aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2011-06-19 00:10:54 +0200
committercedricbonhomme <devnull@localhost>2011-06-19 00:10:54 +0200
commitf34d5bf48f08c75f7dc4476d197735f41219889b (patch)
tree545a94b804657db4c22b09b21d2e5e6ed3363193
parentNew link to the feed page. (diff)
downloadnewspipe-f34d5bf48f08c75f7dc4476d197735f41219889b.tar.gz
newspipe-f34d5bf48f08c75f7dc4476d197735f41219889b.tar.bz2
newspipe-f34d5bf48f08c75f7dc4476d197735f41219889b.zip
Added a new function which enables to change the URL of a feed (this updates all the data base).
-rwxr-xr-xpyAggr3g470r.py14
-rwxr-xr-xutils.py25
-rwxr-xr-xvar/feed.lst4
3 files changed, 36 insertions, 7 deletions
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py
index 51915d0a..a5ed2d4a 100755
--- a/pyAggr3g470r.py
+++ b/pyAggr3g470r.py
@@ -635,6 +635,11 @@ class Root:
html += article.article_date + " - " + \
"""<a class="tooltip" href="/article/%s:%s" rel="noreferrer" target="_blank">%s<span class="classic">%s</span></a><br />\n""" % \
(feed.feed_id, article.article_id, article.article_title[:150], description)
+
+
+ html += """\n<br /><br />\n<form method=post action="/change_feed_url/"><input type="url" name="new_feed_url" value="" placeholder="Enter a new URL for this feed." maxlength=2048 autocomplete="on" size="50" /><input type="hidden" name="old_feed_url" value="%s" /></form>\n""" % \
+ (feed.feed_link,)
+
dic = {}
dic[feed.feed_id] = self.feeds[feed.feed_id]
top_words = utils.top_words(dic, n=50, size=int(word_size))
@@ -648,9 +653,6 @@ class Root:
utils.tag_cloud(top_words) + '</div>'
html += "<br />"
- #html += """<form method=get action="/change_feed_url/"><input type="url" name="querrystring" placeholder="New URL for this feed" maxlength=2048 autocomplete="off">\n<input type="submit" value="OK"></form>\n""" % (feed.feed_id,)
-
-
html += "<hr />"
html += htmlfooter
return html
@@ -1096,14 +1098,16 @@ class Root:
remove_feed.exposed = True
- def change_feed_url(self, querrystring):
+ def change_feed_url(self, new_feed_url, old_feed_url):
"""
Enables to change the URL of a feed already present in the database.
"""
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"
html += htmlfooter
return html
diff --git a/utils.py b/utils.py
index 29ca43d3..c31b24f4 100755
--- a/utils.py
+++ b/utils.py
@@ -253,6 +253,31 @@ def add_feed(feed_url):
f.write(feed_url + "\n")
return True
+def change_feed_url(old_feed_url, new_feed_url):
+ """
+ Change the URL of a feed.
+ """
+ # Replace the URL in the text file
+ with open("./var/feed.lst", "r") as f:
+ lines = f.readlines()
+ try:
+ lines[lines.index(old_feed_url+"\n")] = new_feed_url + '\n'
+ except:
+ return
+ with open("./var/feed.lst", "w") as f:
+ f.write("\n".join(lines))
+
+ # Replace the URL in the data base.
+ try:
+ conn = sqlite3.connect(sqlite_base, isolation_level = None)
+ c = conn.cursor()
+ c.execute("UPDATE articles SET feed_link='" + new_feed_url + "' WHERE feed_link='" + old_feed_url +"'")
+ c.execute("UPDATE feeds SET feed_link='" + new_feed_url + "' WHERE feed_link='" + old_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.
diff --git a/var/feed.lst b/var/feed.lst
index 5678f144..0b373515 100755
--- a/var/feed.lst
+++ b/var/feed.lst
@@ -4,7 +4,7 @@ http://blog.cedricbonhomme.org/feed/
http://bnjgat.fr/weblog/?feed/rss2
http://standblog.org/blog/feed/atom
http://www.haypocalc.com/blog/rss.php
-http://linuxfr.org/backend/news-homepage/rss20.rss
+http://linuxfr.org/news.atom
http://rss.slashdot.org/Slashdot/slashdot
http://theinvisiblethings.blogspot.com/feeds/posts/default
http://torvalds-family.blogspot.com/feeds/posts/default
@@ -24,7 +24,7 @@ http://www.laquadrature.net/en/rss.xml
http://static.fsf.org/fsforg/rss/blogs.xml
http://esr.ibiblio.org/?feed=rss2
http://www.maitre-eolas.fr/feed/atom
-http://linuxfr.org/backend/journaux/rss20.rss
+http://linuxfr.org/journaux.atom
http://www.le-tigre.net/spip.php?page=backend
http://www.schneier.com/blog/index.rdf
http://www.handcrafted-games.com/index.php?feed/atom
bgstack15