aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2011-06-20 19:16:43 +0200
committercedricbonhomme <devnull@localhost>2011-06-20 19:16:43 +0200
commitf8b69e2458bebd5b4ae3aa59d4396e8d5eab807d (patch)
treebb323f1db585d2a4b8cd2e7f99e5f30806763fc7
parentMinor bugfix in a form. (diff)
downloadnewspipe-f8b69e2458bebd5b4ae3aa59d4396e8d5eab807d.tar.gz
newspipe-f8b69e2458bebd5b4ae3aa59d4396e8d5eab807d.tar.bz2
newspipe-f8b69e2458bebd5b4ae3aa59d4396e8d5eab807d.zip
It is now possible to change the name of a feed anytime via the feed management page. The data base is automatically uptodated.
-rwxr-xr-xpyAggr3g470r.py20
-rwxr-xr-xutils.py15
2 files changed, 31 insertions, 4 deletions
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py
index 57c2d986..57f2db1f 100755
--- a/pyAggr3g470r.py
+++ b/pyAggr3g470r.py
@@ -643,11 +643,11 @@ class Root:
# - feed name;
# - URL of the feed (not the site);
html += "<br />\n<h1>Edit this feed</h1>\n"
- html += """\n\n<form method=post action="/change_feed_name/"><input type="text" name="new_feed_name" value="" placeholder="Enter a new name." maxlength=2048 autocomplete="on" size="50" /><input type="hidden" name="old_feed_name" value="%s" /></form>\n""" % \
+ html += """\n\n<form method=post action="/change_feed_name/"><input type="text" name="new_feed_name" value="" placeholder="Enter a new name." maxlength=2048 autocomplete="on" size="50" /><input type="hidden" name="feed_url" value="%s" /></form>\n""" % \
(feed.feed_link,)
html += """\n\n<form method=post action="/change_feed_url/"><input type="url" name="new_feed_url" value="" placeholder="Enter a new URL to retrieve articles." maxlength=2048 autocomplete="on" size="50" /><input type="hidden" name="old_feed_url" value="%s" /></form>\n""" % \
(feed.feed_link,)
- html += """\n\n<form method=post action="/change_feed_logo/"><input type="url" name="new_feed_logo" value="" placeholder="Enter the URL of the logo." maxlength=2048 autocomplete="on" size="50" /><input type="hidden" name="old_feed_logo" value="%s" /></form>\n""" % \
+ html += """\n\n<form method=post action="/change_feed_logo/"><input type="url" name="new_feed_logo" value="" placeholder="Enter the URL of the logo." maxlength=2048 autocomplete="on" size="50" /><input type="hidden" name="feed_url" value="%s" /></form>\n""" % \
(feed.feed_link,)
dic = {}
@@ -1115,7 +1115,6 @@ class Root:
html = htmlheader()
html += htmlnav
html += """<div class="left inner">"""
- print cherrypy.request.params
utils.change_feed_url(old_feed_url, new_feed_url)
html += "<p>The URL of the feed has been changed.</p>"
html += "<hr />\n"
@@ -1123,6 +1122,21 @@ class Root:
return html
change_feed_url.exposed = True
+
+ def change_feed_name(self, feed_url, new_feed_name):
+ """
+ Enables to change the name of a feed.
+ """
+ html = htmlheader()
+ html += htmlnav
+ html += """<div class="left inner">"""
+ utils.change_feed_name(feed_url, new_feed_name)
+ html += "<p>The name of the feed has been changed.</p>"
+ html += "<hr />\n"
+ html += htmlfooter
+ return html
+
+ change_feed_name.exposed = True
def set_max_articles(self, max_nb_articles=1):
diff --git a/utils.py b/utils.py
index c31b24f4..96bfa2c5 100755
--- a/utils.py
+++ b/utils.py
@@ -255,7 +255,7 @@ def add_feed(feed_url):
def change_feed_url(old_feed_url, new_feed_url):
"""
- Change the URL of a feed.
+ Change the URL of a feed given in parameter.
"""
# Replace the URL in the text file
with open("./var/feed.lst", "r") as f:
@@ -278,6 +278,19 @@ def change_feed_url(old_feed_url, new_feed_url):
except Exception, e:
print e
+def change_feed_name(feed_url, new_feed_name):
+ """
+ Change the name of a feed given in parameter.
+ """
+ try:
+ conn = sqlite3.connect(sqlite_base, isolation_level = None)
+ c = conn.cursor()
+ c.execute('UPDATE feeds SET feed_title="' + new_feed_name + '" WHERE feed_link="' + feed_url +'"')
+ conn.commit()
+ c.close()
+ except Exception, e:
+ print e
+
def remove_feed(feed_url):
"""
Remove a feed from the file feed.lst and from the SQLite base.
bgstack15