diff options
Diffstat (limited to 'source')
-rwxr-xr-x | source/pyAggr3g470r.py | 25 | ||||
-rw-r--r-- | source/templates/languages.html | 15 |
2 files changed, 40 insertions, 0 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index cecb73ff..5e979dac 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -452,6 +452,31 @@ class pyAggr3g470r(object): inactives.exposed = True @auth.require() + def languages(self): + """ + Filter by languages. + """ + try: + from guess_language import guess_language + except: + tmpl = lookup.get_template("error.html") + return tmpl.render(message="<p>Module <i>guess_language</i> not installed.</p>") + result = {} + feeds = self.mongo.get_all_feeds() + for feed in feeds: + for article in self.mongo.get_articles(feed["feed_id"]): + language = guess_language(utils.clear_string(article["article_content"])) + if language not in result.keys(): + result[language] = {} + if feed["feed_title"] not in result[language].keys(): + result[language][feed["feed_title"]] = [] + result[language][feed["feed_title"]].append(article) + tmpl = lookup.get_template("languages.html") + return tmpl.render(articles_sorted_by_languages=result) + + languages.exposed = True + + @auth.require() def add_feed(self, url): """ Add a new feed with the URL of a page. diff --git a/source/templates/languages.html b/source/templates/languages.html new file mode 100644 index 00000000..202f02c8 --- /dev/null +++ b/source/templates/languages.html @@ -0,0 +1,15 @@ +## languages.html +<%inherit file="base.html"/> +<div class="left inner"> + %for language in articles_sorted_by_languages.keys(): + <h1>${language}</h1> + %for feed in articles_sorted_by_languages[language]: + <h2>${feed}</h2> + %for article in articles_sorted_by_languages[language][feed]: + ${article["article_title"]} + <br /> + %endfor + <br /> + %endfor + <br /> + %endfor
\ No newline at end of file |