From e6472738b5253aa328f8b2a4f4f2a23abc8582c2 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 15 Apr 2012 18:59:50 +0200 Subject: Reorganization of folders. --- .hgsub | 1 - .hgsubstate | 1 - COPYING | 674 ----------------- README | 84 --- cfg/cherrypy.cfg | 24 - cfg/pyAggr3g470r.cfg-sample | 15 - css/style.css | 374 ---------- epub/__init__.py | 1 - epub/epub.py | 343 --------- epub/ez_epub.py | 36 - epub/templates/container.xml | 6 - epub/templates/content.opf | 34 - epub/templates/ez-section.html | 17 - epub/templates/image.html | 16 - epub/templates/title-page.html | 22 - epub/templates/toc.html | 32 - epub/templates/toc.ncx | 28 - export.py | 190 ----- feedgetter.py | 167 ----- img/blogmarks.png | Bin 195 -> 0 bytes img/check-news.png | Bin 1383 -> 0 bytes img/cross.png | Bin 655 -> 0 bytes img/diaspora.png | Bin 1179 -> 0 bytes img/digg.png | Bin 358 -> 0 bytes img/email-follow.png | Bin 4056 -> 0 bytes img/favicon.png | Bin 6879 -> 0 bytes img/feed-icon-28x28.png | Bin 1737 -> 0 bytes img/following-article.png | Bin 989 -> 0 bytes img/hacker-news.png | Bin 265 -> 0 bytes img/heart-32x32.png | Bin 2084 -> 0 bytes img/heart.png | Bin 634 -> 0 bytes img/heart_open.png | Bin 687 -> 0 bytes img/history.png | Bin 3257 -> 0 bytes img/identica.png | Bin 459 -> 0 bytes img/management.png | Bin 2916 -> 0 bytes img/mark-as-read.png | Bin 1762 -> 0 bytes img/pinboard.png | Bin 597 -> 0 bytes img/previous-article.png | Bin 997 -> 0 bytes img/reddit.png | Bin 525 -> 0 bytes img/scoopeo.png | Bin 295 -> 0 bytes img/tuxrss.png | Bin 6879 -> 0 bytes img/unread.png | Bin 1580 -> 0 bytes mongodb.py | 253 ------- pyAggr3g470r | 130 ---- pyAggr3g470r.py | 1271 --------------------------------- source/.hgsub | 1 + source/COPYING | 674 +++++++++++++++++ source/README | 84 +++ source/cfg/cherrypy.cfg | 24 + source/cfg/pyAggr3g470r.cfg-sample | 15 + source/css/style.css | 374 ++++++++++ source/epub/__init__.py | 1 + source/epub/epub.py | 343 +++++++++ source/epub/ez_epub.py | 36 + source/epub/templates/container.xml | 6 + source/epub/templates/content.opf | 34 + source/epub/templates/ez-section.html | 17 + source/epub/templates/image.html | 16 + source/epub/templates/title-page.html | 22 + source/epub/templates/toc.html | 32 + source/epub/templates/toc.ncx | 28 + source/export.py | 190 +++++ source/feedgetter.py | 167 +++++ source/img/blogmarks.png | Bin 0 -> 195 bytes source/img/check-news.png | Bin 0 -> 1383 bytes source/img/cross.png | Bin 0 -> 655 bytes source/img/diaspora.png | Bin 0 -> 1179 bytes source/img/digg.png | Bin 0 -> 358 bytes source/img/email-follow.png | Bin 0 -> 4056 bytes source/img/favicon.png | Bin 0 -> 6879 bytes source/img/feed-icon-28x28.png | Bin 0 -> 1737 bytes source/img/following-article.png | Bin 0 -> 989 bytes source/img/hacker-news.png | Bin 0 -> 265 bytes source/img/heart-32x32.png | Bin 0 -> 2084 bytes source/img/heart.png | Bin 0 -> 634 bytes source/img/heart_open.png | Bin 0 -> 687 bytes source/img/history.png | Bin 0 -> 3257 bytes source/img/identica.png | Bin 0 -> 459 bytes source/img/management.png | Bin 0 -> 2916 bytes source/img/mark-as-read.png | Bin 0 -> 1762 bytes source/img/pinboard.png | Bin 0 -> 597 bytes source/img/previous-article.png | Bin 0 -> 997 bytes source/img/reddit.png | Bin 0 -> 525 bytes source/img/scoopeo.png | Bin 0 -> 295 bytes source/img/tuxrss.png | Bin 0 -> 6879 bytes source/img/unread.png | Bin 0 -> 1580 bytes source/mongodb.py | 253 +++++++ source/pyAggr3g470r | 130 ++++ source/pyAggr3g470r.py | 1271 +++++++++++++++++++++++++++++++++ source/sqlite2mongo.py | 78 ++ source/utils.py | 351 +++++++++ source/var/feed.lst | 37 + sqlite2mongo.py | 78 -- utils.py | 351 --------- var/feed.lst | 37 - 95 files changed, 4184 insertions(+), 4185 deletions(-) delete mode 100644 .hgsub delete mode 100644 .hgsubstate delete mode 100755 COPYING delete mode 100644 README delete mode 100644 cfg/cherrypy.cfg delete mode 100755 cfg/pyAggr3g470r.cfg-sample delete mode 100755 css/style.css delete mode 100644 epub/__init__.py delete mode 100644 epub/epub.py delete mode 100644 epub/ez_epub.py delete mode 100644 epub/templates/container.xml delete mode 100644 epub/templates/content.opf delete mode 100644 epub/templates/ez-section.html delete mode 100644 epub/templates/image.html delete mode 100644 epub/templates/title-page.html delete mode 100644 epub/templates/toc.html delete mode 100644 epub/templates/toc.ncx delete mode 100644 export.py delete mode 100755 feedgetter.py delete mode 100755 img/blogmarks.png delete mode 100644 img/check-news.png delete mode 100644 img/cross.png delete mode 100644 img/diaspora.png delete mode 100755 img/digg.png delete mode 100644 img/email-follow.png delete mode 100644 img/favicon.png delete mode 100755 img/feed-icon-28x28.png delete mode 100644 img/following-article.png delete mode 100644 img/hacker-news.png delete mode 100644 img/heart-32x32.png delete mode 100644 img/heart.png delete mode 100644 img/heart_open.png delete mode 100644 img/history.png delete mode 100644 img/identica.png delete mode 100644 img/management.png delete mode 100644 img/mark-as-read.png delete mode 100644 img/pinboard.png delete mode 100644 img/previous-article.png delete mode 100755 img/reddit.png delete mode 100755 img/scoopeo.png delete mode 100644 img/tuxrss.png delete mode 100644 img/unread.png delete mode 100644 mongodb.py delete mode 100755 pyAggr3g470r delete mode 100755 pyAggr3g470r.py create mode 100644 source/.hgsub create mode 100755 source/COPYING create mode 100644 source/README create mode 100644 source/cfg/cherrypy.cfg create mode 100755 source/cfg/pyAggr3g470r.cfg-sample create mode 100755 source/css/style.css create mode 100644 source/epub/__init__.py create mode 100644 source/epub/epub.py create mode 100644 source/epub/ez_epub.py create mode 100644 source/epub/templates/container.xml create mode 100644 source/epub/templates/content.opf create mode 100644 source/epub/templates/ez-section.html create mode 100644 source/epub/templates/image.html create mode 100644 source/epub/templates/title-page.html create mode 100644 source/epub/templates/toc.html create mode 100644 source/epub/templates/toc.ncx create mode 100644 source/export.py create mode 100755 source/feedgetter.py create mode 100755 source/img/blogmarks.png create mode 100644 source/img/check-news.png create mode 100644 source/img/cross.png create mode 100644 source/img/diaspora.png create mode 100755 source/img/digg.png create mode 100644 source/img/email-follow.png create mode 100644 source/img/favicon.png create mode 100755 source/img/feed-icon-28x28.png create mode 100644 source/img/following-article.png create mode 100644 source/img/hacker-news.png create mode 100644 source/img/heart-32x32.png create mode 100644 source/img/heart.png create mode 100644 source/img/heart_open.png create mode 100644 source/img/history.png create mode 100644 source/img/identica.png create mode 100644 source/img/management.png create mode 100644 source/img/mark-as-read.png create mode 100644 source/img/pinboard.png create mode 100644 source/img/previous-article.png create mode 100755 source/img/reddit.png create mode 100755 source/img/scoopeo.png create mode 100644 source/img/tuxrss.png create mode 100644 source/img/unread.png create mode 100644 source/mongodb.py create mode 100755 source/pyAggr3g470r create mode 100755 source/pyAggr3g470r.py create mode 100644 source/sqlite2mongo.py create mode 100755 source/utils.py create mode 100755 source/var/feed.lst delete mode 100644 sqlite2mongo.py delete mode 100755 utils.py delete mode 100755 var/feed.lst diff --git a/.hgsub b/.hgsub deleted file mode 100644 index bc339e87..00000000 --- a/.hgsub +++ /dev/null @@ -1 +0,0 @@ -qrcode = http://hg.cedricbonhomme.org/qrcode/ diff --git a/.hgsubstate b/.hgsubstate deleted file mode 100644 index cf4d43fa..00000000 --- a/.hgsubstate +++ /dev/null @@ -1 +0,0 @@ -95fa18e08f277df2f4d03da06e0fe8c7c8cd4e8e qrcode diff --git a/COPYING b/COPYING deleted file mode 100755 index 20d40b6b..00000000 --- a/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. \ No newline at end of file diff --git a/README b/README deleted file mode 100644 index a2737f76..00000000 --- a/README +++ /dev/null @@ -1,84 +0,0 @@ -.. -*-restructuredtext-*- - -============ -pyAggr3g470r -============ - -.. Use headers in this order #=~-_ - -:toc: yes -:symrefs: yes -:sortrefs: yes -:compact: yes -:subcompact: no -:rfcedstyle: no -:comments: no -:inline: yes -:private: yes - -:author: Cédric Bonhomme -:contact: http://cedricbonhomme.org/ - - -Presentation ------------- -pyAggr3g470r_ is a multi-threaded news aggregator with a web interface -based on CherryPy_. Articles are stored in a MongoDB_ base. - - - -Features ------------- -* articles are stored in a MongoDB_ database; -* find an article with history; -* e-mail notification; -* export articles to HTML, EPUB, PDF or raw text; -* mark or unmark articles as favorites; -* share articles with Diaspora, Google Buzz, Pinboard, delicious, Identi.ca, Digg, reddit, Scoopeo, Blogmarks and Twitter; -* generation of QR code with the content or URL of an article. So you can read an article later on your smartphone (or share with friends). - - - -Requierements -------------- -Software required -~~~~~~~~~~~~~~~~~ -* Python_ 2.7.*; -* MongoDB_ and PyMongo_; -* feedparser_; -* CherryPy_ (version 3 and up); -* BeautifulSoup_. - - -Optional module -~~~~~~~~~~~~~~~ -These modules are not required but enables more features: -* lxml and Genshi; -* Python Imaging Library for the generation of QR codes. - - -If you want to install these modules: - - sudo aptitude install python-lxml python-genshi - - -Donnation ---------- -If you wish and if you like pyAggr3g470r, you can donate via bitcoin. My bitcoin address: 1GVmhR9fbBeEh7rP1qNq76jWArDdDQ3otZ -Thank you! - - - -License ------------- -pyAggr3g470r_ is under GPLv3_ license. - - -.. _Python: http://python.org/ -.. _pyAggr3g470r: https://bitbucket.org/cedricbonhomme/pyaggr3g470r/ -.. _feedparser: http://feedparser.org/ -.. _MongoDB: http://www.mongodb.org/ -.. _PyMongo: https://github.com/mongodb/mongo-python-driver -.. _CherryPy: http://cherrypy.org/ -.. _BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/ -.. _GPLv3: http://www.gnu.org/licenses/gpl-3.0.txt diff --git a/cfg/cherrypy.cfg b/cfg/cherrypy.cfg deleted file mode 100644 index a419504d..00000000 --- a/cfg/cherrypy.cfg +++ /dev/null @@ -1,24 +0,0 @@ -[global] -log.error_file = "var/error.log" -log.access_file = "var/access.log" -server.environment = "production" -engine.autoreload_on = True -engine.autoreload_frequency = 5 -engine.timeout_monitor.on = False - -[/] -tools.staticdir.root = os.getcwd() -tools.staticdir.on = True -tools.staticdir.dir = "." -tools.encode.on = True -tools.encode.encoding = "utf8" - -[/css] -tools.staticdir.on = True -tools.staticdir.dir = "css" -tools.staticdir.match = "(?i)^.+\.css$" - -[/images] -tools.staticdir.on = True -tools.staticdir.dir = "img" -tools.staticdir.match = "(?i)^.+\.png$" \ No newline at end of file diff --git a/cfg/pyAggr3g470r.cfg-sample b/cfg/pyAggr3g470r.cfg-sample deleted file mode 100755 index 95db75c5..00000000 --- a/cfg/pyAggr3g470r.cfg-sample +++ /dev/null @@ -1,15 +0,0 @@ -[global] -max_nb_articles = 50 -[MongoDB] -address = 127.0.0.1 -port = 27017 -user = username -password = pwd -[mail] -mail_from = pyAggr3g470r@no-reply.com -mail_to = address_of_the_recipient@example.com -smtp = smtp.example.com -username = your_mail_address@example.com -password = your_password -[misc] -diaspora_pod = joindiaspora.com diff --git a/css/style.css b/css/style.css deleted file mode 100755 index 5f9574e7..00000000 --- a/css/style.css +++ /dev/null @@ -1,374 +0,0 @@ -html, body { - margin: 0; - padding: 0; - width: 100%; - height: 100%; - overflow-x: hidden; - background-color: white; - color: black; -} - -body { - text-align: justify; - font: 400 0.85em Cambria, Georgia, "Trebuchet MS", Verdana, sans-serif; -} - -code, pre { - font: 400 0.85em Cambria, Georgia, "Trebuchet MS", Verdana, sans-serif, Fixed; - white-space:pre-wrap; -} - -img { - border: 0px; -} - -h1 { - font-size: 100%; - margin: 0em 0em; - padding: 0px; -} - -h2 { - margin: 0.5em 0em; - padding: 0px; - font-style: normal; - font-variant: normal; - font-weight: bold; - font-size: 100%; - letter-spacing: 0em; - text-align: right; -} - -h3 { - margin: 0em 0em 0.5em 0em; - font-size: 100%; - font-weight: bold; - text-align: left; -} - -h1 a, h2 a, h3 a { - text-decoration: none; -} - -h2 + h3 { - margin-top: 0.5em; -} - -table { - margin-left: 2em; - margin-bottom: 1em; - border-collapse: collapse; - text-align: left; -} - -th, td { - padding-right: 1em; - text-align: left; -} - -th { - vertical-align: bottom; - border-bottom: 1px solid black; - text-align: left; -} - -td { - vertical-align: top; - padding-top: 5px; - text-align: left; -} - -table.border td, table.border th { - border: 1px solid black; -} - -p { - margin: 0.5em 0em; -} - -ol.lower { - list-style-type: lower-alpha; -} - -ol.upper { - list-style-type: upper-alpha; -} - -ol.roman { - list-style-type: lower-roman; -} - -ul { - margin: 0em 0em 0.5em 0.5em; - padding: 0em; -} - -li { - margin: 0em 0em 0em 0.5em; - padding: 0em; -} - -a:link, a:visited { - color: #003399; - text-decoration:none -} - -a:hover { - color: blue; -} - -dt { - margin: 0.5em 0em 0em 0em; - padding: 0em; - font-weight: bold; -} - -dd { - margin: 0em; -} - -hr { - color: white; - border-top: dotted black; - border-width: 1px 0px 0px 0px; - margin: 1em 0em; -} - - -#heading { - position: absolute; - left: 0px; - top: 0px; - width: 100%; - z-index: 1; -} - -/* Navigation bars */ -.nav_container { position:fixed; top:160px; right:60px; margin:0px; padding:0px; white-space:nowrap; z-index:11; clear:both;} -.nav_container.horizontal { position:absolute; white-space:normal; z-index:25; width:670px; } -.nav_container.horizontal div { float:right; padding-right:10px; } - -#nav { - position: absolute; - top: 0px; - right: 0px; - z-index: 2; -} - -#heading, #nav, #nav ul { - margin: 0; - height: 1.8em; -} - -#heading, #nav ul, #nav li { - background: #EEEEEE; - color: inherit; - border-bottom: 0px solid black; -} - -#heading h1 { - margin: 0; - padding: 0.4em 0 0.4em 2em; - white-space: nowrap; -} - -#nav ul { - display: block; - margin: 0 3em 0 0; - border-right: 0px solid #000000; -} - -#nav li { - margin: 0em; - padding: 0.4em 1em 0.2em 1em; - display: block; - float: left; - border-left: 0px solid #000000; -} - -pre { - margin-left: 2em; -} - -.right { - clear: right; - float: right; - text-align: right; - margin: 0em 2em 0em 2em; - max-width: 36%; -} - -img.right { - width: auto; -} - -.inner .right { - margin-right: 0em; -} - -.right blockquote { - float: right; - position: relative; - clear: both; - padding-top: 1em; - padding-bottom: 0em; - margin-bottom: 0em; - font-style: italic; - width: 100%; - margin-right: 0em; -} - -blockquote.right { - width: 50%; - margin-left: 50%; - margin-right: 0em; -} - -/* Footer (W3C logos) */ - -#w3c { - text-align: right; - padding: 0em 2em 0em 2em; - clear: both; -} - -#w3c img { - padding-left: 10px; - padding-top: 1em; -} - -/* Classes */ - -.clear { - font-size: 1px; - line-height: 1px; - height: 0px; - clear: both; -} - -.invisible { - display: none; -} - -.inner { - margin-top: 3em; - padding: 0em 2em 0em 2em; - clear: both; -} - -.innerlogo { - margin-top: 0em; - padding: 0em 2em 0em 2em; - clear: both; -} - -.left { - float: left; - position: absolute; - -} - -.tex { - position: relative; top: 0.2em; - margin-left: -0.2em; - margin-right: -0.1em; -} - -/* Photo album */ - -#album { - margin: 0 auto; - padding: 3em 2em 0em 2em; -} - -#thumbs { - background: white; - position: absolute; - left: 2em; - right: 2em; - margin-top: -100px; - padding-bottom: 0.5em; - overflow: auto; -} - -#thumbs table { - margin: 0 auto; - position: relative; - max-width: 100%; - border-collapse: collapse; - border: 0px; -} - -#pageselectors { - margin-top: 1em; - text-align: center; - padding-bottom: 100px; - margin-bottom: 0.5em; -} - -#thumbs img, #photo img { - display: block; - margin: 0 auto; -} - -#thumbs td { - width: 8em; - min-width: 100px; - text-align: center; - padding: 0.5em 0.5em 0em 0em; - border: 0px; - margin: 0px; -} - -#photo { - text-align: center; -} - -#thumbs img { - opacity: 0.99; - -moz-opacity: 0.99; -} - -#thumbs img:hover { - opacity: 0.7; - -moz-opacity: 0.7; -} - -#photo img { - max-width: 100%; - min-height: 300px; - max-height: 300px; - overflow: scroll; - margin-top: 0.5em; -} - -/* CSS ToolTips */ - .tooltip { - color: #FFF; - outline: none; - text-decoration: none; - position: relative; - } - - .tooltip span { - color: #FFF; - margin-left: -999em; - position: absolute; - } - - .tooltip:hover span { - border-radius: 5px 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; - box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); - font-family: Calibri, Tahoma, Geneva, sans-serif; - position: absolute; left: 1em; top: 2em; z-index: 99; - margin-left: 0; width: 250px; - } - .classic { - padding: 0.8em 1em; - background: rgba(0, 0, 0, 0.85); - border: 5px 5px; - } - - * html a:hover { - background: transparent; - } \ No newline at end of file diff --git a/epub/__init__.py b/epub/__init__.py deleted file mode 100644 index 8d1c8b69..00000000 --- a/epub/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/epub/epub.py b/epub/epub.py deleted file mode 100644 index 2c01b54a..00000000 --- a/epub/epub.py +++ /dev/null @@ -1,343 +0,0 @@ -#! /usr/local/bin/python -#-*- coding: utf-8 -*- - -import itertools -import mimetypes -import os -import shutil -import subprocess -import uuid -import zipfile -from genshi.template import TemplateLoader -from lxml import etree - -class TocMapNode: - def __init__(self): - self.playOrder = 0 - self.title = '' - self.href = '' - self.children = [] - self.depth = 0 - - def assignPlayOrder(self): - nextPlayOrder = [0] - self.__assignPlayOrder(nextPlayOrder) - - def __assignPlayOrder(self, nextPlayOrder): - self.playOrder = nextPlayOrder[0] - nextPlayOrder[0] = self.playOrder + 1 - for child in self.children: - child.__assignPlayOrder(nextPlayOrder) - -class EpubItem: - def __init__(self): - self.id = '' - self.srcPath = '' - self.destPath = '' - self.mimeType = '' - self.html = '' - -class EpubBook: - def __init__(self): - self.loader = TemplateLoader('./epub/templates') - - self.rootDir = '' - self.UUID = uuid.uuid1() - - self.lang = 'en-US' - self.title = '' - self.creators = [] - self.metaInfo = [] - - self.imageItems = {} - self.htmlItems = {} - self.cssItems = {} - - self.coverImage = None - self.titlePage = None - self.tocPage = None - - self.spine = [] - self.guide = {} - self.tocMapRoot = TocMapNode() - self.lastNodeAtDepth = {0 : self.tocMapRoot} - - def setTitle(self, title): - self.title = title - - def setLang(self, lang): - self.lang = lang - - def addCreator(self, name, role = 'aut'): - self.creators.append((name, role)) - - def addMeta(self, metaName, metaValue, **metaAttrs): - self.metaInfo.append((metaName, metaValue, metaAttrs)) - - def getMetaTags(self): - l = [] - for metaName, metaValue, metaAttr in self.metaInfo: - beginTag = ' - -%s -

%s

- -""" % (text, text) - - book = EpubBook() - book.setTitle('Most Wanted Tips for Aspiring Young Pirates') - book.addCreator('Monkey D Luffy') - book.addCreator('Guybrush Threepwood') - book.addMeta('contributor', 'Smalltalk80', role = 'bkp') - book.addMeta('date', '2010', event = 'publication') - - book.addTitlePage() - book.addTocPage() - book.addCover(r'D:\epub\blank.png') - - book.addCss(r'main.css', 'main.css') - - n1 = book.addHtml('', '1.html', getMinimalHtml('Chapter 1')) - n11 = book.addHtml('', '2.html', getMinimalHtml('Section 1.1')) - n111 = book.addHtml('', '3.html', getMinimalHtml('Subsection 1.1.1')) - n12 = book.addHtml('', '4.html', getMinimalHtml('Section 1.2')) - n2 = book.addHtml('', '5.html', getMinimalHtml('Chapter 2')) - - book.addSpineItem(n1) - book.addSpineItem(n11) - book.addSpineItem(n111) - book.addSpineItem(n12) - book.addSpineItem(n2) - - # You can use both forms to add TOC map - #t1 = book.addTocMapNode(n1.destPath, '1') - #t11 = book.addTocMapNode(n11.destPath, '1.1', parent = t1) - #t111 = book.addTocMapNode(n111.destPath, '1.1.1', parent = t11) - #t12 = book.addTocMapNode(n12.destPath, '1.2', parent = t1) - #t2 = book.addTocMapNode(n2.destPath, '2') - - book.addTocMapNode(n1.destPath, '1') - book.addTocMapNode(n11.destPath, '1.1', 2) - book.addTocMapNode(n111.destPath, '1.1.1', 3) - book.addTocMapNode(n12.destPath, '1.2', 2) - book.addTocMapNode(n2.destPath, '2') - - rootDir = r'd:\epub\test' - book.createBook(rootDir) - EpubBook.createArchive(rootDir, rootDir + '.epub') - -if __name__ == '__main__': - test() \ No newline at end of file diff --git a/epub/ez_epub.py b/epub/ez_epub.py deleted file mode 100644 index ecfd4f5a..00000000 --- a/epub/ez_epub.py +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/local/bin/python -#-*- coding: utf-8 -*- - -import epub -from genshi.template import TemplateLoader - -class Section: - def __init__(self): - self.title = '' - self.paragraphs = [] - self.tocDepth = 1 - -def makeBook(title, authors, sections, outputDir, lang='en-US', cover=None): - book = epub.EpubBook() - book.setLang(lang) - book.setTitle(title) - for author in authors: - book.addCreator(author) - #book.addTitlePage() - #book.addTocPage() - #if cover: - #book.addCover(cover) - - loader = TemplateLoader('./epub/templates') - tmpl = loader.load('ez-section.html') - - for i, section in enumerate(sections): - stream = tmpl.generate(section = section) - html = stream.render('xhtml', doctype='xhtml11', drop_xml_decl=False) - item = book.addHtml('', 's%d.html' % (i + 1), html) - book.addSpineItem(item) - book.addTocMapNode(item.destPath, section.title, section.tocDepth) - - outputFile = outputDir + 'article.epub' - book.createBook(outputDir) - book.createArchive(outputDir, outputFile) \ No newline at end of file diff --git a/epub/templates/container.xml b/epub/templates/container.xml deleted file mode 100644 index eecf7a0d..00000000 --- a/epub/templates/container.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/epub/templates/content.opf b/epub/templates/content.opf deleted file mode 100644 index 67f3f5c6..00000000 --- a/epub/templates/content.opf +++ /dev/null @@ -1,34 +0,0 @@ - - - - urn:uuid:${book.UUID} - ${book.lang} - ${book.title} - - $name - - - ${Markup(beginTag)}$content${Markup(endTag)} - - - - - - - - - - - - - - - - - - - - diff --git a/epub/templates/ez-section.html b/epub/templates/ez-section.html deleted file mode 100644 index 0a715e7f..00000000 --- a/epub/templates/ez-section.html +++ /dev/null @@ -1,17 +0,0 @@ - - - ${section.title} - - - -

${section.title}

- -

$p

-
- - diff --git a/epub/templates/image.html b/epub/templates/image.html deleted file mode 100644 index 9a838c7e..00000000 --- a/epub/templates/image.html +++ /dev/null @@ -1,16 +0,0 @@ - - - ${item.destPath} - - - -
${item.destPath}
- - diff --git a/epub/templates/title-page.html b/epub/templates/title-page.html deleted file mode 100644 index de0f55f0..00000000 --- a/epub/templates/title-page.html +++ /dev/null @@ -1,22 +0,0 @@ - - - ${book.title} - - - -

${book.title}

-

- - $creator - -

- - diff --git a/epub/templates/toc.html b/epub/templates/toc.html deleted file mode 100644 index b14c9da3..00000000 --- a/epub/templates/toc.html +++ /dev/null @@ -1,32 +0,0 @@ - - - ${book.title} - - - - - - - ${tocEntry(child)} - - - - ${tocEntry(child)} - - - diff --git a/epub/templates/toc.ncx b/epub/templates/toc.ncx deleted file mode 100644 index e7dd391a..00000000 --- a/epub/templates/toc.ncx +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - ${book.title} - - - - - ${node.title} - - - ${navPoint(child)} - - - - - ${navPoint(child)} - - - diff --git a/export.py b/export.py deleted file mode 100644 index a14d47c0..00000000 --- a/export.py +++ /dev/null @@ -1,190 +0,0 @@ -#! /usr/bin/env python -#-*- coding: utf-8 -*- - -# pyAggr3g470r - A Web based news aggregator. -# Copyright (C) 2010 Cédric Bonhomme - http://cedricbonhomme.org/ -# -# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see - -__author__ = "Cedric Bonhomme" -__version__ = "$Revision: 0.1 $" -__date__ = "$Date: 2011/10/24 $" -__copyright__ = "Copyright (c) Cedric Bonhomme" -__license__ = "GPLv3" - -# -# This file contains the export functions of pyAggr3g470r. Indeed -# it is possible to export the database of articles in different formats: -# - simple HTML webzine; -# - text file; -# - ePub file; -# - PDF file. -# - -import os -import hashlib - -import utils - - -htmlheader = '\n' + \ - '' + \ - '\n\tpyAggr3g470r - News aggregator\n' + \ - '\t' + \ - '\n\t\n' + \ - '\n' - -htmlfooter = '

This software is under GPLv3 license. You are welcome to copy, modify or' + \ - ' redistribute the source code according to the' + \ - ' GPLv3 license.

\n' + \ - '\n' - - - -def export_html(feeds): - """ - Export the articles given in parameter in a simple Webzine. - """ - index = htmlheader - index += "
\n
    " - for feed in feeds.values(): - # creates a folder for each stream - feed_folder = utils.path + "/var/export/webzine/" + \ - utils.normalize_filename(feed.feed_id) - try: - os.makedirs(feed_folder) - except OSError: - # directories already exists (not a problem) - pass - - - index += """
  • %s
  • \n""" % \ - (feed.feed_id, feed.feed_title) - - posts = htmlheader - for article in feed.articles.values(): - - post_file_name = os.path.normpath(feed_folder + "/" + article.article_id + ".html") - feed_index = os.path.normpath(feed_folder + "/index.html") - - posts += article.article_date + " - " + \ - """%s""" % \ - (article.article_id, article.article_title[:150]) + "
    \n" - - - a_post = htmlheader - a_post += '\n
    \n' - a_post += """

    %s


    """ % \ - (article.article_link, article.article_title) - a_post += article.article_description - a_post += "
    \n
    \n" - a_post += """
    \nComplete story\n
    \n""" % (article.article_link,) - a_post += "
    \n" + htmlfooter - - - with open(post_file_name, "w") as f: - f.write(a_post) - - posts += htmlfooter - with open(feed_index, "w") as f: - f.write(posts) - - index += "\n
\n
" - index += htmlfooter - with open(utils.path + "/var/export/webzine/" + "index.html", "w") as f: - f.write(index) - -def export_txt(feeds): - """ - Export the articles given in parameter in text files. - """ - for feed in feeds.values(): - # creates folder for each stream - folder = utils.path + "/var/export/txt/" + \ - utils.normalize_filename(feed.feed_title.strip().replace(':', '').lower()) - try: - os.makedirs(folder) - except OSError: - # directories already exists (not a problem) - pass - - for article in feed.articles.values(): - name = article.article_date.strip().replace(' ', '_') - name = os.path.normpath(folder + "/" + name + ".txt") - - content = "Title: " + article.article_title + "\n\n\n" - content += utils.clear_string(article.article_description) - - with open(name, "w") as f: - f.write(content) - -def export_epub(feeds): - """ - Export the articles given in parameter in ePub files. - """ - from epub import ez_epub - for feed in feeds.values(): - # creates folder for each stream - folder = utils.path + "/var/export/epub/" + \ - utils.normalize_filename(feed.feed_title.strip().replace(':', '').lower()) - try: - os.makedirs(folder) - except OSError: - # directories already exists (not a problem) - pass - - for article in feed.articles.values(): - name = article.article_date.strip().replace(' ', '_') - name = os.path.normpath(folder + "/" + name + ".epub") - - section = ez_epub.Section() - section.title = article.article_title.decode('utf-8') - section.paragraphs = [utils.clear_string(article.article_description).decode('utf-8')] - ez_epub.makeBook(article.article_title.decode('utf-8'), [feed.feed_title.decode('utf-8')], [section], \ - name, lang='en-US', cover=None) - -def export_pdf(feeds): - """ - Export the articles given in parameter in PDF files. - """ - from xhtml2pdf import pisa - import cStringIO as StringIO - for feed in feeds.values(): - # creates folder for each stream - folder = utils.path + "/var/export/pdf/" + \ - utils.normalize_filename(feed.feed_title.strip().replace(':', '').lower()) - try: - os.makedirs(folder) - except OSError: - # directories already exists (not a problem) - pass - - for article in feed.articles.values(): - name = article.article_date.strip().replace(' ', '_') - name = os.path.normpath(folder + "/" + name + ".pdf") - - content = htmlheader - content += '\n
\n' - content += """

%s


""" % \ - (article.article_link, article.article_title) - content += article.article_description - content += "
\n
\n" - content += htmlfooter - - try: - pdf = pisa.CreatePDF(StringIO.StringIO(content), file(name, "wb")) - except: - pass \ No newline at end of file diff --git a/feedgetter.py b/feedgetter.py deleted file mode 100755 index e3469132..00000000 --- a/feedgetter.py +++ /dev/null @@ -1,167 +0,0 @@ -#! /usr/bin/env python -#-*- coding: utf-8 -*- - -# pyAggr3g470r - A Web based news aggregator. -# Copyright (C) 2010 Cédric Bonhomme - http://cedricbonhomme.org/ -# -# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see - -__author__ = "Cedric Bonhomme" -__version__ = "$Revision: 1.0 $" -__date__ = "$Date: 2010/09/02 $" -__copyright__ = "Copyright (c) Cedric Bonhomme" -__license__ = "GPLv3" - -import os.path -import traceback -import threading -import feedparser -import hashlib -from BeautifulSoup import BeautifulSoup - -from datetime import datetime - -import utils -import mongodb - -feeds_list = [] -list_of_threads = [] - - -class FeedGetter(object): - """ - This class is in charge of retrieving feeds listed in ./var/feed.lst. - This class uses feedparser module from Mark Pilgrim. - For each feed a new thread is launched. - """ - def __init__(self): - """ - Initializes the base and variables. - """ - # MongoDB connections - self.articles = mongodb.Articles() - - def retrieve_feed(self): - """ - Parse the file 'feeds.lst' and launch a thread for each RSS feed. - """ - with open("./var/feed.lst") as f: - for a_feed in f: - # test if the URL is well formed - for url_regexp in utils.url_finders: - if url_regexp.match(a_feed): - the_good_url = url_regexp.match(a_feed).group(0).replace("\n", "") - try: - # launch a new thread for the RSS feed - thread = threading.Thread(None, self.process, \ - None, (the_good_url,)) - thread.start() - list_of_threads.append(thread) - except: - pass - break - - # wait for all threads are done - for th in list_of_threads: - th.join() - - def process(self, the_good_url): - """Request the URL - - Executed in a thread. - """ - if utils.detect_url_errors([the_good_url]) == []: - # if ressource is available add the articles in the base. - self.add_into_database(the_good_url) - - def add_into_database(self, feed_link): - """ - Add the articles of the feed 'a_feed' in the SQLite base. - """ - a_feed = feedparser.parse(feed_link) - if a_feed['entries'] == []: - return - try: - feed_image = a_feed.feed.image.href - except: - feed_image = "/img/feed-icon-28x28.png" - - sha1_hash = hashlib.sha1() - sha1_hash.update(feed_link.encode('utf-8')) - feed_id = sha1_hash.hexdigest() - - collection_dic = {"feed_id": feed_id, \ - "type": 0, \ - "feed_image": feed_image, \ - "feed_title": utils.clear_string(a_feed.feed.title.encode('utf-8')), \ - "feed_link": feed_link, \ - "site_link": a_feed.feed.link.encode('utf-8'), \ - "mail": False \ - } - - self.articles.add_collection(collection_dic) - - articles = [] - for article in a_feed['entries']: - description = "" - try: - # article content - description = article.content[0].value - except AttributeError: - try: - # article description - description = article.description - except Exception, e: - description = "" - description = str(BeautifulSoup(description)) - article_title = str(BeautifulSoup(article.title)) - - try: - post_date = datetime(*article.updated_parsed[:6]) - except: - post_date = datetime(*article.published_parsed[:6]) - - - sha1_hash = hashlib.sha1() - sha1_hash.update(article.link.encode('utf-8')) - article_id = sha1_hash.hexdigest() - - article = {"article_id": article_id, \ - "type":1, \ - "article_date": post_date, \ - "article_link": article.link.encode('utf-8'), \ - "article_title": article_title, \ - "article_content": description, \ - "article_readed": False, \ - "article_like": False \ - } - - articles.append(article) - - self.articles.add_articles(articles, feed_id) - - # send new articles by e-mail if desired. - #threading.Thread(None, utils.send_mail, None, (utils.mail_from, utils.mail_to, \ - #a_feed.feed.title.encode('utf-8'), \ - #article_title, description) \ - #).start() - - - -if __name__ == "__main__": - # Point of entry in execution mode - feed_getter = FeedGetter() - feed_getter.retrieve_feed() diff --git a/img/blogmarks.png b/img/blogmarks.png deleted file mode 100755 index 2464e5bb..00000000 Binary files a/img/blogmarks.png and /dev/null differ diff --git a/img/check-news.png b/img/check-news.png deleted file mode 100644 index cce7df39..00000000 Binary files a/img/check-news.png and /dev/null differ diff --git a/img/cross.png b/img/cross.png deleted file mode 100644 index 1514d51a..00000000 Binary files a/img/cross.png and /dev/null differ diff --git a/img/diaspora.png b/img/diaspora.png deleted file mode 100644 index fdf8bb72..00000000 Binary files a/img/diaspora.png and /dev/null differ diff --git a/img/digg.png b/img/digg.png deleted file mode 100755 index 097c4600..00000000 Binary files a/img/digg.png and /dev/null differ diff --git a/img/email-follow.png b/img/email-follow.png deleted file mode 100644 index 4505c610..00000000 Binary files a/img/email-follow.png and /dev/null differ diff --git a/img/favicon.png b/img/favicon.png deleted file mode 100644 index d4d38473..00000000 Binary files a/img/favicon.png and /dev/null differ diff --git a/img/feed-icon-28x28.png b/img/feed-icon-28x28.png deleted file mode 100755 index d64c669c..00000000 Binary files a/img/feed-icon-28x28.png and /dev/null differ diff --git a/img/following-article.png b/img/following-article.png deleted file mode 100644 index 0e59e459..00000000 Binary files a/img/following-article.png and /dev/null differ diff --git a/img/hacker-news.png b/img/hacker-news.png deleted file mode 100644 index ce92765d..00000000 Binary files a/img/hacker-news.png and /dev/null differ diff --git a/img/heart-32x32.png b/img/heart-32x32.png deleted file mode 100644 index 09b01cb5..00000000 Binary files a/img/heart-32x32.png and /dev/null differ diff --git a/img/heart.png b/img/heart.png deleted file mode 100644 index f36f3cfd..00000000 Binary files a/img/heart.png and /dev/null differ diff --git a/img/heart_open.png b/img/heart_open.png deleted file mode 100644 index e1c6e027..00000000 Binary files a/img/heart_open.png and /dev/null differ diff --git a/img/history.png b/img/history.png deleted file mode 100644 index 2a57cc17..00000000 Binary files a/img/history.png and /dev/null differ diff --git a/img/identica.png b/img/identica.png deleted file mode 100644 index 18b5bd2b..00000000 Binary files a/img/identica.png and /dev/null differ diff --git a/img/management.png b/img/management.png deleted file mode 100644 index 7bcbc384..00000000 Binary files a/img/management.png and /dev/null differ diff --git a/img/mark-as-read.png b/img/mark-as-read.png deleted file mode 100644 index ffc90910..00000000 Binary files a/img/mark-as-read.png and /dev/null differ diff --git a/img/pinboard.png b/img/pinboard.png deleted file mode 100644 index 6dddc10b..00000000 Binary files a/img/pinboard.png and /dev/null differ diff --git a/img/previous-article.png b/img/previous-article.png deleted file mode 100644 index fcd9bfd8..00000000 Binary files a/img/previous-article.png and /dev/null differ diff --git a/img/reddit.png b/img/reddit.png deleted file mode 100755 index 2d615f2a..00000000 Binary files a/img/reddit.png and /dev/null differ diff --git a/img/scoopeo.png b/img/scoopeo.png deleted file mode 100755 index 052c7dc8..00000000 Binary files a/img/scoopeo.png and /dev/null differ diff --git a/img/tuxrss.png b/img/tuxrss.png deleted file mode 100644 index d4d38473..00000000 Binary files a/img/tuxrss.png and /dev/null differ diff --git a/img/unread.png b/img/unread.png deleted file mode 100644 index d3a641c7..00000000 Binary files a/img/unread.png and /dev/null differ diff --git a/mongodb.py b/mongodb.py deleted file mode 100644 index d00b453e..00000000 --- a/mongodb.py +++ /dev/null @@ -1,253 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf-8 -*- - -__author__ = "Cedric Bonhomme" -__version__ = "$Revision: 0.1 $" -__date__ = "$Date: 2012/03/03 $" -__revision__ = "$Date: 2012/03/03 $" -__copyright__ = "Copyright (c) Cedric Bonhomme" -__license__ = "GPLv3" - -import time -import pymongo - -from operator import itemgetter, attrgetter - -class Articles(object): - """ - """ - def __init__(self, url='localhost', port=27017): - """ - Instantiates the connection. - """ - self.connection = pymongo.connection.Connection(url, port) - self.db = self.connection.pyaggr3g470r - - def add_collection(self, new_collection): - """ - Creates a new collection for a new feed. - """ - collection = self.db[new_collection["feed_id"]] - #collection.create_index([("feed_link", pymongo.ASCENDING)], {"unique":True, "sparse":True}) - collection.insert(new_collection) - - def add_articles(self, articles, feed_id): - """ - Add article(s) in a collection. - """ - collection = self.db[str(feed_id)] - - collection.create_index([("article_date", pymongo.DESCENDING)], \ - {"unique":False, "sparse":False}) - - for article in articles: - cursor = collection.find({"article_id":article["article_id"]}) - if cursor.count() == 0: - collection.insert(article) - - def delete_feed(self, feed_id): - """ - Delete a collection (feed with all articles). - """ - self.db.drop_collection(feed_id) - - def delete_article(self, feed_id, article_id): - """ - Delete an article. - """ - collection = self.db[str(feed_id)] - collection.find_and_modify(query={"article_id":article_id}, remove=True) - - def get_collection(self, feed_id): - """ - """ - return self.db[str(feed_id)].find().next() - - def get_all_articles(self): - """ - Return all articles from all collections. - """ - articles = [] - collections = self.db.collection_names() - for collection_name in collections: - collection = self.db[collection_name] - articles.extend([article for article in collection.find({'type':1})]) - return articles - - def get_article(self, feed_id, article_id): - """ - """ - collection = self.db[str(feed_id)] - return collection.find({"article_id":article_id}).next() - - def get_all_collections(self, condition=None): - """ - """ - feeds = [] - collections = self.db.collection_names() - for collection_name in collections: - if collection_name != "system.indexes": - if condition is None: - cursor = self.db[collection_name].find({"type":0}) - else: - cursor = self.db[collection_name].find({"type":0, condition[0]:condition[1]}) - if cursor.count() != 0: - feeds.append(cursor.next()) - feeds.sort(key = lambda elem: elem['feed_title'].lower()) - return feeds - - def get_articles_from_collection(self, feed_id, condition=None): - """ - Return all the articles of a collection. - """ - collection = self.db[str(feed_id)] - if condition is None: - cursor = collection.find({"type":1}) - else: - cursor = collection.find({"type":1, condition[0]:condition[1]}) - return cursor.sort([("article_date", pymongo.DESCENDING)]) - - def print_articles_from_collection(self, collection_id): - """ - Print the articles of a collection. - """ - collection = self.db[str(collection_id)] - cursor = collection.find({"type":1}) - print "Article for the collection", collection_id - for d in cursor: - print d - print - - def nb_articles(self, feed_id=None): - """ - Return the number of users. - """ - if feed_id is not None: - collection = self.db[feed_id] - cursor = collection.find({'type':1}) - return cursor.count() - else: - nb_articles = 0 - for feed_id in self.db.collection_names(): - nb_articles += self.nb_articles(feed_id) - return nb_articles - - def nb_favorites(self, feed_id=None): - if feed_id is not None: - collection = self.db[feed_id] - cursor = collection.find({'type':1, 'article_like':True}) - return cursor.count() - else: - nb_favorites = 0 - for feed_id in self.db.collection_names(): - nb_favorites += self.nb_favorites(feed_id) - return nb_favorites - - def nb_mail_notifications(self): - """ - Return the number of subscribed feeds. - """ - nb_mail_notifications = 0 - for feed_id in self.db.collection_names(): - collection = self.db[feed_id] - cursor = collection.find({'type':0, 'mail':True}) - nb_mail_notifications += cursor.count() - return nb_mail_notifications - - def nb_unread_articles(self, feed_id=None): - if feed_id is not None: - collection = self.db[feed_id] - cursor = collection.find({'article_readed':False}) - return cursor.count() - else: - unread_articles = 0 - for feed_id in self.db.collection_names(): - unread_articles += self.nb_unread_articles(feed_id) - return unread_articles - - def like_article(self, like, feed_id, article_id): - """ - Like or unlike an article. - """ - collection = self.db[str(feed_id)] - collection.update({"article_id": article_id}, {"$set": {"article_like": like}}) - - def mark_as_read(self, readed, feed_id=None, article_id=None): - """ - """ - if feed_id != None and article_id != None: - collection = self.db[str(feed_id)] - collection.update({"article_id": article_id, "article_readed":not readed}, {"$set": {"article_readed": readed}}) - elif feed_id != None and article_id == None: - collection = self.db[str(feed_id)] - collection.update({"type": 1, "article_readed":not readed}, {"$set": {"article_readed": readed}}, multi=True) - else: - for feed_id in self.db.collection_names(): - self.mark_as_read(readed, feed_id, None) - - def list_collections(self): - """ - List all collections (feed). - """ - collections = self.db.collection_names() - return collections - - # Functions on database - def drop_database(self): - """ - Drop all the database - """ - self.connection.drop_database('pyaggr3g470r') - - -if __name__ == "__main__": - # Point of entry in execution mode. - articles = Articles() - - - # Create a collection for a stream - collection_dic = {"collection_id": 42,\ - "feed_image": "Image", \ - "feed_title": "Title", \ - "feed_link": "Link", \ - "site_title": "Site link", \ - "mail": True, \ - } - - #articles.add_collection(collection_dic) - - - - # Add an article in the newly created collection - article_dic1 = {"article_id": 51, \ - "article_date": "Today", \ - "article_link": "Link of the article", \ - "article_title": "The title", \ - "article_content": "The content of the article", \ - "article_readed": True, \ - "article_like": True \ - } - - article_dic2 = {"article_id": 52, \ - "article_date": "Yesterday", \ - "article_link": "Link", \ - "article_title": "Hello", \ - "article_content": "The content of the article", \ - "article_readed": True, \ - "article_like": True \ - } - - #articles.add_articles([article_dic1, article_dic2], 42) - - - # Print articles of the collection - #articles.print_articles_from_collection("http://esr.ibiblio.org/?feed=rss2") - - - print "All articles:" - #print articles.get_all_articles() - - - - # Drop the database - articles.drop_database() \ No newline at end of file diff --git a/pyAggr3g470r b/pyAggr3g470r deleted file mode 100755 index 81f5cea0..00000000 --- a/pyAggr3g470r +++ /dev/null @@ -1,130 +0,0 @@ -#! /usr/bin/env python -#-*- coding: utf-8 -*- - -# pyAggr3g470r - A Web based news aggregator. -# Copyright (C) 2010 Cédric Bonhomme - http://cedricbonhomme.org/ -# -# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see - -__author__ = "Cedric Bonhomme" -__version__ = "$Revision: 0.1 $" -__date__ = "$Date: 2011/06/20 $" -__copyright__ = "Copyright (c) Cedric Bonhomme" -__license__ = "GPLv3" - -# This control file is inspired from Forban: http://www.foo.be/forban. - -import os -import sys -import time -import subprocess -import platform -import signal - -PATH = os.path.abspath(".") -SERVICE = "pyAggr3g470r" - -def service_start(servicename = None): - if servicename is not None: - service = servicename + ".py" - proc = subprocess.Popen(["python",service], stderr=subprocess.STDOUT, stdout=subprocess.PIPE) - time.sleep(0.15) - return proc.pid - return False - -def writepid (processname = None, pid = None): - pidpath = os.path.join(PATH,"var",processname+".pid") - if processname is not None and pid is not None: - f = open (pidpath,"w") - f.write(str(pid)) - f.close() - return True - else: - return False - -def checkpid (servicename = None): - pidpath = os.path.join(PATH,"var",servicename+".pid") - if os.path.exists(pidpath): - return True - else: - return False - -def pidof(processname = None): - pidpath = os.path.join(PATH,"var",processname+".pid") - if processname is not None and os.path.exists(pidpath): - f = open (pidpath) - pid = f.read() - f.close() - return pid - else: - return False - -def rmpid (processname = None): - pidpath = os.path.join(PATH, "var", processname + ".pid") - if os.path.exists(pidpath): - os.unlink(pidpath) - return True - else: - return False - -def start(): - if not checkpid(servicename = SERVICE): - pid = service_start(servicename = SERVICE) - writepid(processname = SERVICE, pid = pid) - print SERVICE + " is starting with pid: " + pidof(processname=SERVICE) - else: - print SERVICE + " could not be started (pid exists)" - retval=False - -def stop(): - print "Stopping pyAggr3g470r..." - retval=True - pid = pidof(processname=SERVICE) - if pid: - if platform.system() == "Windows": - import win32api - import win32con - phandle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, int(pid)) - win32api.TerminateProcess(phandle, 0) - win32api.CloseHandle(phandle) - rmpid(processname=SERVICE) - else: - try: - os.kill(int(pid), signal.SIGKILL) - except OSError, e: - print SERVICE + " unsuccessfully stopped" - retval = False - print SERVICE - rmpid(processname=SERVICE) - return retval - -def usage(): - print "pyAggr3g470r (start|stop|restart)" - exit (1) - -if __name__ == "__main__": - # Point of entry in execution mode. - if len(sys.argv) == 1: - usage() - elif sys.argv[1] == "start": - start() - elif sys.argv[1] == "stop": - stop() - elif sys.argv[1] == "restart": - stop() - start() - else: - usage() diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py deleted file mode 100755 index 1284ea3e..00000000 --- a/pyAggr3g470r.py +++ /dev/null @@ -1,1271 +0,0 @@ -#! /usr/bin/env python -#-*- coding: utf-8 -*- - -# pyAggr3g470r - A Web based news aggregator. -# Copyright (C) 2010-2012 Cédric Bonhomme - http://cedricbonhomme.org/ -# -# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see - -__author__ = "Cedric Bonhomme" -__version__ = "$Revision: 3.1 $" -__date__ = "$Date: 2010/01/29 $" -__revision__ = "$Date: 2012/03/09 $" -__copyright__ = "Copyright (c) Cedric Bonhomme" -__license__ = "GPLv3" - -# -# This file contains the "Root" class which describes -# all pages of pyAggr3g470r. These pages are: -# - main page; -# - management; -# - history; -# - favorites; -# - notifications; -# - unread; -# - feed summary. -# - -import os -import re -import time -import cherrypy -import calendar - -from collections import Counter -import datetime - -import utils -import export -import mongodb -import feedgetter -from qrcode.pyqrnative.PyQRNative import QRCode, QRErrorCorrectLevel, CodeOverflowException -from qrcode import qr - - -def error_page_404(status, message, traceback, version): - """ - Display an error if the page does not exist. - """ - html = htmlheader() - html += htmlnav - html += "

Error %s - This page does not exist." % status - html += "\n
\n" + htmlfooter - return html - -def handle_error(): - """ - Handle different type of errors. - """ - html = htmlheader() - html += htmlnav - html += "

Sorry, an error occured" - html += "\n
\n" + htmlfooter - cherrypy.response.status = 500 - cherrypy.response.body = [html] - -def htmlheader(nb_unread_articles=""): - """ - Return the header of the HTML page with the number of unread articles - in the 'title' HTML tag.. - """ - return '\n' + \ - '' + \ - '\n\t'+ nb_unread_articles +'pyAggr3g470r - News aggregator\n' + \ - '\t' + \ - '\n\t\n' + \ - '\n\t\n' + \ - '\n' - -htmlfooter = '

This software is under GPLv3 license. You are welcome to copy, modify or' + \ - ' redistribute the source code according to the' + \ - ' GPLv3 license.

\n' + \ - '\n' - -htmlnav = '\n

pyAggr3g470r - News aggregator

\n' + \ - 'pyAggr3g470r (source code)' - - -class Root: - """ - Root class. - All pages of pyAggr3g470r are described in this class. - """ - def __init__(self): - """ - """ - self.mongo = mongodb.Articles(utils.MONGODB_ADDRESS, utils.MONGODB_PORT) - - def index(self): - """ - Main page containing the list of feeds and articles. - """ - feeds = self.mongo.get_all_collections() - nb_unread_articles = self.mongo.nb_unread_articles() - nb_favorites = self.mongo.nb_favorites() - nb_mail_notifications = self.mongo.nb_mail_notifications() - - # if there are unread articles, display the number in the tab of the browser - html = htmlheader((nb_unread_articles and \ - ['(' + str(nb_unread_articles) +') '] or \ - [""])[0]) - html += htmlnav - html += self.create_right_menu() - html += """
\n""" - - if feeds: - html += '\n' - html += '\n' - html += '      \n' - - html += """\n""" % \ - (nb_favorites,) - - html += """\n""" % \ - (nb_mail_notifications,) - - html += '      ' - if nb_unread_articles != 0: - html += '\n' - html += """\n""" % \ - (nb_unread_articles,) - html += '\n' - - - # The main page display all the feeds. - for feed in feeds: - html += """

%s -

\n""" % \ - (feed["feed_id"], feed["feed_link"], feed["feed_title"], \ - feed["feed_link"], feed["feed_image"]) - - # The main page display only 10 articles by feeds. - for article in self.mongo.get_articles_from_collection(feed["feed_id"])[:10]: - if article["article_readed"] == False: - # not readed articles are in bold - not_read_begin, not_read_end = "", "" - else: - not_read_begin, not_read_end = "", "" - - # display a heart for faved articles - if article["article_like"] == True: - like = """ """ - else: - like = "" - - # Descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content.split(' ')[:55]) - else: - description = "No description." - # Title of the article - article_title = article["article_title"] - if len(article_title) >= 110: - article_title = article_title[:110] + " ..." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].ctime() + " - " + \ - """%s%s%s%s""" % \ - (feed["feed_id"], article["article_id"], not_read_begin, \ - article_title, not_read_end, description) + like + "
\n" - html += "
\n" - - # some options for the current feed - html += """All articles   """ % (feed["feed_id"],) - html += """Feed summary   """ % (feed["feed_id"],) - if self.mongo.nb_unread_articles(feed["feed_id"]) != 0: - html += """  Mark all as read""" % (feed["feed_id"],) - html += """     Unread article(s) (%s)""" % (feed["feed_id"], self.mongo.nb_unread_articles(feed["feed_id"])) - if feed["mail"] == "0": - html += """
\nStay tuned""" % (feed["feed_id"],) - else: - html += """
\nStop staying tuned""" % (feed["feed_id"],) - html += """

Top

""" - html += "
\n" - html += htmlfooter - return html - - index.exposed = True - - - def create_right_menu(self): - """ - Create the right menu. - """ - html = """
\n""" - html += """
\n""" - html += "
\n" - # insert the list of feeds in the menu - html += self.create_list_of_feeds() - html += "
\n" - - return html - - def create_list_of_feeds(self): - """ - Create the list of feeds. - """ - feeds = self.mongo.get_all_collections() - html = """" - - - def management(self, max_nb_articles=5): - """ - Management page. - Allows adding and deleting feeds. Export functions of the MongoDB data base - and display some statistics. - """ - feeds = self.mongo.get_all_collections() - nb_mail_notifications = self.mongo.nb_mail_notifications() - nb_favorites = self.mongo.nb_favorites() - nb_articles = self.mongo.nb_articles() - nb_unread_articles = self.mongo.nb_unread_articles() - - html = htmlheader() - html += htmlnav - html += """
\n""" - html += "

Add Feeds

\n" - # Form: add a feed - html += """
\n
\n""" - - if feeds: - # Form: delete a feed - html += "

Delete Feeds

\n" - html += """
\n""" - - html += """

Active e-mail notifications: %s

\n""" % \ - (nb_mail_notifications,) - html += """

You like %s article(s).

\n""" % \ - (nb_favorites, ) - - html += "
\n" - - # Informations about the data base of articles - html += """

%s article(s) are loaded from the database with - %s unread article(s).
\n""" % \ - (nb_articles, nb_unread_articles) - #html += """Database: %s.\n
Size: %s bytes.
\n""" % \ - #(os.path.abspath(utils.sqlite_base), os.path.getsize(utils.sqlite_base)) - html += 'Advanced statistics.

\n' - - html += """
\n
\n""" - html += """
\n
\n""" - - - html += '
\n' - html += "For each feed only load the " - html += """\n""" % (max_nb_articles) - html += " last articles." - if utils.MAX_NB_ARTICLES == -1: - html += "
All articles are currently loaded.\n" - else: - html += "
For each feed only " + str(utils.MAX_NB_ARTICLES) + " articles are currently loaded. " - html += 'Load all articles.
\n' - html += "
\n" - - # Export functions - html += "

Export articles

\n\n" - html += """
\n\t\n
\n""" - html += "
" - html += htmlfooter - return html - - management.exposed = True - - - def statistics(self, word_size=6): - """ - More advanced statistics. - """ - articles = self.mongo.get_all_articles() - html = htmlheader() - html += htmlnav - html += """
\n""" - - # Some statistics (most frequent word) - if articles: - top_words = utils.top_words(articles, n=50, size=int(word_size)) - html += "

Statistics

\n
\n" - # Tags cloud - html += 'Minimum size of a word:' - html += '
' - html += """""" % (word_size) - html += '
\n' - html += '

Tag cloud

\n' - html += '
' + \ - utils.tag_cloud(top_words) + '
' - html += "
\n" - - html += htmlfooter - return html - - statistics.exposed = True - - - def search(self, query=None): - """ - Simply search for the string 'query' - in the description of the article. - """ - param, _, value = query.partition(':') - wordre = re.compile(r'\b%s\b' % param, re.I) - feed_id = None - if param == "Feed": - feed_id, _, query = value.partition(':') - html = htmlheader() - html += htmlnav - html += """
""" - html += """

Articles containing the string %s


""" % (query,) - - if feed_id is not None: - for article in self.feeds[feed_id].articles.values(): - article_content = utils.clear_string(article.article_description) - if not article_content: - utils.clear_string(article.article_title) - if wordre.findall(article_content) != []: - if article.article_readed == "0": - # not readed articles are in bold - not_read_begin, not_read_end = "", "" - else: - not_read_begin, not_read_end = "", "" - - html += article.article_date + " - " + not_read_begin + \ - """%s""" % \ - (feed_id, article.article_id, article.article_title) + \ - not_read_end + """
\n""" - else: - feeds = self.mongo.get_all_collections() - for feed in feeds: - new_feed_section = True - for article in self.mongo.get_articles_from_collection(feed["feed_id"]): - article_content = utils.clear_string(article["article_content"]) - if not article_content: - utils.clear_string(article["article_title"]) - if wordre.findall(article_content) != []: - if new_feed_section is True: - new_feed_section = False - html += """

%s

\n""" % \ - (feed["feed_id"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) - - if article["article_readed"] == False: - # not readed articles are in bold - not_read_begin, not_read_end = "", "" - else: - not_read_begin, not_read_end = "", "" - - # display a heart for faved articles - if article["article_like"] == True: - like = """ """ - else: - like = "" - - # descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].ctime() + " - " + \ - """%s%s%s%s""" % \ - (feed["feed_id"], article["article_id"], not_read_begin, \ - article["article_title"][:150], not_read_end, description) + like + "
\n" - html += "
" - html += htmlfooter - return html - - search.exposed = True - - - def fetch(self): - """ - Fetch all feeds. - """ - feed_getter = feedgetter.FeedGetter() - feed_getter.retrieve_feed() - return self.index() - - fetch.exposed = True - - - def article(self, param): - """ - Display the article in parameter in a new Web page. - """ - try: - feed_id, article_id = param.split(':') - feed = self.mongo.get_collection(feed_id) - articles = self.mongo.get_articles_from_collection(feed_id) - article = self.mongo.get_article(feed_id, article_id) - except: - return self.error_page("Bad URL. This article do not exists.") - html = htmlheader() - html += htmlnav - html += """
""" - - if article["article_readed"] == False: - # if the current article is not yet readed, update the database - self.mark_as_read("Article:"+article["article_id"]+":"+feed["feed_id"]) - - html += '\n
\n' - # Title of the article - html += """

%s from %s

\n
\n""" % \ - (article["article_title"], feed_id, feed["feed_title"]) - if article["article_like"] == True: - html += """""" % \ - (feed_id, article["article_id"]) - else: - html += """""" % \ - (feed_id, article["article_id"]) - html += """  """ % \ - (feed_id, article["article_id"]) - html += "

" - - # Description (full content) of the article - description = article["article_content"] - if description: - p = re.compile(r'<') - q = re.compile(r'>') - - description = p.sub('<', description) - description = q.sub('>', description) - - html += description + "\n


" - else: - html += "No description available.\n


" - - # Generation of the QR Code for the current article - try: - os.makedirs("./var/qrcode/") - except OSError: - pass - if not os.path.isfile("./var/qrcode/" + article_id + ".png"): - # QR Code generation - try: - if len(utils.clear_string(description)) > 4296: - raise Exception() - f = qr.QRUrl(url = utils.clear_string(description)) - f.make() - except: - f = qr.QRUrl(url = article["article_link"]) - f.make() - f.save("./var/qrcode/"+article_id+".png") - - # Previous and following articles - articles_list = articles.distinct("article_id") - try: - following = articles[articles_list.index(article_id) - 1] - html += """
\n""" % \ - (feed_id, following["article_id"], following["article_title"]) - except Exception, e: - print e - try: - previous = articles[articles_list.index(article_id) + 1] - except: - previous = articles[0] - finally: - html += """
\n""" % \ - (feed_id, previous["article_id"], previous["article_title"]) - - html += "\n
\n" - - # Footer menu - html += "
\n" - html += """\nPlain text\n""" % (feed_id, article["article_id"]) - html += """ - Export to EPUB\n""" % (feed_id, article["article_id"]) - html += """
\nComplete story\n
\n""" % (article["article_link"],) - - # Share this article: - html += "Share this article:
\n" - # on Diaspora - html += """\n\t - \n""" % \ - (utils.DIASPORA_POD, article["article_link"], article["article_title"], "via pyAggr3g470r") - - # on Identi.ca - html += """\n\n""" % \ - (article["article_title"], article["article_link"]) - - # on Hacker News - html += """\n\n""" % \ - (article["article_link"], article["article_title"]) - - # on Pinboard - html += """\n\n\t\n - """ % \ - (article["article_link"], article["article_title"]) - - # on Digg - html += """\n\n\t\n - """ % \ - (article["article_link"], article["article_title"]) - # on reddit - html += """\n\n\t\n - """ % \ - (article["article_link"], article["article_title"]) - # on Scoopeo - html += """\n\n\t\n - """ % \ - (article["article_link"], article["article_title"]) - # on Blogmarks - html += """\n\n\t\n - """ % \ - (article["article_link"], article["article_title"]) - - # Google +1 button - html += """\n\n""" % \ - (article["article_link"],) - - - # QRCode (for smartphone) - html += """
\n""" % (article_id, article_id) - html += "
\n" + htmlfooter - return html - - article.exposed = True - - - def feed(self, feed_id, word_size=6): - """ - This page gives summary informations about a feed (number of articles, - unread articles, average activity, tag cloud, e-mail notification and - favourite articles for the current feed. - """ - try: - feed = self.mongo.get_collection(feed_id) - articles = self.mongo.get_articles_from_collection(feed_id) - except KeyError: - return self.error_page("This feed do not exists.") - html = htmlheader() - html += htmlnav - html += """
""" - html += "

The feed " + feed["feed_title"] + " contains " + str(self.mongo.nb_articles(feed_id)) + " articles. " - html += "Representing " + str((round(float(self.mongo.nb_articles(feed_id)) / 1000, 4)) * 100) + " % of the total " #hack - html += "(" + str(1000) + ").

" - if articles != []: - html += "

" + (self.mongo.nb_unread_articles(feed_id) == 0 and ["All articles are read"] or [str(self.mongo.nb_unread_articles(feed_id)) + \ - " unread article" + (self.mongo.nb_unread_articles(feed_id) == 1 and [""] or ["s"])[0]])[0] + ".

" - if feed["mail"] == True: - html += """

You are receiving articles from this feed to the address: %s. """ % \ - (utils.mail_to, utils.mail_to) - html += """Stop receiving articles from this feed.

""" % \ - (feed[feed_id], ) - - if articles != []: - last_article = utils.string_to_datetime(str(articles[0]["article_date"])) - first_article = utils.string_to_datetime(str(articles[self.mongo.nb_articles(feed_id)-2]["article_date"])) - delta = last_article - first_article - delta_today = datetime.datetime.fromordinal(datetime.date.today().toordinal()) - last_article - html += "

The last article was posted " + str(abs(delta_today.days)) + " day(s) ago.

" - if delta.days > 0: - html += """

Daily average: %s,""" % (str(round(float(self.mongo.nb_articles(feed_id))/abs(delta.days), 2)),) - html += """ between the %s and the %s.

\n""" % \ - (str(articles[self.mongo.nb_articles(feed_id)-2]["article_date"])[:10], str(articles[0]["article_date"])[:10]) - - html += "

Recent articles

" - for article in articles[:10]: - if article["article_readed"] == False: - # not readed articles are in bold - not_read_begin, not_read_end = "", "" - else: - not_read_begin, not_read_end = "", "" - - # display a heart for faved articles - if article["article_like"] == True: - like = """ """ - else: - like = "" - - # Descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - # Title of the article - article_title = article["article_title"] - if len(article_title) >= 110: - article_title = article_title[:110] + " ..." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].ctime() + " - " + \ - """%s%s%s%s""" % \ - (feed["feed_id"], article["article_id"], not_read_begin, \ - article_title, not_read_end, description) + like + "
\n" - html += "
\n" - html += """All articles   """ % (feed["feed_id"],) - - favs = [article for article in articles if article["article_like"] == True] - if len(favs) != 0: - html += "

Your favorites articles for this feed

" - for article in favs: - if article["like"] == True: - # descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].ctime() + " - " + \ - """%s%s
\n""" % \ - (feed["feed_id"], article["article_id"], article["article_title"][:150], description) - - - # This section enables the user to edit informations about - # the current feed: - # - feed logo; - # - feed name; - # - URL of the feed (not the site); - html += "
\n

Edit this feed

\n" - html += '\n\n
' + \ - '' + \ - """
\n""" % \ - (feed["feed_link"],) - html += '\n\n
' + \ - '' + \ - """
\n""" % \ - (feed["feed_link"],) - html += '\n\n
' + \ - '' + \ - """
\n""" % \ - (feed["feed_link"],) - - dic = {} - top_words = utils.top_words(articles = self.mongo.get_articles_from_collection(feed_id), n=50, size=int(word_size)) - html += "

Tag cloud

\n
\n" - # Tags cloud - html += 'Minimum size of a word:' - html += """
""" % (feed["feed_id"],) - html += """""" % (word_size,) - html += '
\n' - html += '
' + \ - utils.tag_cloud(top_words) + '
' - - html += "
" - html += "
" - html += htmlfooter - return html - - feed.exposed = True - - - def articles(self, feed_id): - """ - This page displays all articles of a feed. - """ - try: - feed = self.mongo.get_collection(feed_id) - articles = self.mongo.get_articles_from_collection(feed_id) - except KeyError: - return self.error_page("This feed do not exists.") - html = htmlheader() - html += htmlnav - html += """
\n""" - html += """Mark all articles from this feed as read""" % (feed_id,) - html += """
\n
\n""" % ("Feed:"+feed_id,) - html += "
\n" - html += self.create_list_of_feeds() - html += """
""" - html += """

Articles of the feed %s


""" % (feed["feed_title"],) - - for article in articles: - - if article["article_readed"] == False: - # not readed articles are in bold - not_read_begin, not_read_end = "", "" - else: - not_read_begin, not_read_end = "", "" - - if article["article_like"] == True: - like = """ """ - else: - like = "" - - # descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].ctime() + " - " + \ - """%s%s%s%s""" % \ - (feed_id, article["article_id"], not_read_begin, \ - article["article_title"][:150], not_read_end, description) + like + "
\n" - - html += """\n

All feeds

""" - html += "
\n" - html += htmlfooter - return html - - articles.exposed = True - - - def unread(self, feed_id=""): - """ - This page displays all unread articles of a feed. - """ - feeds = self.mongo.get_all_collections() - html = htmlheader() - html += htmlnav - html += """
""" - if self.mongo.nb_unread_articles() != 0: - - # List unread articles of all the database - if feed_id == "": - html += "

Unread article(s)

" - html += """\n
\nMark articles as read\n
\n""" - for feed in feeds: - new_feed_section = True - nb_unread = 0 - - # For all unread article of the current feed. - for article in self.mongo.get_articles_from_collection(feed["feed_id"], condition=("article_readed", False)): - nb_unread += 1 - if new_feed_section is True: - new_feed_section = False - html += """

%s

\n""" % \ - (feed["feed_id"], feed["site_link"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) - - # descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].ctime() + " - " + \ - """%s%s
\n""" % \ - (feed["feed_id"], article["article_id"], article["article_title"][:150], description) - - if nb_unread == self.mongo.nb_unread_articles(feed["feed_id"]): - html += """
\nMark all articles from this feed as read\n""" % \ - (feed["feed_id"],) - html += """
\nMark articles as read\n""" - - # List unread articles of a feed - else: - try: - feed = self.mongo.get_collection(feed_id) - except: - self.error_page("This feed do not exists.") - html += """

Unread article(s) of the feed %s

-
""" % (feed_id, feed["feed_title"]) - - # For all unread article of the feed. - for article in self.mongo.get_articles_from_collection(feed_id, condition=("article_readed", False)): - # descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].ctime() + " - " + \ - """%s%s
\n""" % \ - (feed_id, article["article_id"], article["article_title"][:150], description) - - html += """
\nMark all as read""" % (feed_id,) - # No unread article - else: - html += '

No unread article(s)

\n
\nWhy not check for news?' - html += """\n

All feeds

""" - html += "
\n" - html += htmlfooter - return html - - unread.exposed = True - - - def history(self, query="all", m=""): - """ - This page enables to browse articles chronologically. - """ - feeds = self.mongo.get_all_collections() - html = htmlheader() - html += htmlnav - html += """
\n""" - - # Get the date from the tag cloud - # Format: /history/?query=year:2011-month:06 to get the - # list of articles of June, 2011. - if m != "": - query = """year:%s-month:%s""" % tuple(m.split('-')) - - if query == "all": - html += "

Search with tags cloud

\n" - html += "

Choose a year


\n" - if "year" in query: - the_year = query.split('-')[0].split(':')[1] - if "month" not in query: - html += "

Choose a month for " + the_year + "


\n" - if "month" in query: - the_month = query.split('-')[1].split(':')[1] - html += "

Articles of "+ calendar.month_name[int(the_month)] + \ - ", "+ the_year +".


\n" - - timeline = Counter() - for feed in feeds: - new_feed_section = True - for article in self.mongo.get_articles_from_collection(feed["feed_id"]): - - if query == "all": - timeline[str(article["article_date"]).split(' ')[0].split('-')[0]] += 1 - - elif query[:4] == "year": - - if str(article["article_date"]).split(' ')[0].split('-')[0] == the_year: - timeline[str(article["article_date"]).split(' ')[0].split('-')[1]] += 1 - - if "month" in query: - if str(article["article_date"]).split(' ')[0].split('-')[1] == the_month: - if article["article_readed"] == False: - # not readed articles are in bold - not_read_begin, not_read_end = "", "" - else: - not_read_begin, not_read_end = "", "" - - if article["article_like"] == True: - like = """ """ - else: - like = "" - # Descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - # Title of the article - article_title = article["article_title"] - if len(article_title) >= 110: - article_title = article_title[:110] + " ..." - - if new_feed_section is True: - new_feed_section = False - html += """

%s

\n""" % \ - (feed["feed_id"], feed["feed_link"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) - - html += article["article_date"].strftime("%a %d (%H:%M:%S) ") + \ - """%s%s%s%s""" % \ - (feed["feed_id"], article["article_id"], not_read_begin, \ - article_title, not_read_end, description) + like + "
\n" - if query == "all": - query_string = "year" - elif "year" in query: - query_string = "year:" + the_year + "-month" - if "month" not in query: - html += '
' + \ - utils.tag_cloud([(elem, timeline[elem]) for elem in timeline.keys()], query_string) + '
' - html += '

Search with a month+year picker

\n' - html += '
\n\t\n\t\n
' - html += '
' - html += htmlfooter - return html - - history.exposed = True - - - def plain_text(self, target): - """ - Display an article in plain text (without HTML tags). - """ - try: - feed_id, article_id = target.split(':') - feed = self.mongo.get_collection(feed_id) - article = self.mongo.get_article(feed_id, article_id) - except: - return self.error_page("Bad URL. This article do not exists.") - html = htmlheader() - html += htmlnav - html += """
""" - html += """

%s from %s

\n
\n"""% \ - (article["article_title"], feed_id, feed["feed_title"]) - description = utils.clear_string(article["article_content"]) - if description: - html += description - else: - html += "No description available." - html += "\n
\n" + htmlfooter - return html - - plain_text.exposed = True - - - def error_page(self, message): - """ - Display a message (bad feed id, bad article id, etc.) - """ - html = htmlheader() - html += htmlnav - html += """
""" - html += """%s""" % message - html += "\n
\n" + htmlfooter - return html - - error_page.exposed = True - - - def mark_as_read(self, target=""): - """ - Mark one (or more) article(s) as read by setting the value of the field - 'article_readed' of the MongoDB database to 'True'. - """ - param, _, identifiant = target.partition(':') - - # Mark all articles as read. - if param == "": - self.mongo.mark_as_read(True, None, None) - # Mark all articles from a feed as read. - elif param == "Feed" or param == "Feed_FromMainPage": - self.mongo.mark_as_read(True, identifiant, None) - # Mark an article as read. - elif param == "Article": - self.mongo.mark_as_read(True, identifiant.split(':')[1], identifiant.split(':')[0]) - if param == "" or param == "Feed_FromMainPage": - return self.index() - elif param == "Feed": - return self.articles(identifiant) - - mark_as_read.exposed = True - - - def notifications(self): - """ - List all active e-mail notifications. - """ - html = htmlheader() - html += htmlnav - html += """
""" - feeds = self.mongo.get_all_collections(condition=("mail",True)) - if feeds != []: - html += "

You are receiving e-mails for the following feeds:

\n" - for feed in feeds: - html += """\t%s - Stop
\n""" % \ - (feed["feed_id"], feed["feed_title"], feed["feed_id"]) - else: - html += "

No active notifications.

\n" - html += """

Notifications are sent to: %s

""" % \ - (utils.mail_to, utils.mail_to) - html += "\n
\n" + htmlfooter - return html - - notifications.exposed = True - - - def mail_notification(self, param): - """ - Enable or disable to notifications of news for a feed. - """ - try: - action, feed_id = param.split(':') - feed = self.feeds[feed_id] - except: - return self.error_page("Bad URL. This feed do not exists.") - - return self.index() - - mail_notification.exposed = True - - - def like(self, param): - """ - Mark or unmark an article as favorites. - """ - try: - like, feed_id, article_id = param.split(':') - articles = self.mongo.get_article(feed_id, article_id) - except: - return self.error_page("Bad URL. This article do not exists.") - self.mongo.like_article("1"==like, feed_id, article_id) - return self.article(feed_id+":"+article_id) - - like.exposed = True - - - def favorites(self): - """ - List of favorites articles - """ - feeds = self.mongo.get_all_collections() - html = htmlheader() - html += htmlnav - html += """
""" - html += "

Your favorites articles

" - for feed in feeds: - new_feed_section = True - for article in self.mongo.get_articles_from_collection(feed["feed_id"]): - if article["article_like"] == True: - if new_feed_section is True: - new_feed_section = False - html += """

%s

\n""" % \ - (feed["feed_id"], feed["feed_link"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) - - # descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." - - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].ctime() + " - " + \ - """%s%s
\n""" % \ - (feed["feed_id"], article["article_id"], article["article_title"][:150], description) - html += "
\n" - html += htmlfooter - return html - - favorites.exposed = True - - - def add_feed(self, url): - """ - Add a new feed with the URL of a page. - """ - html = htmlheader() - html += htmlnav - html += """
""" - # search the feed in the HTML page with BeautifulSoup - feed_url = utils.search_feed(url) - if feed_url is None: - return self.error_page("Impossible to find a feed at this URL.") - # if a feed exists - else: - result = utils.add_feed(feed_url) - # if the feed is not in the file feed.lst - if result is False: - html += "

You are already following this feed!

" - else: - html += """

Feed added. You can now fetch your feeds.

""" - html += """\n
\nBack to the management page.
\n""" - html += "
\n" - html += htmlfooter - return html - - add_feed.exposed = True - - - def remove_feed(self, feed_id): - """ - Remove a feed from the file feed.lst and from the MongoDB database. - """ - html = htmlheader() - html += htmlnav - html += """
""" - - feed = self.mongo.get_collection(feed_id) - self.mongo.delete_feed(feed_id) - utils.remove_feed(feed["feed_link"]) - - html += """

All articles from the feed %s are now removed from the base.


""" % \ - (feed["feed_title"],) - html += """Back to the management page.
\n""" - html += "
\n" - html += htmlfooter - return html - - remove_feed.exposed = True - - - 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 += """
""" - utils.change_feed_url(old_feed_url, new_feed_url) - html += "

The URL of the feed has been changed.

" - html += "
\n" - html += htmlfooter - 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 += """
""" - utils.change_feed_name(feed_url, new_feed_name) - html += "

The name of the feed has been changed.

" - html += "
\n" - html += htmlfooter - return html - - change_feed_name.exposed = True - - def change_feed_logo(self, feed_url, new_feed_logo): - """ - Enables to change the name of a feed. - """ - html = htmlheader() - html += htmlnav - html += """
""" - utils.change_feed_logo(feed_url, new_feed_logo) - html += "

The logo of the feed has been changed.

" - html += "
\n" - html += htmlfooter - return html - - change_feed_logo.exposed = True - - - def set_max_articles(self, max_nb_articles=1): - """ - Enables to set the maximum of articles to be loaded per feed from - the data base. - """ - if max_nb_articles < -1 or max_nb_articles == 0: - max_nb_articles = 1 - utils.MAX_NB_ARTICLES = int(max_nb_articles) - return self.management() - - set_max_articles.exposed = True - - - def delete_article(self, param): - """ - Delete an article. - """ - try: - feed_id, article_id = param.split(':') - self.mongo.delete_article(feed_id, article_id) - except: - return self.error_page("Bad URL. This article do not exists.") - - return self.index() - - delete_article.exposed = True - - - def drop_base(self): - """ - Delete all articles. - """ - utils.drop_base() - return self.management() - - drop_base.exposed = True - - - def export(self, export_method): - """ - Export articles currently loaded from the MongoDB database with - the appropriate function of the 'export' module. - """ - try: - getattr(export, export_method)(self.feeds) - except Exception, e: - return self.error_page(e) - return self.management() - - export.exposed = True - - - def epub(self, param): - """ - Export an article to EPUB. - """ - try: - from epub import ez_epub - except Exception, e: - return self.error_page(e) - try: - feed_id, article_id = param.split(':') - except: - return self.error_page("Bad URL.") - try: - feed = self.feeds[feed_id] - article = feed.articles[article_id] - except: - self.error_page("This article do not exists.") - try: - folder = utils.path + "/var/export/epub/" - os.makedirs(folder) - except OSError: - # directories already exists (not a problem) - pass - section = ez_epub.Section() - section.title = article.article_title.decode('utf-8') - section.paragraphs = [utils.clear_string(article.article_description).decode('utf-8')] - ez_epub.makeBook(article.article_title.decode('utf-8'), [feed.feed_title.decode('utf-8')], [section], \ - os.path.normpath(folder) + "article.epub", lang='en-US', cover=None) - return self.article(param) - - epub.exposed = True - - -if __name__ == '__main__': - # Point of entry in execution mode - print "Launching pyAggr3g470r..." - - root = Root() - root.favicon_ico = cherrypy.tools.staticfile.handler(filename=os.path.join(utils.path + "/img/favicon.png")) - cherrypy.config.update({ 'server.socket_port': 12556, 'server.socket_host': "0.0.0.0"}) - cherrypy.config.update({'error_page.404': error_page_404}) - _cp_config = {'request.error_response': handle_error} - - cherrypy.quickstart(root, "/" ,config=utils.path + "/cfg/cherrypy.cfg") \ No newline at end of file diff --git a/source/.hgsub b/source/.hgsub new file mode 100644 index 00000000..bc339e87 --- /dev/null +++ b/source/.hgsub @@ -0,0 +1 @@ +qrcode = http://hg.cedricbonhomme.org/qrcode/ diff --git a/source/COPYING b/source/COPYING new file mode 100755 index 00000000..20d40b6b --- /dev/null +++ b/source/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/source/README b/source/README new file mode 100644 index 00000000..a2737f76 --- /dev/null +++ b/source/README @@ -0,0 +1,84 @@ +.. -*-restructuredtext-*- + +============ +pyAggr3g470r +============ + +.. Use headers in this order #=~-_ + +:toc: yes +:symrefs: yes +:sortrefs: yes +:compact: yes +:subcompact: no +:rfcedstyle: no +:comments: no +:inline: yes +:private: yes + +:author: Cédric Bonhomme +:contact: http://cedricbonhomme.org/ + + +Presentation +------------ +pyAggr3g470r_ is a multi-threaded news aggregator with a web interface +based on CherryPy_. Articles are stored in a MongoDB_ base. + + + +Features +------------ +* articles are stored in a MongoDB_ database; +* find an article with history; +* e-mail notification; +* export articles to HTML, EPUB, PDF or raw text; +* mark or unmark articles as favorites; +* share articles with Diaspora, Google Buzz, Pinboard, delicious, Identi.ca, Digg, reddit, Scoopeo, Blogmarks and Twitter; +* generation of QR code with the content or URL of an article. So you can read an article later on your smartphone (or share with friends). + + + +Requierements +------------- +Software required +~~~~~~~~~~~~~~~~~ +* Python_ 2.7.*; +* MongoDB_ and PyMongo_; +* feedparser_; +* CherryPy_ (version 3 and up); +* BeautifulSoup_. + + +Optional module +~~~~~~~~~~~~~~~ +These modules are not required but enables more features: +* lxml and Genshi; +* Python Imaging Library for the generation of QR codes. + + +If you want to install these modules: + + sudo aptitude install python-lxml python-genshi + + +Donnation +--------- +If you wish and if you like pyAggr3g470r, you can donate via bitcoin. My bitcoin address: 1GVmhR9fbBeEh7rP1qNq76jWArDdDQ3otZ +Thank you! + + + +License +------------ +pyAggr3g470r_ is under GPLv3_ license. + + +.. _Python: http://python.org/ +.. _pyAggr3g470r: https://bitbucket.org/cedricbonhomme/pyaggr3g470r/ +.. _feedparser: http://feedparser.org/ +.. _MongoDB: http://www.mongodb.org/ +.. _PyMongo: https://github.com/mongodb/mongo-python-driver +.. _CherryPy: http://cherrypy.org/ +.. _BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/ +.. _GPLv3: http://www.gnu.org/licenses/gpl-3.0.txt diff --git a/source/cfg/cherrypy.cfg b/source/cfg/cherrypy.cfg new file mode 100644 index 00000000..a419504d --- /dev/null +++ b/source/cfg/cherrypy.cfg @@ -0,0 +1,24 @@ +[global] +log.error_file = "var/error.log" +log.access_file = "var/access.log" +server.environment = "production" +engine.autoreload_on = True +engine.autoreload_frequency = 5 +engine.timeout_monitor.on = False + +[/] +tools.staticdir.root = os.getcwd() +tools.staticdir.on = True +tools.staticdir.dir = "." +tools.encode.on = True +tools.encode.encoding = "utf8" + +[/css] +tools.staticdir.on = True +tools.staticdir.dir = "css" +tools.staticdir.match = "(?i)^.+\.css$" + +[/images] +tools.staticdir.on = True +tools.staticdir.dir = "img" +tools.staticdir.match = "(?i)^.+\.png$" \ No newline at end of file diff --git a/source/cfg/pyAggr3g470r.cfg-sample b/source/cfg/pyAggr3g470r.cfg-sample new file mode 100755 index 00000000..95db75c5 --- /dev/null +++ b/source/cfg/pyAggr3g470r.cfg-sample @@ -0,0 +1,15 @@ +[global] +max_nb_articles = 50 +[MongoDB] +address = 127.0.0.1 +port = 27017 +user = username +password = pwd +[mail] +mail_from = pyAggr3g470r@no-reply.com +mail_to = address_of_the_recipient@example.com +smtp = smtp.example.com +username = your_mail_address@example.com +password = your_password +[misc] +diaspora_pod = joindiaspora.com diff --git a/source/css/style.css b/source/css/style.css new file mode 100755 index 00000000..5f9574e7 --- /dev/null +++ b/source/css/style.css @@ -0,0 +1,374 @@ +html, body { + margin: 0; + padding: 0; + width: 100%; + height: 100%; + overflow-x: hidden; + background-color: white; + color: black; +} + +body { + text-align: justify; + font: 400 0.85em Cambria, Georgia, "Trebuchet MS", Verdana, sans-serif; +} + +code, pre { + font: 400 0.85em Cambria, Georgia, "Trebuchet MS", Verdana, sans-serif, Fixed; + white-space:pre-wrap; +} + +img { + border: 0px; +} + +h1 { + font-size: 100%; + margin: 0em 0em; + padding: 0px; +} + +h2 { + margin: 0.5em 0em; + padding: 0px; + font-style: normal; + font-variant: normal; + font-weight: bold; + font-size: 100%; + letter-spacing: 0em; + text-align: right; +} + +h3 { + margin: 0em 0em 0.5em 0em; + font-size: 100%; + font-weight: bold; + text-align: left; +} + +h1 a, h2 a, h3 a { + text-decoration: none; +} + +h2 + h3 { + margin-top: 0.5em; +} + +table { + margin-left: 2em; + margin-bottom: 1em; + border-collapse: collapse; + text-align: left; +} + +th, td { + padding-right: 1em; + text-align: left; +} + +th { + vertical-align: bottom; + border-bottom: 1px solid black; + text-align: left; +} + +td { + vertical-align: top; + padding-top: 5px; + text-align: left; +} + +table.border td, table.border th { + border: 1px solid black; +} + +p { + margin: 0.5em 0em; +} + +ol.lower { + list-style-type: lower-alpha; +} + +ol.upper { + list-style-type: upper-alpha; +} + +ol.roman { + list-style-type: lower-roman; +} + +ul { + margin: 0em 0em 0.5em 0.5em; + padding: 0em; +} + +li { + margin: 0em 0em 0em 0.5em; + padding: 0em; +} + +a:link, a:visited { + color: #003399; + text-decoration:none +} + +a:hover { + color: blue; +} + +dt { + margin: 0.5em 0em 0em 0em; + padding: 0em; + font-weight: bold; +} + +dd { + margin: 0em; +} + +hr { + color: white; + border-top: dotted black; + border-width: 1px 0px 0px 0px; + margin: 1em 0em; +} + + +#heading { + position: absolute; + left: 0px; + top: 0px; + width: 100%; + z-index: 1; +} + +/* Navigation bars */ +.nav_container { position:fixed; top:160px; right:60px; margin:0px; padding:0px; white-space:nowrap; z-index:11; clear:both;} +.nav_container.horizontal { position:absolute; white-space:normal; z-index:25; width:670px; } +.nav_container.horizontal div { float:right; padding-right:10px; } + +#nav { + position: absolute; + top: 0px; + right: 0px; + z-index: 2; +} + +#heading, #nav, #nav ul { + margin: 0; + height: 1.8em; +} + +#heading, #nav ul, #nav li { + background: #EEEEEE; + color: inherit; + border-bottom: 0px solid black; +} + +#heading h1 { + margin: 0; + padding: 0.4em 0 0.4em 2em; + white-space: nowrap; +} + +#nav ul { + display: block; + margin: 0 3em 0 0; + border-right: 0px solid #000000; +} + +#nav li { + margin: 0em; + padding: 0.4em 1em 0.2em 1em; + display: block; + float: left; + border-left: 0px solid #000000; +} + +pre { + margin-left: 2em; +} + +.right { + clear: right; + float: right; + text-align: right; + margin: 0em 2em 0em 2em; + max-width: 36%; +} + +img.right { + width: auto; +} + +.inner .right { + margin-right: 0em; +} + +.right blockquote { + float: right; + position: relative; + clear: both; + padding-top: 1em; + padding-bottom: 0em; + margin-bottom: 0em; + font-style: italic; + width: 100%; + margin-right: 0em; +} + +blockquote.right { + width: 50%; + margin-left: 50%; + margin-right: 0em; +} + +/* Footer (W3C logos) */ + +#w3c { + text-align: right; + padding: 0em 2em 0em 2em; + clear: both; +} + +#w3c img { + padding-left: 10px; + padding-top: 1em; +} + +/* Classes */ + +.clear { + font-size: 1px; + line-height: 1px; + height: 0px; + clear: both; +} + +.invisible { + display: none; +} + +.inner { + margin-top: 3em; + padding: 0em 2em 0em 2em; + clear: both; +} + +.innerlogo { + margin-top: 0em; + padding: 0em 2em 0em 2em; + clear: both; +} + +.left { + float: left; + position: absolute; + +} + +.tex { + position: relative; top: 0.2em; + margin-left: -0.2em; + margin-right: -0.1em; +} + +/* Photo album */ + +#album { + margin: 0 auto; + padding: 3em 2em 0em 2em; +} + +#thumbs { + background: white; + position: absolute; + left: 2em; + right: 2em; + margin-top: -100px; + padding-bottom: 0.5em; + overflow: auto; +} + +#thumbs table { + margin: 0 auto; + position: relative; + max-width: 100%; + border-collapse: collapse; + border: 0px; +} + +#pageselectors { + margin-top: 1em; + text-align: center; + padding-bottom: 100px; + margin-bottom: 0.5em; +} + +#thumbs img, #photo img { + display: block; + margin: 0 auto; +} + +#thumbs td { + width: 8em; + min-width: 100px; + text-align: center; + padding: 0.5em 0.5em 0em 0em; + border: 0px; + margin: 0px; +} + +#photo { + text-align: center; +} + +#thumbs img { + opacity: 0.99; + -moz-opacity: 0.99; +} + +#thumbs img:hover { + opacity: 0.7; + -moz-opacity: 0.7; +} + +#photo img { + max-width: 100%; + min-height: 300px; + max-height: 300px; + overflow: scroll; + margin-top: 0.5em; +} + +/* CSS ToolTips */ + .tooltip { + color: #FFF; + outline: none; + text-decoration: none; + position: relative; + } + + .tooltip span { + color: #FFF; + margin-left: -999em; + position: absolute; + } + + .tooltip:hover span { + border-radius: 5px 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); + font-family: Calibri, Tahoma, Geneva, sans-serif; + position: absolute; left: 1em; top: 2em; z-index: 99; + margin-left: 0; width: 250px; + } + .classic { + padding: 0.8em 1em; + background: rgba(0, 0, 0, 0.85); + border: 5px 5px; + } + + * html a:hover { + background: transparent; + } \ No newline at end of file diff --git a/source/epub/__init__.py b/source/epub/__init__.py new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/source/epub/__init__.py @@ -0,0 +1 @@ + diff --git a/source/epub/epub.py b/source/epub/epub.py new file mode 100644 index 00000000..2c01b54a --- /dev/null +++ b/source/epub/epub.py @@ -0,0 +1,343 @@ +#! /usr/local/bin/python +#-*- coding: utf-8 -*- + +import itertools +import mimetypes +import os +import shutil +import subprocess +import uuid +import zipfile +from genshi.template import TemplateLoader +from lxml import etree + +class TocMapNode: + def __init__(self): + self.playOrder = 0 + self.title = '' + self.href = '' + self.children = [] + self.depth = 0 + + def assignPlayOrder(self): + nextPlayOrder = [0] + self.__assignPlayOrder(nextPlayOrder) + + def __assignPlayOrder(self, nextPlayOrder): + self.playOrder = nextPlayOrder[0] + nextPlayOrder[0] = self.playOrder + 1 + for child in self.children: + child.__assignPlayOrder(nextPlayOrder) + +class EpubItem: + def __init__(self): + self.id = '' + self.srcPath = '' + self.destPath = '' + self.mimeType = '' + self.html = '' + +class EpubBook: + def __init__(self): + self.loader = TemplateLoader('./epub/templates') + + self.rootDir = '' + self.UUID = uuid.uuid1() + + self.lang = 'en-US' + self.title = '' + self.creators = [] + self.metaInfo = [] + + self.imageItems = {} + self.htmlItems = {} + self.cssItems = {} + + self.coverImage = None + self.titlePage = None + self.tocPage = None + + self.spine = [] + self.guide = {} + self.tocMapRoot = TocMapNode() + self.lastNodeAtDepth = {0 : self.tocMapRoot} + + def setTitle(self, title): + self.title = title + + def setLang(self, lang): + self.lang = lang + + def addCreator(self, name, role = 'aut'): + self.creators.append((name, role)) + + def addMeta(self, metaName, metaValue, **metaAttrs): + self.metaInfo.append((metaName, metaValue, metaAttrs)) + + def getMetaTags(self): + l = [] + for metaName, metaValue, metaAttr in self.metaInfo: + beginTag = ' + +%s +

%s

+ +""" % (text, text) + + book = EpubBook() + book.setTitle('Most Wanted Tips for Aspiring Young Pirates') + book.addCreator('Monkey D Luffy') + book.addCreator('Guybrush Threepwood') + book.addMeta('contributor', 'Smalltalk80', role = 'bkp') + book.addMeta('date', '2010', event = 'publication') + + book.addTitlePage() + book.addTocPage() + book.addCover(r'D:\epub\blank.png') + + book.addCss(r'main.css', 'main.css') + + n1 = book.addHtml('', '1.html', getMinimalHtml('Chapter 1')) + n11 = book.addHtml('', '2.html', getMinimalHtml('Section 1.1')) + n111 = book.addHtml('', '3.html', getMinimalHtml('Subsection 1.1.1')) + n12 = book.addHtml('', '4.html', getMinimalHtml('Section 1.2')) + n2 = book.addHtml('', '5.html', getMinimalHtml('Chapter 2')) + + book.addSpineItem(n1) + book.addSpineItem(n11) + book.addSpineItem(n111) + book.addSpineItem(n12) + book.addSpineItem(n2) + + # You can use both forms to add TOC map + #t1 = book.addTocMapNode(n1.destPath, '1') + #t11 = book.addTocMapNode(n11.destPath, '1.1', parent = t1) + #t111 = book.addTocMapNode(n111.destPath, '1.1.1', parent = t11) + #t12 = book.addTocMapNode(n12.destPath, '1.2', parent = t1) + #t2 = book.addTocMapNode(n2.destPath, '2') + + book.addTocMapNode(n1.destPath, '1') + book.addTocMapNode(n11.destPath, '1.1', 2) + book.addTocMapNode(n111.destPath, '1.1.1', 3) + book.addTocMapNode(n12.destPath, '1.2', 2) + book.addTocMapNode(n2.destPath, '2') + + rootDir = r'd:\epub\test' + book.createBook(rootDir) + EpubBook.createArchive(rootDir, rootDir + '.epub') + +if __name__ == '__main__': + test() \ No newline at end of file diff --git a/source/epub/ez_epub.py b/source/epub/ez_epub.py new file mode 100644 index 00000000..ecfd4f5a --- /dev/null +++ b/source/epub/ez_epub.py @@ -0,0 +1,36 @@ +#! /usr/local/bin/python +#-*- coding: utf-8 -*- + +import epub +from genshi.template import TemplateLoader + +class Section: + def __init__(self): + self.title = '' + self.paragraphs = [] + self.tocDepth = 1 + +def makeBook(title, authors, sections, outputDir, lang='en-US', cover=None): + book = epub.EpubBook() + book.setLang(lang) + book.setTitle(title) + for author in authors: + book.addCreator(author) + #book.addTitlePage() + #book.addTocPage() + #if cover: + #book.addCover(cover) + + loader = TemplateLoader('./epub/templates') + tmpl = loader.load('ez-section.html') + + for i, section in enumerate(sections): + stream = tmpl.generate(section = section) + html = stream.render('xhtml', doctype='xhtml11', drop_xml_decl=False) + item = book.addHtml('', 's%d.html' % (i + 1), html) + book.addSpineItem(item) + book.addTocMapNode(item.destPath, section.title, section.tocDepth) + + outputFile = outputDir + 'article.epub' + book.createBook(outputDir) + book.createArchive(outputDir, outputFile) \ No newline at end of file diff --git a/source/epub/templates/container.xml b/source/epub/templates/container.xml new file mode 100644 index 00000000..eecf7a0d --- /dev/null +++ b/source/epub/templates/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/source/epub/templates/content.opf b/source/epub/templates/content.opf new file mode 100644 index 00000000..67f3f5c6 --- /dev/null +++ b/source/epub/templates/content.opf @@ -0,0 +1,34 @@ + + + + urn:uuid:${book.UUID} + ${book.lang} + ${book.title} + + $name + + + ${Markup(beginTag)}$content${Markup(endTag)} + + + + + + + + + + + + + + + + + + + + diff --git a/source/epub/templates/ez-section.html b/source/epub/templates/ez-section.html new file mode 100644 index 00000000..0a715e7f --- /dev/null +++ b/source/epub/templates/ez-section.html @@ -0,0 +1,17 @@ + + + ${section.title} + + + +

${section.title}

+ +

$p

+
+ + diff --git a/source/epub/templates/image.html b/source/epub/templates/image.html new file mode 100644 index 00000000..9a838c7e --- /dev/null +++ b/source/epub/templates/image.html @@ -0,0 +1,16 @@ + + + ${item.destPath} + + + +
${item.destPath}
+ + diff --git a/source/epub/templates/title-page.html b/source/epub/templates/title-page.html new file mode 100644 index 00000000..de0f55f0 --- /dev/null +++ b/source/epub/templates/title-page.html @@ -0,0 +1,22 @@ + + + ${book.title} + + + +

${book.title}

+

+ + $creator + +

+ + diff --git a/source/epub/templates/toc.html b/source/epub/templates/toc.html new file mode 100644 index 00000000..b14c9da3 --- /dev/null +++ b/source/epub/templates/toc.html @@ -0,0 +1,32 @@ + + + ${book.title} + + + + + + + ${tocEntry(child)} + + + + ${tocEntry(child)} + + + diff --git a/source/epub/templates/toc.ncx b/source/epub/templates/toc.ncx new file mode 100644 index 00000000..e7dd391a --- /dev/null +++ b/source/epub/templates/toc.ncx @@ -0,0 +1,28 @@ + + + + + + + + + + ${book.title} + + + + + ${node.title} + + + ${navPoint(child)} + + + + + ${navPoint(child)} + + + diff --git a/source/export.py b/source/export.py new file mode 100644 index 00000000..a14d47c0 --- /dev/null +++ b/source/export.py @@ -0,0 +1,190 @@ +#! /usr/bin/env python +#-*- coding: utf-8 -*- + +# pyAggr3g470r - A Web based news aggregator. +# Copyright (C) 2010 Cédric Bonhomme - http://cedricbonhomme.org/ +# +# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +__author__ = "Cedric Bonhomme" +__version__ = "$Revision: 0.1 $" +__date__ = "$Date: 2011/10/24 $" +__copyright__ = "Copyright (c) Cedric Bonhomme" +__license__ = "GPLv3" + +# +# This file contains the export functions of pyAggr3g470r. Indeed +# it is possible to export the database of articles in different formats: +# - simple HTML webzine; +# - text file; +# - ePub file; +# - PDF file. +# + +import os +import hashlib + +import utils + + +htmlheader = '\n' + \ + '' + \ + '\n\tpyAggr3g470r - News aggregator\n' + \ + '\t' + \ + '\n\t\n' + \ + '\n' + +htmlfooter = '

This software is under GPLv3 license. You are welcome to copy, modify or' + \ + ' redistribute the source code according to the' + \ + ' GPLv3 license.

\n' + \ + '\n' + + + +def export_html(feeds): + """ + Export the articles given in parameter in a simple Webzine. + """ + index = htmlheader + index += "
\n
    " + for feed in feeds.values(): + # creates a folder for each stream + feed_folder = utils.path + "/var/export/webzine/" + \ + utils.normalize_filename(feed.feed_id) + try: + os.makedirs(feed_folder) + except OSError: + # directories already exists (not a problem) + pass + + + index += """
  • %s
  • \n""" % \ + (feed.feed_id, feed.feed_title) + + posts = htmlheader + for article in feed.articles.values(): + + post_file_name = os.path.normpath(feed_folder + "/" + article.article_id + ".html") + feed_index = os.path.normpath(feed_folder + "/index.html") + + posts += article.article_date + " - " + \ + """%s""" % \ + (article.article_id, article.article_title[:150]) + "
    \n" + + + a_post = htmlheader + a_post += '\n
    \n' + a_post += """

    %s


    """ % \ + (article.article_link, article.article_title) + a_post += article.article_description + a_post += "
    \n
    \n" + a_post += """
    \nComplete story\n
    \n""" % (article.article_link,) + a_post += "
    \n" + htmlfooter + + + with open(post_file_name, "w") as f: + f.write(a_post) + + posts += htmlfooter + with open(feed_index, "w") as f: + f.write(posts) + + index += "\n
\n
" + index += htmlfooter + with open(utils.path + "/var/export/webzine/" + "index.html", "w") as f: + f.write(index) + +def export_txt(feeds): + """ + Export the articles given in parameter in text files. + """ + for feed in feeds.values(): + # creates folder for each stream + folder = utils.path + "/var/export/txt/" + \ + utils.normalize_filename(feed.feed_title.strip().replace(':', '').lower()) + try: + os.makedirs(folder) + except OSError: + # directories already exists (not a problem) + pass + + for article in feed.articles.values(): + name = article.article_date.strip().replace(' ', '_') + name = os.path.normpath(folder + "/" + name + ".txt") + + content = "Title: " + article.article_title + "\n\n\n" + content += utils.clear_string(article.article_description) + + with open(name, "w") as f: + f.write(content) + +def export_epub(feeds): + """ + Export the articles given in parameter in ePub files. + """ + from epub import ez_epub + for feed in feeds.values(): + # creates folder for each stream + folder = utils.path + "/var/export/epub/" + \ + utils.normalize_filename(feed.feed_title.strip().replace(':', '').lower()) + try: + os.makedirs(folder) + except OSError: + # directories already exists (not a problem) + pass + + for article in feed.articles.values(): + name = article.article_date.strip().replace(' ', '_') + name = os.path.normpath(folder + "/" + name + ".epub") + + section = ez_epub.Section() + section.title = article.article_title.decode('utf-8') + section.paragraphs = [utils.clear_string(article.article_description).decode('utf-8')] + ez_epub.makeBook(article.article_title.decode('utf-8'), [feed.feed_title.decode('utf-8')], [section], \ + name, lang='en-US', cover=None) + +def export_pdf(feeds): + """ + Export the articles given in parameter in PDF files. + """ + from xhtml2pdf import pisa + import cStringIO as StringIO + for feed in feeds.values(): + # creates folder for each stream + folder = utils.path + "/var/export/pdf/" + \ + utils.normalize_filename(feed.feed_title.strip().replace(':', '').lower()) + try: + os.makedirs(folder) + except OSError: + # directories already exists (not a problem) + pass + + for article in feed.articles.values(): + name = article.article_date.strip().replace(' ', '_') + name = os.path.normpath(folder + "/" + name + ".pdf") + + content = htmlheader + content += '\n
\n' + content += """

%s


""" % \ + (article.article_link, article.article_title) + content += article.article_description + content += "
\n
\n" + content += htmlfooter + + try: + pdf = pisa.CreatePDF(StringIO.StringIO(content), file(name, "wb")) + except: + pass \ No newline at end of file diff --git a/source/feedgetter.py b/source/feedgetter.py new file mode 100755 index 00000000..e3469132 --- /dev/null +++ b/source/feedgetter.py @@ -0,0 +1,167 @@ +#! /usr/bin/env python +#-*- coding: utf-8 -*- + +# pyAggr3g470r - A Web based news aggregator. +# Copyright (C) 2010 Cédric Bonhomme - http://cedricbonhomme.org/ +# +# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +__author__ = "Cedric Bonhomme" +__version__ = "$Revision: 1.0 $" +__date__ = "$Date: 2010/09/02 $" +__copyright__ = "Copyright (c) Cedric Bonhomme" +__license__ = "GPLv3" + +import os.path +import traceback +import threading +import feedparser +import hashlib +from BeautifulSoup import BeautifulSoup + +from datetime import datetime + +import utils +import mongodb + +feeds_list = [] +list_of_threads = [] + + +class FeedGetter(object): + """ + This class is in charge of retrieving feeds listed in ./var/feed.lst. + This class uses feedparser module from Mark Pilgrim. + For each feed a new thread is launched. + """ + def __init__(self): + """ + Initializes the base and variables. + """ + # MongoDB connections + self.articles = mongodb.Articles() + + def retrieve_feed(self): + """ + Parse the file 'feeds.lst' and launch a thread for each RSS feed. + """ + with open("./var/feed.lst") as f: + for a_feed in f: + # test if the URL is well formed + for url_regexp in utils.url_finders: + if url_regexp.match(a_feed): + the_good_url = url_regexp.match(a_feed).group(0).replace("\n", "") + try: + # launch a new thread for the RSS feed + thread = threading.Thread(None, self.process, \ + None, (the_good_url,)) + thread.start() + list_of_threads.append(thread) + except: + pass + break + + # wait for all threads are done + for th in list_of_threads: + th.join() + + def process(self, the_good_url): + """Request the URL + + Executed in a thread. + """ + if utils.detect_url_errors([the_good_url]) == []: + # if ressource is available add the articles in the base. + self.add_into_database(the_good_url) + + def add_into_database(self, feed_link): + """ + Add the articles of the feed 'a_feed' in the SQLite base. + """ + a_feed = feedparser.parse(feed_link) + if a_feed['entries'] == []: + return + try: + feed_image = a_feed.feed.image.href + except: + feed_image = "/img/feed-icon-28x28.png" + + sha1_hash = hashlib.sha1() + sha1_hash.update(feed_link.encode('utf-8')) + feed_id = sha1_hash.hexdigest() + + collection_dic = {"feed_id": feed_id, \ + "type": 0, \ + "feed_image": feed_image, \ + "feed_title": utils.clear_string(a_feed.feed.title.encode('utf-8')), \ + "feed_link": feed_link, \ + "site_link": a_feed.feed.link.encode('utf-8'), \ + "mail": False \ + } + + self.articles.add_collection(collection_dic) + + articles = [] + for article in a_feed['entries']: + description = "" + try: + # article content + description = article.content[0].value + except AttributeError: + try: + # article description + description = article.description + except Exception, e: + description = "" + description = str(BeautifulSoup(description)) + article_title = str(BeautifulSoup(article.title)) + + try: + post_date = datetime(*article.updated_parsed[:6]) + except: + post_date = datetime(*article.published_parsed[:6]) + + + sha1_hash = hashlib.sha1() + sha1_hash.update(article.link.encode('utf-8')) + article_id = sha1_hash.hexdigest() + + article = {"article_id": article_id, \ + "type":1, \ + "article_date": post_date, \ + "article_link": article.link.encode('utf-8'), \ + "article_title": article_title, \ + "article_content": description, \ + "article_readed": False, \ + "article_like": False \ + } + + articles.append(article) + + self.articles.add_articles(articles, feed_id) + + # send new articles by e-mail if desired. + #threading.Thread(None, utils.send_mail, None, (utils.mail_from, utils.mail_to, \ + #a_feed.feed.title.encode('utf-8'), \ + #article_title, description) \ + #).start() + + + +if __name__ == "__main__": + # Point of entry in execution mode + feed_getter = FeedGetter() + feed_getter.retrieve_feed() diff --git a/source/img/blogmarks.png b/source/img/blogmarks.png new file mode 100755 index 00000000..2464e5bb Binary files /dev/null and b/source/img/blogmarks.png differ diff --git a/source/img/check-news.png b/source/img/check-news.png new file mode 100644 index 00000000..cce7df39 Binary files /dev/null and b/source/img/check-news.png differ diff --git a/source/img/cross.png b/source/img/cross.png new file mode 100644 index 00000000..1514d51a Binary files /dev/null and b/source/img/cross.png differ diff --git a/source/img/diaspora.png b/source/img/diaspora.png new file mode 100644 index 00000000..fdf8bb72 Binary files /dev/null and b/source/img/diaspora.png differ diff --git a/source/img/digg.png b/source/img/digg.png new file mode 100755 index 00000000..097c4600 Binary files /dev/null and b/source/img/digg.png differ diff --git a/source/img/email-follow.png b/source/img/email-follow.png new file mode 100644 index 00000000..4505c610 Binary files /dev/null and b/source/img/email-follow.png differ diff --git a/source/img/favicon.png b/source/img/favicon.png new file mode 100644 index 00000000..d4d38473 Binary files /dev/null and b/source/img/favicon.png differ diff --git a/source/img/feed-icon-28x28.png b/source/img/feed-icon-28x28.png new file mode 100755 index 00000000..d64c669c Binary files /dev/null and b/source/img/feed-icon-28x28.png differ diff --git a/source/img/following-article.png b/source/img/following-article.png new file mode 100644 index 00000000..0e59e459 Binary files /dev/null and b/source/img/following-article.png differ diff --git a/source/img/hacker-news.png b/source/img/hacker-news.png new file mode 100644 index 00000000..ce92765d Binary files /dev/null and b/source/img/hacker-news.png differ diff --git a/source/img/heart-32x32.png b/source/img/heart-32x32.png new file mode 100644 index 00000000..09b01cb5 Binary files /dev/null and b/source/img/heart-32x32.png differ diff --git a/source/img/heart.png b/source/img/heart.png new file mode 100644 index 00000000..f36f3cfd Binary files /dev/null and b/source/img/heart.png differ diff --git a/source/img/heart_open.png b/source/img/heart_open.png new file mode 100644 index 00000000..e1c6e027 Binary files /dev/null and b/source/img/heart_open.png differ diff --git a/source/img/history.png b/source/img/history.png new file mode 100644 index 00000000..2a57cc17 Binary files /dev/null and b/source/img/history.png differ diff --git a/source/img/identica.png b/source/img/identica.png new file mode 100644 index 00000000..18b5bd2b Binary files /dev/null and b/source/img/identica.png differ diff --git a/source/img/management.png b/source/img/management.png new file mode 100644 index 00000000..7bcbc384 Binary files /dev/null and b/source/img/management.png differ diff --git a/source/img/mark-as-read.png b/source/img/mark-as-read.png new file mode 100644 index 00000000..ffc90910 Binary files /dev/null and b/source/img/mark-as-read.png differ diff --git a/source/img/pinboard.png b/source/img/pinboard.png new file mode 100644 index 00000000..6dddc10b Binary files /dev/null and b/source/img/pinboard.png differ diff --git a/source/img/previous-article.png b/source/img/previous-article.png new file mode 100644 index 00000000..fcd9bfd8 Binary files /dev/null and b/source/img/previous-article.png differ diff --git a/source/img/reddit.png b/source/img/reddit.png new file mode 100755 index 00000000..2d615f2a Binary files /dev/null and b/source/img/reddit.png differ diff --git a/source/img/scoopeo.png b/source/img/scoopeo.png new file mode 100755 index 00000000..052c7dc8 Binary files /dev/null and b/source/img/scoopeo.png differ diff --git a/source/img/tuxrss.png b/source/img/tuxrss.png new file mode 100644 index 00000000..d4d38473 Binary files /dev/null and b/source/img/tuxrss.png differ diff --git a/source/img/unread.png b/source/img/unread.png new file mode 100644 index 00000000..d3a641c7 Binary files /dev/null and b/source/img/unread.png differ diff --git a/source/mongodb.py b/source/mongodb.py new file mode 100644 index 00000000..d00b453e --- /dev/null +++ b/source/mongodb.py @@ -0,0 +1,253 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +__author__ = "Cedric Bonhomme" +__version__ = "$Revision: 0.1 $" +__date__ = "$Date: 2012/03/03 $" +__revision__ = "$Date: 2012/03/03 $" +__copyright__ = "Copyright (c) Cedric Bonhomme" +__license__ = "GPLv3" + +import time +import pymongo + +from operator import itemgetter, attrgetter + +class Articles(object): + """ + """ + def __init__(self, url='localhost', port=27017): + """ + Instantiates the connection. + """ + self.connection = pymongo.connection.Connection(url, port) + self.db = self.connection.pyaggr3g470r + + def add_collection(self, new_collection): + """ + Creates a new collection for a new feed. + """ + collection = self.db[new_collection["feed_id"]] + #collection.create_index([("feed_link", pymongo.ASCENDING)], {"unique":True, "sparse":True}) + collection.insert(new_collection) + + def add_articles(self, articles, feed_id): + """ + Add article(s) in a collection. + """ + collection = self.db[str(feed_id)] + + collection.create_index([("article_date", pymongo.DESCENDING)], \ + {"unique":False, "sparse":False}) + + for article in articles: + cursor = collection.find({"article_id":article["article_id"]}) + if cursor.count() == 0: + collection.insert(article) + + def delete_feed(self, feed_id): + """ + Delete a collection (feed with all articles). + """ + self.db.drop_collection(feed_id) + + def delete_article(self, feed_id, article_id): + """ + Delete an article. + """ + collection = self.db[str(feed_id)] + collection.find_and_modify(query={"article_id":article_id}, remove=True) + + def get_collection(self, feed_id): + """ + """ + return self.db[str(feed_id)].find().next() + + def get_all_articles(self): + """ + Return all articles from all collections. + """ + articles = [] + collections = self.db.collection_names() + for collection_name in collections: + collection = self.db[collection_name] + articles.extend([article for article in collection.find({'type':1})]) + return articles + + def get_article(self, feed_id, article_id): + """ + """ + collection = self.db[str(feed_id)] + return collection.find({"article_id":article_id}).next() + + def get_all_collections(self, condition=None): + """ + """ + feeds = [] + collections = self.db.collection_names() + for collection_name in collections: + if collection_name != "system.indexes": + if condition is None: + cursor = self.db[collection_name].find({"type":0}) + else: + cursor = self.db[collection_name].find({"type":0, condition[0]:condition[1]}) + if cursor.count() != 0: + feeds.append(cursor.next()) + feeds.sort(key = lambda elem: elem['feed_title'].lower()) + return feeds + + def get_articles_from_collection(self, feed_id, condition=None): + """ + Return all the articles of a collection. + """ + collection = self.db[str(feed_id)] + if condition is None: + cursor = collection.find({"type":1}) + else: + cursor = collection.find({"type":1, condition[0]:condition[1]}) + return cursor.sort([("article_date", pymongo.DESCENDING)]) + + def print_articles_from_collection(self, collection_id): + """ + Print the articles of a collection. + """ + collection = self.db[str(collection_id)] + cursor = collection.find({"type":1}) + print "Article for the collection", collection_id + for d in cursor: + print d + print + + def nb_articles(self, feed_id=None): + """ + Return the number of users. + """ + if feed_id is not None: + collection = self.db[feed_id] + cursor = collection.find({'type':1}) + return cursor.count() + else: + nb_articles = 0 + for feed_id in self.db.collection_names(): + nb_articles += self.nb_articles(feed_id) + return nb_articles + + def nb_favorites(self, feed_id=None): + if feed_id is not None: + collection = self.db[feed_id] + cursor = collection.find({'type':1, 'article_like':True}) + return cursor.count() + else: + nb_favorites = 0 + for feed_id in self.db.collection_names(): + nb_favorites += self.nb_favorites(feed_id) + return nb_favorites + + def nb_mail_notifications(self): + """ + Return the number of subscribed feeds. + """ + nb_mail_notifications = 0 + for feed_id in self.db.collection_names(): + collection = self.db[feed_id] + cursor = collection.find({'type':0, 'mail':True}) + nb_mail_notifications += cursor.count() + return nb_mail_notifications + + def nb_unread_articles(self, feed_id=None): + if feed_id is not None: + collection = self.db[feed_id] + cursor = collection.find({'article_readed':False}) + return cursor.count() + else: + unread_articles = 0 + for feed_id in self.db.collection_names(): + unread_articles += self.nb_unread_articles(feed_id) + return unread_articles + + def like_article(self, like, feed_id, article_id): + """ + Like or unlike an article. + """ + collection = self.db[str(feed_id)] + collection.update({"article_id": article_id}, {"$set": {"article_like": like}}) + + def mark_as_read(self, readed, feed_id=None, article_id=None): + """ + """ + if feed_id != None and article_id != None: + collection = self.db[str(feed_id)] + collection.update({"article_id": article_id, "article_readed":not readed}, {"$set": {"article_readed": readed}}) + elif feed_id != None and article_id == None: + collection = self.db[str(feed_id)] + collection.update({"type": 1, "article_readed":not readed}, {"$set": {"article_readed": readed}}, multi=True) + else: + for feed_id in self.db.collection_names(): + self.mark_as_read(readed, feed_id, None) + + def list_collections(self): + """ + List all collections (feed). + """ + collections = self.db.collection_names() + return collections + + # Functions on database + def drop_database(self): + """ + Drop all the database + """ + self.connection.drop_database('pyaggr3g470r') + + +if __name__ == "__main__": + # Point of entry in execution mode. + articles = Articles() + + + # Create a collection for a stream + collection_dic = {"collection_id": 42,\ + "feed_image": "Image", \ + "feed_title": "Title", \ + "feed_link": "Link", \ + "site_title": "Site link", \ + "mail": True, \ + } + + #articles.add_collection(collection_dic) + + + + # Add an article in the newly created collection + article_dic1 = {"article_id": 51, \ + "article_date": "Today", \ + "article_link": "Link of the article", \ + "article_title": "The title", \ + "article_content": "The content of the article", \ + "article_readed": True, \ + "article_like": True \ + } + + article_dic2 = {"article_id": 52, \ + "article_date": "Yesterday", \ + "article_link": "Link", \ + "article_title": "Hello", \ + "article_content": "The content of the article", \ + "article_readed": True, \ + "article_like": True \ + } + + #articles.add_articles([article_dic1, article_dic2], 42) + + + # Print articles of the collection + #articles.print_articles_from_collection("http://esr.ibiblio.org/?feed=rss2") + + + print "All articles:" + #print articles.get_all_articles() + + + + # Drop the database + articles.drop_database() \ No newline at end of file diff --git a/source/pyAggr3g470r b/source/pyAggr3g470r new file mode 100755 index 00000000..81f5cea0 --- /dev/null +++ b/source/pyAggr3g470r @@ -0,0 +1,130 @@ +#! /usr/bin/env python +#-*- coding: utf-8 -*- + +# pyAggr3g470r - A Web based news aggregator. +# Copyright (C) 2010 Cédric Bonhomme - http://cedricbonhomme.org/ +# +# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +__author__ = "Cedric Bonhomme" +__version__ = "$Revision: 0.1 $" +__date__ = "$Date: 2011/06/20 $" +__copyright__ = "Copyright (c) Cedric Bonhomme" +__license__ = "GPLv3" + +# This control file is inspired from Forban: http://www.foo.be/forban. + +import os +import sys +import time +import subprocess +import platform +import signal + +PATH = os.path.abspath(".") +SERVICE = "pyAggr3g470r" + +def service_start(servicename = None): + if servicename is not None: + service = servicename + ".py" + proc = subprocess.Popen(["python",service], stderr=subprocess.STDOUT, stdout=subprocess.PIPE) + time.sleep(0.15) + return proc.pid + return False + +def writepid (processname = None, pid = None): + pidpath = os.path.join(PATH,"var",processname+".pid") + if processname is not None and pid is not None: + f = open (pidpath,"w") + f.write(str(pid)) + f.close() + return True + else: + return False + +def checkpid (servicename = None): + pidpath = os.path.join(PATH,"var",servicename+".pid") + if os.path.exists(pidpath): + return True + else: + return False + +def pidof(processname = None): + pidpath = os.path.join(PATH,"var",processname+".pid") + if processname is not None and os.path.exists(pidpath): + f = open (pidpath) + pid = f.read() + f.close() + return pid + else: + return False + +def rmpid (processname = None): + pidpath = os.path.join(PATH, "var", processname + ".pid") + if os.path.exists(pidpath): + os.unlink(pidpath) + return True + else: + return False + +def start(): + if not checkpid(servicename = SERVICE): + pid = service_start(servicename = SERVICE) + writepid(processname = SERVICE, pid = pid) + print SERVICE + " is starting with pid: " + pidof(processname=SERVICE) + else: + print SERVICE + " could not be started (pid exists)" + retval=False + +def stop(): + print "Stopping pyAggr3g470r..." + retval=True + pid = pidof(processname=SERVICE) + if pid: + if platform.system() == "Windows": + import win32api + import win32con + phandle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, int(pid)) + win32api.TerminateProcess(phandle, 0) + win32api.CloseHandle(phandle) + rmpid(processname=SERVICE) + else: + try: + os.kill(int(pid), signal.SIGKILL) + except OSError, e: + print SERVICE + " unsuccessfully stopped" + retval = False + print SERVICE + rmpid(processname=SERVICE) + return retval + +def usage(): + print "pyAggr3g470r (start|stop|restart)" + exit (1) + +if __name__ == "__main__": + # Point of entry in execution mode. + if len(sys.argv) == 1: + usage() + elif sys.argv[1] == "start": + start() + elif sys.argv[1] == "stop": + stop() + elif sys.argv[1] == "restart": + stop() + start() + else: + usage() diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py new file mode 100755 index 00000000..1284ea3e --- /dev/null +++ b/source/pyAggr3g470r.py @@ -0,0 +1,1271 @@ +#! /usr/bin/env python +#-*- coding: utf-8 -*- + +# pyAggr3g470r - A Web based news aggregator. +# Copyright (C) 2010-2012 Cédric Bonhomme - http://cedricbonhomme.org/ +# +# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +__author__ = "Cedric Bonhomme" +__version__ = "$Revision: 3.1 $" +__date__ = "$Date: 2010/01/29 $" +__revision__ = "$Date: 2012/03/09 $" +__copyright__ = "Copyright (c) Cedric Bonhomme" +__license__ = "GPLv3" + +# +# This file contains the "Root" class which describes +# all pages of pyAggr3g470r. These pages are: +# - main page; +# - management; +# - history; +# - favorites; +# - notifications; +# - unread; +# - feed summary. +# + +import os +import re +import time +import cherrypy +import calendar + +from collections import Counter +import datetime + +import utils +import export +import mongodb +import feedgetter +from qrcode.pyqrnative.PyQRNative import QRCode, QRErrorCorrectLevel, CodeOverflowException +from qrcode import qr + + +def error_page_404(status, message, traceback, version): + """ + Display an error if the page does not exist. + """ + html = htmlheader() + html += htmlnav + html += "

Error %s - This page does not exist." % status + html += "\n
\n" + htmlfooter + return html + +def handle_error(): + """ + Handle different type of errors. + """ + html = htmlheader() + html += htmlnav + html += "

Sorry, an error occured" + html += "\n
\n" + htmlfooter + cherrypy.response.status = 500 + cherrypy.response.body = [html] + +def htmlheader(nb_unread_articles=""): + """ + Return the header of the HTML page with the number of unread articles + in the 'title' HTML tag.. + """ + return '\n' + \ + '' + \ + '\n\t'+ nb_unread_articles +'pyAggr3g470r - News aggregator\n' + \ + '\t' + \ + '\n\t\n' + \ + '\n\t\n' + \ + '\n' + +htmlfooter = '

This software is under GPLv3 license. You are welcome to copy, modify or' + \ + ' redistribute the source code according to the' + \ + ' GPLv3 license.

\n' + \ + '\n' + +htmlnav = '\n

pyAggr3g470r - News aggregator

\n' + \ + 'pyAggr3g470r (source code)' + + +class Root: + """ + Root class. + All pages of pyAggr3g470r are described in this class. + """ + def __init__(self): + """ + """ + self.mongo = mongodb.Articles(utils.MONGODB_ADDRESS, utils.MONGODB_PORT) + + def index(self): + """ + Main page containing the list of feeds and articles. + """ + feeds = self.mongo.get_all_collections() + nb_unread_articles = self.mongo.nb_unread_articles() + nb_favorites = self.mongo.nb_favorites() + nb_mail_notifications = self.mongo.nb_mail_notifications() + + # if there are unread articles, display the number in the tab of the browser + html = htmlheader((nb_unread_articles and \ + ['(' + str(nb_unread_articles) +') '] or \ + [""])[0]) + html += htmlnav + html += self.create_right_menu() + html += """
\n""" + + if feeds: + html += '\n' + html += '\n' + html += '      \n' + + html += """\n""" % \ + (nb_favorites,) + + html += """\n""" % \ + (nb_mail_notifications,) + + html += '      ' + if nb_unread_articles != 0: + html += '\n' + html += """\n""" % \ + (nb_unread_articles,) + html += '\n' + + + # The main page display all the feeds. + for feed in feeds: + html += """

%s +

\n""" % \ + (feed["feed_id"], feed["feed_link"], feed["feed_title"], \ + feed["feed_link"], feed["feed_image"]) + + # The main page display only 10 articles by feeds. + for article in self.mongo.get_articles_from_collection(feed["feed_id"])[:10]: + if article["article_readed"] == False: + # not readed articles are in bold + not_read_begin, not_read_end = "", "" + else: + not_read_begin, not_read_end = "", "" + + # display a heart for faved articles + if article["article_like"] == True: + like = """ """ + else: + like = "" + + # Descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content.split(' ')[:55]) + else: + description = "No description." + # Title of the article + article_title = article["article_title"] + if len(article_title) >= 110: + article_title = article_title[:110] + " ..." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].ctime() + " - " + \ + """%s%s%s%s""" % \ + (feed["feed_id"], article["article_id"], not_read_begin, \ + article_title, not_read_end, description) + like + "
\n" + html += "
\n" + + # some options for the current feed + html += """All articles   """ % (feed["feed_id"],) + html += """Feed summary   """ % (feed["feed_id"],) + if self.mongo.nb_unread_articles(feed["feed_id"]) != 0: + html += """  Mark all as read""" % (feed["feed_id"],) + html += """     Unread article(s) (%s)""" % (feed["feed_id"], self.mongo.nb_unread_articles(feed["feed_id"])) + if feed["mail"] == "0": + html += """
\nStay tuned""" % (feed["feed_id"],) + else: + html += """
\nStop staying tuned""" % (feed["feed_id"],) + html += """

Top

""" + html += "
\n" + html += htmlfooter + return html + + index.exposed = True + + + def create_right_menu(self): + """ + Create the right menu. + """ + html = """
\n""" + html += """
\n""" + html += "
\n" + # insert the list of feeds in the menu + html += self.create_list_of_feeds() + html += "
\n" + + return html + + def create_list_of_feeds(self): + """ + Create the list of feeds. + """ + feeds = self.mongo.get_all_collections() + html = """" + + + def management(self, max_nb_articles=5): + """ + Management page. + Allows adding and deleting feeds. Export functions of the MongoDB data base + and display some statistics. + """ + feeds = self.mongo.get_all_collections() + nb_mail_notifications = self.mongo.nb_mail_notifications() + nb_favorites = self.mongo.nb_favorites() + nb_articles = self.mongo.nb_articles() + nb_unread_articles = self.mongo.nb_unread_articles() + + html = htmlheader() + html += htmlnav + html += """
\n""" + html += "

Add Feeds

\n" + # Form: add a feed + html += """
\n
\n""" + + if feeds: + # Form: delete a feed + html += "

Delete Feeds

\n" + html += """
\n""" + + html += """

Active e-mail notifications: %s

\n""" % \ + (nb_mail_notifications,) + html += """

You like %s article(s).

\n""" % \ + (nb_favorites, ) + + html += "
\n" + + # Informations about the data base of articles + html += """

%s article(s) are loaded from the database with + %s unread article(s).
\n""" % \ + (nb_articles, nb_unread_articles) + #html += """Database: %s.\n
Size: %s bytes.
\n""" % \ + #(os.path.abspath(utils.sqlite_base), os.path.getsize(utils.sqlite_base)) + html += 'Advanced statistics.

\n' + + html += """
\n
\n""" + html += """
\n
\n""" + + + html += '
\n' + html += "For each feed only load the " + html += """\n""" % (max_nb_articles) + html += " last articles." + if utils.MAX_NB_ARTICLES == -1: + html += "
All articles are currently loaded.\n" + else: + html += "
For each feed only " + str(utils.MAX_NB_ARTICLES) + " articles are currently loaded. " + html += 'Load all articles.
\n' + html += "
\n" + + # Export functions + html += "

Export articles

\n\n" + html += """
\n\t\n
\n""" + html += "
" + html += htmlfooter + return html + + management.exposed = True + + + def statistics(self, word_size=6): + """ + More advanced statistics. + """ + articles = self.mongo.get_all_articles() + html = htmlheader() + html += htmlnav + html += """
\n""" + + # Some statistics (most frequent word) + if articles: + top_words = utils.top_words(articles, n=50, size=int(word_size)) + html += "

Statistics

\n
\n" + # Tags cloud + html += 'Minimum size of a word:' + html += '
' + html += """""" % (word_size) + html += '
\n' + html += '

Tag cloud

\n' + html += '
' + \ + utils.tag_cloud(top_words) + '
' + html += "
\n" + + html += htmlfooter + return html + + statistics.exposed = True + + + def search(self, query=None): + """ + Simply search for the string 'query' + in the description of the article. + """ + param, _, value = query.partition(':') + wordre = re.compile(r'\b%s\b' % param, re.I) + feed_id = None + if param == "Feed": + feed_id, _, query = value.partition(':') + html = htmlheader() + html += htmlnav + html += """
""" + html += """

Articles containing the string %s


""" % (query,) + + if feed_id is not None: + for article in self.feeds[feed_id].articles.values(): + article_content = utils.clear_string(article.article_description) + if not article_content: + utils.clear_string(article.article_title) + if wordre.findall(article_content) != []: + if article.article_readed == "0": + # not readed articles are in bold + not_read_begin, not_read_end = "", "" + else: + not_read_begin, not_read_end = "", "" + + html += article.article_date + " - " + not_read_begin + \ + """%s""" % \ + (feed_id, article.article_id, article.article_title) + \ + not_read_end + """
\n""" + else: + feeds = self.mongo.get_all_collections() + for feed in feeds: + new_feed_section = True + for article in self.mongo.get_articles_from_collection(feed["feed_id"]): + article_content = utils.clear_string(article["article_content"]) + if not article_content: + utils.clear_string(article["article_title"]) + if wordre.findall(article_content) != []: + if new_feed_section is True: + new_feed_section = False + html += """

%s

\n""" % \ + (feed["feed_id"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) + + if article["article_readed"] == False: + # not readed articles are in bold + not_read_begin, not_read_end = "", "" + else: + not_read_begin, not_read_end = "", "" + + # display a heart for faved articles + if article["article_like"] == True: + like = """ """ + else: + like = "" + + # descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].ctime() + " - " + \ + """%s%s%s%s""" % \ + (feed["feed_id"], article["article_id"], not_read_begin, \ + article["article_title"][:150], not_read_end, description) + like + "
\n" + html += "
" + html += htmlfooter + return html + + search.exposed = True + + + def fetch(self): + """ + Fetch all feeds. + """ + feed_getter = feedgetter.FeedGetter() + feed_getter.retrieve_feed() + return self.index() + + fetch.exposed = True + + + def article(self, param): + """ + Display the article in parameter in a new Web page. + """ + try: + feed_id, article_id = param.split(':') + feed = self.mongo.get_collection(feed_id) + articles = self.mongo.get_articles_from_collection(feed_id) + article = self.mongo.get_article(feed_id, article_id) + except: + return self.error_page("Bad URL. This article do not exists.") + html = htmlheader() + html += htmlnav + html += """
""" + + if article["article_readed"] == False: + # if the current article is not yet readed, update the database + self.mark_as_read("Article:"+article["article_id"]+":"+feed["feed_id"]) + + html += '\n
\n' + # Title of the article + html += """

%s from %s

\n
\n""" % \ + (article["article_title"], feed_id, feed["feed_title"]) + if article["article_like"] == True: + html += """""" % \ + (feed_id, article["article_id"]) + else: + html += """""" % \ + (feed_id, article["article_id"]) + html += """  """ % \ + (feed_id, article["article_id"]) + html += "

" + + # Description (full content) of the article + description = article["article_content"] + if description: + p = re.compile(r'<') + q = re.compile(r'>') + + description = p.sub('<', description) + description = q.sub('>', description) + + html += description + "\n


" + else: + html += "No description available.\n


" + + # Generation of the QR Code for the current article + try: + os.makedirs("./var/qrcode/") + except OSError: + pass + if not os.path.isfile("./var/qrcode/" + article_id + ".png"): + # QR Code generation + try: + if len(utils.clear_string(description)) > 4296: + raise Exception() + f = qr.QRUrl(url = utils.clear_string(description)) + f.make() + except: + f = qr.QRUrl(url = article["article_link"]) + f.make() + f.save("./var/qrcode/"+article_id+".png") + + # Previous and following articles + articles_list = articles.distinct("article_id") + try: + following = articles[articles_list.index(article_id) - 1] + html += """
\n""" % \ + (feed_id, following["article_id"], following["article_title"]) + except Exception, e: + print e + try: + previous = articles[articles_list.index(article_id) + 1] + except: + previous = articles[0] + finally: + html += """
\n""" % \ + (feed_id, previous["article_id"], previous["article_title"]) + + html += "\n
\n" + + # Footer menu + html += "
\n" + html += """\nPlain text\n""" % (feed_id, article["article_id"]) + html += """ - Export to EPUB\n""" % (feed_id, article["article_id"]) + html += """
\nComplete story\n
\n""" % (article["article_link"],) + + # Share this article: + html += "Share this article:
\n" + # on Diaspora + html += """\n\t + \n""" % \ + (utils.DIASPORA_POD, article["article_link"], article["article_title"], "via pyAggr3g470r") + + # on Identi.ca + html += """\n\n""" % \ + (article["article_title"], article["article_link"]) + + # on Hacker News + html += """\n\n""" % \ + (article["article_link"], article["article_title"]) + + # on Pinboard + html += """\n\n\t\n + """ % \ + (article["article_link"], article["article_title"]) + + # on Digg + html += """\n\n\t\n + """ % \ + (article["article_link"], article["article_title"]) + # on reddit + html += """\n\n\t\n + """ % \ + (article["article_link"], article["article_title"]) + # on Scoopeo + html += """\n\n\t\n + """ % \ + (article["article_link"], article["article_title"]) + # on Blogmarks + html += """\n\n\t\n + """ % \ + (article["article_link"], article["article_title"]) + + # Google +1 button + html += """\n\n""" % \ + (article["article_link"],) + + + # QRCode (for smartphone) + html += """
\n""" % (article_id, article_id) + html += "
\n" + htmlfooter + return html + + article.exposed = True + + + def feed(self, feed_id, word_size=6): + """ + This page gives summary informations about a feed (number of articles, + unread articles, average activity, tag cloud, e-mail notification and + favourite articles for the current feed. + """ + try: + feed = self.mongo.get_collection(feed_id) + articles = self.mongo.get_articles_from_collection(feed_id) + except KeyError: + return self.error_page("This feed do not exists.") + html = htmlheader() + html += htmlnav + html += """
""" + html += "

The feed " + feed["feed_title"] + " contains " + str(self.mongo.nb_articles(feed_id)) + " articles. " + html += "Representing " + str((round(float(self.mongo.nb_articles(feed_id)) / 1000, 4)) * 100) + " % of the total " #hack + html += "(" + str(1000) + ").

" + if articles != []: + html += "

" + (self.mongo.nb_unread_articles(feed_id) == 0 and ["All articles are read"] or [str(self.mongo.nb_unread_articles(feed_id)) + \ + " unread article" + (self.mongo.nb_unread_articles(feed_id) == 1 and [""] or ["s"])[0]])[0] + ".

" + if feed["mail"] == True: + html += """

You are receiving articles from this feed to the address: %s. """ % \ + (utils.mail_to, utils.mail_to) + html += """Stop receiving articles from this feed.

""" % \ + (feed[feed_id], ) + + if articles != []: + last_article = utils.string_to_datetime(str(articles[0]["article_date"])) + first_article = utils.string_to_datetime(str(articles[self.mongo.nb_articles(feed_id)-2]["article_date"])) + delta = last_article - first_article + delta_today = datetime.datetime.fromordinal(datetime.date.today().toordinal()) - last_article + html += "

The last article was posted " + str(abs(delta_today.days)) + " day(s) ago.

" + if delta.days > 0: + html += """

Daily average: %s,""" % (str(round(float(self.mongo.nb_articles(feed_id))/abs(delta.days), 2)),) + html += """ between the %s and the %s.

\n""" % \ + (str(articles[self.mongo.nb_articles(feed_id)-2]["article_date"])[:10], str(articles[0]["article_date"])[:10]) + + html += "

Recent articles

" + for article in articles[:10]: + if article["article_readed"] == False: + # not readed articles are in bold + not_read_begin, not_read_end = "", "" + else: + not_read_begin, not_read_end = "", "" + + # display a heart for faved articles + if article["article_like"] == True: + like = """ """ + else: + like = "" + + # Descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + # Title of the article + article_title = article["article_title"] + if len(article_title) >= 110: + article_title = article_title[:110] + " ..." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].ctime() + " - " + \ + """%s%s%s%s""" % \ + (feed["feed_id"], article["article_id"], not_read_begin, \ + article_title, not_read_end, description) + like + "
\n" + html += "
\n" + html += """All articles   """ % (feed["feed_id"],) + + favs = [article for article in articles if article["article_like"] == True] + if len(favs) != 0: + html += "

Your favorites articles for this feed

" + for article in favs: + if article["like"] == True: + # descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].ctime() + " - " + \ + """%s%s
\n""" % \ + (feed["feed_id"], article["article_id"], article["article_title"][:150], description) + + + # This section enables the user to edit informations about + # the current feed: + # - feed logo; + # - feed name; + # - URL of the feed (not the site); + html += "
\n

Edit this feed

\n" + html += '\n\n
' + \ + '' + \ + """
\n""" % \ + (feed["feed_link"],) + html += '\n\n
' + \ + '' + \ + """
\n""" % \ + (feed["feed_link"],) + html += '\n\n
' + \ + '' + \ + """
\n""" % \ + (feed["feed_link"],) + + dic = {} + top_words = utils.top_words(articles = self.mongo.get_articles_from_collection(feed_id), n=50, size=int(word_size)) + html += "

Tag cloud

\n
\n" + # Tags cloud + html += 'Minimum size of a word:' + html += """
""" % (feed["feed_id"],) + html += """""" % (word_size,) + html += '
\n' + html += '
' + \ + utils.tag_cloud(top_words) + '
' + + html += "
" + html += "
" + html += htmlfooter + return html + + feed.exposed = True + + + def articles(self, feed_id): + """ + This page displays all articles of a feed. + """ + try: + feed = self.mongo.get_collection(feed_id) + articles = self.mongo.get_articles_from_collection(feed_id) + except KeyError: + return self.error_page("This feed do not exists.") + html = htmlheader() + html += htmlnav + html += """
\n""" + html += """Mark all articles from this feed as read""" % (feed_id,) + html += """
\n
\n""" % ("Feed:"+feed_id,) + html += "
\n" + html += self.create_list_of_feeds() + html += """
""" + html += """

Articles of the feed %s


""" % (feed["feed_title"],) + + for article in articles: + + if article["article_readed"] == False: + # not readed articles are in bold + not_read_begin, not_read_end = "", "" + else: + not_read_begin, not_read_end = "", "" + + if article["article_like"] == True: + like = """ """ + else: + like = "" + + # descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].ctime() + " - " + \ + """%s%s%s%s""" % \ + (feed_id, article["article_id"], not_read_begin, \ + article["article_title"][:150], not_read_end, description) + like + "
\n" + + html += """\n

All feeds

""" + html += "
\n" + html += htmlfooter + return html + + articles.exposed = True + + + def unread(self, feed_id=""): + """ + This page displays all unread articles of a feed. + """ + feeds = self.mongo.get_all_collections() + html = htmlheader() + html += htmlnav + html += """
""" + if self.mongo.nb_unread_articles() != 0: + + # List unread articles of all the database + if feed_id == "": + html += "

Unread article(s)

" + html += """\n
\nMark articles as read\n
\n""" + for feed in feeds: + new_feed_section = True + nb_unread = 0 + + # For all unread article of the current feed. + for article in self.mongo.get_articles_from_collection(feed["feed_id"], condition=("article_readed", False)): + nb_unread += 1 + if new_feed_section is True: + new_feed_section = False + html += """

%s

\n""" % \ + (feed["feed_id"], feed["site_link"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) + + # descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].ctime() + " - " + \ + """%s%s
\n""" % \ + (feed["feed_id"], article["article_id"], article["article_title"][:150], description) + + if nb_unread == self.mongo.nb_unread_articles(feed["feed_id"]): + html += """
\nMark all articles from this feed as read\n""" % \ + (feed["feed_id"],) + html += """
\nMark articles as read\n""" + + # List unread articles of a feed + else: + try: + feed = self.mongo.get_collection(feed_id) + except: + self.error_page("This feed do not exists.") + html += """

Unread article(s) of the feed %s

+
""" % (feed_id, feed["feed_title"]) + + # For all unread article of the feed. + for article in self.mongo.get_articles_from_collection(feed_id, condition=("article_readed", False)): + # descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].ctime() + " - " + \ + """%s%s
\n""" % \ + (feed_id, article["article_id"], article["article_title"][:150], description) + + html += """
\nMark all as read""" % (feed_id,) + # No unread article + else: + html += '

No unread article(s)

\n
\nWhy not check for news?' + html += """\n

All feeds

""" + html += "
\n" + html += htmlfooter + return html + + unread.exposed = True + + + def history(self, query="all", m=""): + """ + This page enables to browse articles chronologically. + """ + feeds = self.mongo.get_all_collections() + html = htmlheader() + html += htmlnav + html += """
\n""" + + # Get the date from the tag cloud + # Format: /history/?query=year:2011-month:06 to get the + # list of articles of June, 2011. + if m != "": + query = """year:%s-month:%s""" % tuple(m.split('-')) + + if query == "all": + html += "

Search with tags cloud

\n" + html += "

Choose a year


\n" + if "year" in query: + the_year = query.split('-')[0].split(':')[1] + if "month" not in query: + html += "

Choose a month for " + the_year + "


\n" + if "month" in query: + the_month = query.split('-')[1].split(':')[1] + html += "

Articles of "+ calendar.month_name[int(the_month)] + \ + ", "+ the_year +".


\n" + + timeline = Counter() + for feed in feeds: + new_feed_section = True + for article in self.mongo.get_articles_from_collection(feed["feed_id"]): + + if query == "all": + timeline[str(article["article_date"]).split(' ')[0].split('-')[0]] += 1 + + elif query[:4] == "year": + + if str(article["article_date"]).split(' ')[0].split('-')[0] == the_year: + timeline[str(article["article_date"]).split(' ')[0].split('-')[1]] += 1 + + if "month" in query: + if str(article["article_date"]).split(' ')[0].split('-')[1] == the_month: + if article["article_readed"] == False: + # not readed articles are in bold + not_read_begin, not_read_end = "", "" + else: + not_read_begin, not_read_end = "", "" + + if article["article_like"] == True: + like = """ """ + else: + like = "" + # Descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + # Title of the article + article_title = article["article_title"] + if len(article_title) >= 110: + article_title = article_title[:110] + " ..." + + if new_feed_section is True: + new_feed_section = False + html += """

%s

\n""" % \ + (feed["feed_id"], feed["feed_link"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) + + html += article["article_date"].strftime("%a %d (%H:%M:%S) ") + \ + """%s%s%s%s""" % \ + (feed["feed_id"], article["article_id"], not_read_begin, \ + article_title, not_read_end, description) + like + "
\n" + if query == "all": + query_string = "year" + elif "year" in query: + query_string = "year:" + the_year + "-month" + if "month" not in query: + html += '
' + \ + utils.tag_cloud([(elem, timeline[elem]) for elem in timeline.keys()], query_string) + '
' + html += '

Search with a month+year picker

\n' + html += '
\n\t\n\t\n
' + html += '
' + html += htmlfooter + return html + + history.exposed = True + + + def plain_text(self, target): + """ + Display an article in plain text (without HTML tags). + """ + try: + feed_id, article_id = target.split(':') + feed = self.mongo.get_collection(feed_id) + article = self.mongo.get_article(feed_id, article_id) + except: + return self.error_page("Bad URL. This article do not exists.") + html = htmlheader() + html += htmlnav + html += """
""" + html += """

%s from %s

\n
\n"""% \ + (article["article_title"], feed_id, feed["feed_title"]) + description = utils.clear_string(article["article_content"]) + if description: + html += description + else: + html += "No description available." + html += "\n
\n" + htmlfooter + return html + + plain_text.exposed = True + + + def error_page(self, message): + """ + Display a message (bad feed id, bad article id, etc.) + """ + html = htmlheader() + html += htmlnav + html += """
""" + html += """%s""" % message + html += "\n
\n" + htmlfooter + return html + + error_page.exposed = True + + + def mark_as_read(self, target=""): + """ + Mark one (or more) article(s) as read by setting the value of the field + 'article_readed' of the MongoDB database to 'True'. + """ + param, _, identifiant = target.partition(':') + + # Mark all articles as read. + if param == "": + self.mongo.mark_as_read(True, None, None) + # Mark all articles from a feed as read. + elif param == "Feed" or param == "Feed_FromMainPage": + self.mongo.mark_as_read(True, identifiant, None) + # Mark an article as read. + elif param == "Article": + self.mongo.mark_as_read(True, identifiant.split(':')[1], identifiant.split(':')[0]) + if param == "" or param == "Feed_FromMainPage": + return self.index() + elif param == "Feed": + return self.articles(identifiant) + + mark_as_read.exposed = True + + + def notifications(self): + """ + List all active e-mail notifications. + """ + html = htmlheader() + html += htmlnav + html += """
""" + feeds = self.mongo.get_all_collections(condition=("mail",True)) + if feeds != []: + html += "

You are receiving e-mails for the following feeds:

\n" + for feed in feeds: + html += """\t%s - Stop
\n""" % \ + (feed["feed_id"], feed["feed_title"], feed["feed_id"]) + else: + html += "

No active notifications.

\n" + html += """

Notifications are sent to: %s

""" % \ + (utils.mail_to, utils.mail_to) + html += "\n
\n" + htmlfooter + return html + + notifications.exposed = True + + + def mail_notification(self, param): + """ + Enable or disable to notifications of news for a feed. + """ + try: + action, feed_id = param.split(':') + feed = self.feeds[feed_id] + except: + return self.error_page("Bad URL. This feed do not exists.") + + return self.index() + + mail_notification.exposed = True + + + def like(self, param): + """ + Mark or unmark an article as favorites. + """ + try: + like, feed_id, article_id = param.split(':') + articles = self.mongo.get_article(feed_id, article_id) + except: + return self.error_page("Bad URL. This article do not exists.") + self.mongo.like_article("1"==like, feed_id, article_id) + return self.article(feed_id+":"+article_id) + + like.exposed = True + + + def favorites(self): + """ + List of favorites articles + """ + feeds = self.mongo.get_all_collections() + html = htmlheader() + html += htmlnav + html += """
""" + html += "

Your favorites articles

" + for feed in feeds: + new_feed_section = True + for article in self.mongo.get_articles_from_collection(feed["feed_id"]): + if article["article_like"] == True: + if new_feed_section is True: + new_feed_section = False + html += """

%s

\n""" % \ + (feed["feed_id"], feed["feed_link"], feed["feed_title"], feed["feed_link"], feed["feed_image"]) + + # descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].ctime() + " - " + \ + """%s%s
\n""" % \ + (feed["feed_id"], article["article_id"], article["article_title"][:150], description) + html += "
\n" + html += htmlfooter + return html + + favorites.exposed = True + + + def add_feed(self, url): + """ + Add a new feed with the URL of a page. + """ + html = htmlheader() + html += htmlnav + html += """
""" + # search the feed in the HTML page with BeautifulSoup + feed_url = utils.search_feed(url) + if feed_url is None: + return self.error_page("Impossible to find a feed at this URL.") + # if a feed exists + else: + result = utils.add_feed(feed_url) + # if the feed is not in the file feed.lst + if result is False: + html += "

You are already following this feed!

" + else: + html += """

Feed added. You can now fetch your feeds.

""" + html += """\n
\nBack to the management page.
\n""" + html += "
\n" + html += htmlfooter + return html + + add_feed.exposed = True + + + def remove_feed(self, feed_id): + """ + Remove a feed from the file feed.lst and from the MongoDB database. + """ + html = htmlheader() + html += htmlnav + html += """
""" + + feed = self.mongo.get_collection(feed_id) + self.mongo.delete_feed(feed_id) + utils.remove_feed(feed["feed_link"]) + + html += """

All articles from the feed %s are now removed from the base.


""" % \ + (feed["feed_title"],) + html += """Back to the management page.
\n""" + html += "
\n" + html += htmlfooter + return html + + remove_feed.exposed = True + + + 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 += """
""" + utils.change_feed_url(old_feed_url, new_feed_url) + html += "

The URL of the feed has been changed.

" + html += "
\n" + html += htmlfooter + 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 += """
""" + utils.change_feed_name(feed_url, new_feed_name) + html += "

The name of the feed has been changed.

" + html += "
\n" + html += htmlfooter + return html + + change_feed_name.exposed = True + + def change_feed_logo(self, feed_url, new_feed_logo): + """ + Enables to change the name of a feed. + """ + html = htmlheader() + html += htmlnav + html += """
""" + utils.change_feed_logo(feed_url, new_feed_logo) + html += "

The logo of the feed has been changed.

" + html += "
\n" + html += htmlfooter + return html + + change_feed_logo.exposed = True + + + def set_max_articles(self, max_nb_articles=1): + """ + Enables to set the maximum of articles to be loaded per feed from + the data base. + """ + if max_nb_articles < -1 or max_nb_articles == 0: + max_nb_articles = 1 + utils.MAX_NB_ARTICLES = int(max_nb_articles) + return self.management() + + set_max_articles.exposed = True + + + def delete_article(self, param): + """ + Delete an article. + """ + try: + feed_id, article_id = param.split(':') + self.mongo.delete_article(feed_id, article_id) + except: + return self.error_page("Bad URL. This article do not exists.") + + return self.index() + + delete_article.exposed = True + + + def drop_base(self): + """ + Delete all articles. + """ + utils.drop_base() + return self.management() + + drop_base.exposed = True + + + def export(self, export_method): + """ + Export articles currently loaded from the MongoDB database with + the appropriate function of the 'export' module. + """ + try: + getattr(export, export_method)(self.feeds) + except Exception, e: + return self.error_page(e) + return self.management() + + export.exposed = True + + + def epub(self, param): + """ + Export an article to EPUB. + """ + try: + from epub import ez_epub + except Exception, e: + return self.error_page(e) + try: + feed_id, article_id = param.split(':') + except: + return self.error_page("Bad URL.") + try: + feed = self.feeds[feed_id] + article = feed.articles[article_id] + except: + self.error_page("This article do not exists.") + try: + folder = utils.path + "/var/export/epub/" + os.makedirs(folder) + except OSError: + # directories already exists (not a problem) + pass + section = ez_epub.Section() + section.title = article.article_title.decode('utf-8') + section.paragraphs = [utils.clear_string(article.article_description).decode('utf-8')] + ez_epub.makeBook(article.article_title.decode('utf-8'), [feed.feed_title.decode('utf-8')], [section], \ + os.path.normpath(folder) + "article.epub", lang='en-US', cover=None) + return self.article(param) + + epub.exposed = True + + +if __name__ == '__main__': + # Point of entry in execution mode + print "Launching pyAggr3g470r..." + + root = Root() + root.favicon_ico = cherrypy.tools.staticfile.handler(filename=os.path.join(utils.path + "/img/favicon.png")) + cherrypy.config.update({ 'server.socket_port': 12556, 'server.socket_host': "0.0.0.0"}) + cherrypy.config.update({'error_page.404': error_page_404}) + _cp_config = {'request.error_response': handle_error} + + cherrypy.quickstart(root, "/" ,config=utils.path + "/cfg/cherrypy.cfg") \ No newline at end of file diff --git a/source/sqlite2mongo.py b/source/sqlite2mongo.py new file mode 100644 index 00000000..633fb8f9 --- /dev/null +++ b/source/sqlite2mongo.py @@ -0,0 +1,78 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +import hashlib +import sqlite3 +import mongodb + +import utils + +from datetime import datetime + +SQLITE_BASE = "./var/feed.db" + + +def sqlite2mongo(): + """ + Load feeds and articles in a dictionary. + """ + mongo = mongodb.Articles() + list_of_feeds = [] + list_of_articles = [] + + try: + conn = sqlite3.connect(SQLITE_BASE, isolation_level = None) + c = conn.cursor() + list_of_feeds = c.execute("SELECT * FROM feeds").fetchall() + except: + pass + + if list_of_feeds != []: + # Walk through the list of feeds + for feed in list_of_feeds: + try: + list_of_articles = c.execute(\ + "SELECT * FROM articles WHERE feed_link='" + \ + feed[2] + "'").fetchall() + except: + continue + sha1_hash = hashlib.sha1() + sha1_hash.update(feed[2].encode('utf-8')) + feed_id = sha1_hash.hexdigest() + + new_collection = {"feed_id" : feed_id.encode('utf-8'), \ + "type": 0, \ + "feed_image" : feed[3].encode('utf-8'), \ + "feed_title" : feed[0].encode('utf-8'), \ + "feed_link" : feed[2].encode('utf-8'), \ + "site_link" : feed[1].encode('utf-8'), \ + "mail" : feed[4]=="1"} + + mongo.add_collection(new_collection) + + if list_of_articles != []: + # Walk through the list of articles for the current feed. + articles = [] + for article in list_of_articles: + sha1_hash = hashlib.sha1() + sha1_hash.update(article[2].encode('utf-8')) + article_id = sha1_hash.hexdigest() + + article = {"article_id": article_id.encode('utf-8'), \ + "type":1, \ + "article_date": utils.string_to_datetime(article[0]), \ + "article_link": article[2].encode('utf-8'), \ + "article_title": article[1].encode('utf-8'), \ + "article_content": article[3].encode('utf-8'), \ + "article_readed": article[4]=="1", \ + "article_like": article[6]=="1" \ + } + + articles.append(article) + + mongo.add_articles(articles, feed_id) + + c.close() + +if __name__ == "__main__": + sqlite2mongo() \ No newline at end of file diff --git a/source/utils.py b/source/utils.py new file mode 100755 index 00000000..c23b8794 --- /dev/null +++ b/source/utils.py @@ -0,0 +1,351 @@ +#! /usr/bin/env python +#-*- coding: utf-8 -*- + +# pyAggr3g470r - A Web based news aggregator. +# Copyright (C) 2010 Cédric Bonhomme - http://cedricbonhomme.org/ +# +# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +__author__ = "Cedric Bonhomme" +__version__ = "$Revision: 1.2 $" +__date__ = "$Date: 2010/12/07 $" +__revision__ = "$Date: 2011/04/15 $" +__copyright__ = "Copyright (c) Cedric Bonhomme" +__license__ = "GPLv3" + +# +# This file provides functions used for: +# - the database management; +# - generation of tags cloud; +# - HTML processing; +# - mail notifications. +# + +import re +import hashlib +import sqlite3 +import operator +import urlparse +import calendar +import unicodedata +import htmlentitydefs + +import smtplib +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText + +import urllib2 +import BaseHTTPServer +from BeautifulSoup import BeautifulSoup + +from datetime import datetime +from string import punctuation +from collections import Counter +from collections import OrderedDict + +from StringIO import StringIO + +import threading +LOCKER = threading.Lock() + +import os +import ConfigParser +# load the configuration +config = ConfigParser.RawConfigParser() +try: + config.read("./cfg/pyAggr3g470r.cfg") +except: + config.read("./cfg/pyAggr3g470r.cfg-sample") +path = os.path.abspath(".") + +MONGODB_ADDRESS = config.get('MongoDB', 'address') +MONGODB_PORT = int(config.get('MongoDB', 'port')) +MONGODB_USER = config.get('MongoDB', 'user') +MONGODB_PASSWORD = config.get('MongoDB', 'password') + +MAX_NB_ARTICLES = int(config.get('global', 'max_nb_articles')) + +mail_from = config.get('mail','mail_from') +mail_to = config.get('mail','mail_to') +smtp_server = config.get('mail','smtp') +username = config.get('mail','username') +password = config.get('mail','password') + +DIASPORA_POD = config.get('misc', 'diaspora_pod') + +# regular expression to chech URL +url_finders = [ \ + re.compile("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\),\\\"]"), \ + re.compile("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?"), \ + re.compile("(~/|/|\\./)([-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]|\\\\)+"), \ + re.compile("'\\<((mailto:)|)[-A-Za-z0-9\\.]+@[-A-Za-z0-9\\.]+"), \ +] + +def detect_url_errors(list_of_urls): + """ + Detect URL errors. + Return a list of error(s). + """ + errors = [] + for url in list_of_urls: + req = urllib2.Request(url) + try: + urllib2.urlopen(req) + except urllib2.HTTPError, e: + # server couldn't fulfill the request + errors.append((url, e.code, \ + BaseHTTPServer.BaseHTTPRequestHandler.responses[e.code][1])) + except urllib2.URLError, e: + # failed to reach the server + errors.append((url, e.reason.errno ,e.reason.strerror)) + return errors + +def clear_string(data): + """ + Clear a string by removing HTML tags, HTML special caracters + and consecutive white spaces (more that one). + """ + p = re.compile(r'<[^<]*?/?>') # HTML tags + q = re.compile(r'\s') # consecutive white spaces + return p.sub('', q.sub(' ', data)) + +def unescape(text): + """ + Removes HTML or XML character references and entities from a text string. + """ + def fixup(m): + text = m.group(0) + if text[:2] == "&#": + # character reference + try: + if text[:3] == "&#x": + return unichr(int(text[3:-1], 16)) + else: + return unichr(int(text[2:-1])) + except ValueError: + pass + else: + # named entity + try: + text = unichr(htmlentitydefs.name2codepoint[text[1:-1]]) + except KeyError: + pass + return text # leave as is + return re.sub("&#?\w+;", fixup, text) + +def not_combining(char): + return unicodedata.category(char) != 'Mn' + +def strip_accents(text, encoding): + """ + Strip accents. + + >>> print strip_accents("déjà", "utf-8") + deja + """ + unicode_text= unicodedata.normalize('NFD', text.decode(encoding)) + return filter(not_combining, unicode_text).encode(encoding) + +def normalize_filename(name): + """ + Normalize a file name. + """ + file_name = re.sub("[,'!?|&]", "", name) + file_name = re.sub("[\s.]", "_", file_name) + file_name = file_name.strip('_') + file_name = file_name.strip('.') + file_name = strip_accents(file_name, "utf-8") + return os.path.normpath(file_name) + +def top_words(articles, n=10, size=5): + """ + Return the n most frequent words in a list. + """ + words = Counter() + wordre = re.compile(r'\b\w{%s,}\b' % size, re.I) + for article in articles: + for word in wordre.findall(clear_string(article["article_content"])): + words[word.lower()] += 1 + return words.most_common(n) + +def tag_cloud(tags, query="word_count"): + """ + Generates a tags cloud. + """ + tags.sort(key=operator.itemgetter(0)) + if query == "word_count": + # tags cloud from the management page + return ' '.join([('%s\n' % \ + (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), word, count, word)) \ + for (word, count) in tags]) + if query == "year": + # tags cloud for the history + return ' '.join([('%s\n' % \ + (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), query, word, count, word)) \ + for (word, count) in tags]) + return ' '.join([('%s\n' % \ + (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), query, word, count, calendar.month_name[int(word)])) \ + for (word, count) in tags]) + +def send_mail(mfrom, mto, feed_title, article_title, description): + """ + Send the article via mail. + """ + # Create the body of the message (a plain-text and an HTML version). + html = """\n\n%s\n\n\n%s\n\n""" % \ + (feed_title + ": " + article_title, description) + text = clear_string(description) + + # Create message container - the correct MIME type is multipart/alternative. + msg = MIMEMultipart('alternative') + msg['Subject'] = '[pyAggr3g470r] ' + feed_title + ": " + article_title + msg['From'] = mfrom + msg['To'] = mto + + # Record the MIME types of both parts - text/plain and text/html. + part1 = MIMEText(text, 'plain') + part2 = MIMEText(html, 'html') + + # Attach parts into message container. + # According to RFC 2046, the last part of a multipart message, in this case + # the HTML message, is best and preferred. + msg.attach(part1) + msg.attach(part2) + + # Send the message via local SMTP server. + s = smtplib.SMTP(smtp_server) + s.login(username, password) + # sendmail function takes 3 arguments: sender's address, recipient's address + # and message to send - here it is sent as one string. + s.sendmail(mfrom, mto, msg.as_string()) + s.quit() + +def string_to_datetime(stringtime): + """ + Convert a string to datetime. + """ + date, time = stringtime.split(' ') + year, month, day = date.split('-') + hour, minute, second = time.split(':') + return datetime(year=int(year), month=int(month), day=int(day), \ + hour=int(hour), minute=int(minute), second=int(second)) + +def compare(stringtime1, stringtime2): + """ + Compare two dates in the format 'yyyy-mm-dd hh:mm:ss'. + """ + datetime1 = string_to_datetime(stringtime1) + datetime2 = string_to_datetime(stringtime2) + if datetime1 < datetime2: + return -1 + elif datetime1 > datetime2: + return 1 + return 0 + +def add_feed(feed_url): + """ + Add the URL feed_url in the file feed.lst. + """ + if os.path.exists("./var/feed.lst"): + for line in open("./var/feed.lst", "r"): + if feed_url in line: + # if the feed is already in the file + return False + with open("./var/feed.lst", "a") as f: + f.write(feed_url + "\n") + return True + +def change_feed_url(old_feed_url, new_feed_url): + """ + Change the URL of a feed given in parameter. + """ + # 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 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 change_feed_logo(feed_url, new_feed_logo): + """ + Change the logo of a feed given in parameter. + """ + try: + conn = sqlite3.connect(sqlite_base, isolation_level = None) + c = conn.cursor() + c.execute('UPDATE feeds SET feed_image_link="' + new_feed_logo + '" 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. + """ + feeds = [] + # Remove the URL from the file feed.lst + if os.path.exists("./var/feed.lst"): + for line in open("./var/feed.lst", "r"): + if feed_url not in line: + feeds.append(line.replace("\n", "")) + with open("./var/feed.lst", "w") as f: + f.write("\n".join(feeds) + "\n") + +def search_feed(url): + """ + Search a feed in a HTML page. + """ + soup = None + try: + page = urllib2.urlopen(url) + soup = BeautifulSoup(page) + except: + return None + feed_links = soup('link', type='application/atom+xml') + feed_links.extend(soup('link', type='application/rss+xml')) + for feed_link in feed_links: + if url not in feed_link['href']: + return urlparse.urljoin(url, feed_link['href']) + return feed_link['href'] + return None \ No newline at end of file diff --git a/source/var/feed.lst b/source/var/feed.lst new file mode 100755 index 00000000..51cd1936 --- /dev/null +++ b/source/var/feed.lst @@ -0,0 +1,37 @@ +http://feeds2.feedburner.com/diveintomark/all +http://www.foo.be/cgi-bin/wiki.pl?action=journal&tile=AdulauMessyDesk +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/news.atom +http://rss.slashdot.org/Slashdot/slashdot +http://theinvisiblethings.blogspot.com/feeds/posts/default +http://torvalds-family.blogspot.com/feeds/posts/default +http://www.python.org/channews.rdf +http://www.kde.org/dotkdeorg.rdf +http://feeds.feedburner.com/internetactu/bcmJ +http://www.april.org/fr/rss.xml +http://www.framablog.org/index.php/feed/atom +http://tarekziade.wordpress.com/feed/ +http://formats-ouverts.org/rss.php +http://lwn.net/headlines/newrss +http://kernelnewbies.org/RecentChanges?action=rss_rc&ddiffs=1&unique=1 +http://www.kroah.com/log/index.rss +http://www.lessentiel.lu/rss/news.tmpl +http://www.jeffersonswheel.org/?feed=rss2 +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/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 +http://python-history.blogspot.com/feeds/posts/default +http://www.haypocalc.com/wordpress/feed +http://www.crypto.com/blog/rss10.xml +http://spaf.wordpress.com/feed/ +http://neopythonic.blogspot.com/feeds/posts/default +http://www.quuxlabs.com/feed/ +http://etbe.coker.com.au/feed/ diff --git a/sqlite2mongo.py b/sqlite2mongo.py deleted file mode 100644 index 633fb8f9..00000000 --- a/sqlite2mongo.py +++ /dev/null @@ -1,78 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf-8 -*- - -import hashlib -import sqlite3 -import mongodb - -import utils - -from datetime import datetime - -SQLITE_BASE = "./var/feed.db" - - -def sqlite2mongo(): - """ - Load feeds and articles in a dictionary. - """ - mongo = mongodb.Articles() - list_of_feeds = [] - list_of_articles = [] - - try: - conn = sqlite3.connect(SQLITE_BASE, isolation_level = None) - c = conn.cursor() - list_of_feeds = c.execute("SELECT * FROM feeds").fetchall() - except: - pass - - if list_of_feeds != []: - # Walk through the list of feeds - for feed in list_of_feeds: - try: - list_of_articles = c.execute(\ - "SELECT * FROM articles WHERE feed_link='" + \ - feed[2] + "'").fetchall() - except: - continue - sha1_hash = hashlib.sha1() - sha1_hash.update(feed[2].encode('utf-8')) - feed_id = sha1_hash.hexdigest() - - new_collection = {"feed_id" : feed_id.encode('utf-8'), \ - "type": 0, \ - "feed_image" : feed[3].encode('utf-8'), \ - "feed_title" : feed[0].encode('utf-8'), \ - "feed_link" : feed[2].encode('utf-8'), \ - "site_link" : feed[1].encode('utf-8'), \ - "mail" : feed[4]=="1"} - - mongo.add_collection(new_collection) - - if list_of_articles != []: - # Walk through the list of articles for the current feed. - articles = [] - for article in list_of_articles: - sha1_hash = hashlib.sha1() - sha1_hash.update(article[2].encode('utf-8')) - article_id = sha1_hash.hexdigest() - - article = {"article_id": article_id.encode('utf-8'), \ - "type":1, \ - "article_date": utils.string_to_datetime(article[0]), \ - "article_link": article[2].encode('utf-8'), \ - "article_title": article[1].encode('utf-8'), \ - "article_content": article[3].encode('utf-8'), \ - "article_readed": article[4]=="1", \ - "article_like": article[6]=="1" \ - } - - articles.append(article) - - mongo.add_articles(articles, feed_id) - - c.close() - -if __name__ == "__main__": - sqlite2mongo() \ No newline at end of file diff --git a/utils.py b/utils.py deleted file mode 100755 index c23b8794..00000000 --- a/utils.py +++ /dev/null @@ -1,351 +0,0 @@ -#! /usr/bin/env python -#-*- coding: utf-8 -*- - -# pyAggr3g470r - A Web based news aggregator. -# Copyright (C) 2010 Cédric Bonhomme - http://cedricbonhomme.org/ -# -# For more information : http://bitbucket.org/cedricbonhomme/pyaggr3g470r/ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see - -__author__ = "Cedric Bonhomme" -__version__ = "$Revision: 1.2 $" -__date__ = "$Date: 2010/12/07 $" -__revision__ = "$Date: 2011/04/15 $" -__copyright__ = "Copyright (c) Cedric Bonhomme" -__license__ = "GPLv3" - -# -# This file provides functions used for: -# - the database management; -# - generation of tags cloud; -# - HTML processing; -# - mail notifications. -# - -import re -import hashlib -import sqlite3 -import operator -import urlparse -import calendar -import unicodedata -import htmlentitydefs - -import smtplib -from email.mime.multipart import MIMEMultipart -from email.mime.text import MIMEText - -import urllib2 -import BaseHTTPServer -from BeautifulSoup import BeautifulSoup - -from datetime import datetime -from string import punctuation -from collections import Counter -from collections import OrderedDict - -from StringIO import StringIO - -import threading -LOCKER = threading.Lock() - -import os -import ConfigParser -# load the configuration -config = ConfigParser.RawConfigParser() -try: - config.read("./cfg/pyAggr3g470r.cfg") -except: - config.read("./cfg/pyAggr3g470r.cfg-sample") -path = os.path.abspath(".") - -MONGODB_ADDRESS = config.get('MongoDB', 'address') -MONGODB_PORT = int(config.get('MongoDB', 'port')) -MONGODB_USER = config.get('MongoDB', 'user') -MONGODB_PASSWORD = config.get('MongoDB', 'password') - -MAX_NB_ARTICLES = int(config.get('global', 'max_nb_articles')) - -mail_from = config.get('mail','mail_from') -mail_to = config.get('mail','mail_to') -smtp_server = config.get('mail','smtp') -username = config.get('mail','username') -password = config.get('mail','password') - -DIASPORA_POD = config.get('misc', 'diaspora_pod') - -# regular expression to chech URL -url_finders = [ \ - re.compile("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\),\\\"]"), \ - re.compile("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?"), \ - re.compile("(~/|/|\\./)([-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]|\\\\)+"), \ - re.compile("'\\<((mailto:)|)[-A-Za-z0-9\\.]+@[-A-Za-z0-9\\.]+"), \ -] - -def detect_url_errors(list_of_urls): - """ - Detect URL errors. - Return a list of error(s). - """ - errors = [] - for url in list_of_urls: - req = urllib2.Request(url) - try: - urllib2.urlopen(req) - except urllib2.HTTPError, e: - # server couldn't fulfill the request - errors.append((url, e.code, \ - BaseHTTPServer.BaseHTTPRequestHandler.responses[e.code][1])) - except urllib2.URLError, e: - # failed to reach the server - errors.append((url, e.reason.errno ,e.reason.strerror)) - return errors - -def clear_string(data): - """ - Clear a string by removing HTML tags, HTML special caracters - and consecutive white spaces (more that one). - """ - p = re.compile(r'<[^<]*?/?>') # HTML tags - q = re.compile(r'\s') # consecutive white spaces - return p.sub('', q.sub(' ', data)) - -def unescape(text): - """ - Removes HTML or XML character references and entities from a text string. - """ - def fixup(m): - text = m.group(0) - if text[:2] == "&#": - # character reference - try: - if text[:3] == "&#x": - return unichr(int(text[3:-1], 16)) - else: - return unichr(int(text[2:-1])) - except ValueError: - pass - else: - # named entity - try: - text = unichr(htmlentitydefs.name2codepoint[text[1:-1]]) - except KeyError: - pass - return text # leave as is - return re.sub("&#?\w+;", fixup, text) - -def not_combining(char): - return unicodedata.category(char) != 'Mn' - -def strip_accents(text, encoding): - """ - Strip accents. - - >>> print strip_accents("déjà", "utf-8") - deja - """ - unicode_text= unicodedata.normalize('NFD', text.decode(encoding)) - return filter(not_combining, unicode_text).encode(encoding) - -def normalize_filename(name): - """ - Normalize a file name. - """ - file_name = re.sub("[,'!?|&]", "", name) - file_name = re.sub("[\s.]", "_", file_name) - file_name = file_name.strip('_') - file_name = file_name.strip('.') - file_name = strip_accents(file_name, "utf-8") - return os.path.normpath(file_name) - -def top_words(articles, n=10, size=5): - """ - Return the n most frequent words in a list. - """ - words = Counter() - wordre = re.compile(r'\b\w{%s,}\b' % size, re.I) - for article in articles: - for word in wordre.findall(clear_string(article["article_content"])): - words[word.lower()] += 1 - return words.most_common(n) - -def tag_cloud(tags, query="word_count"): - """ - Generates a tags cloud. - """ - tags.sort(key=operator.itemgetter(0)) - if query == "word_count": - # tags cloud from the management page - return ' '.join([('%s\n' % \ - (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), word, count, word)) \ - for (word, count) in tags]) - if query == "year": - # tags cloud for the history - return ' '.join([('%s\n' % \ - (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), query, word, count, word)) \ - for (word, count) in tags]) - return ' '.join([('%s\n' % \ - (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), query, word, count, calendar.month_name[int(word)])) \ - for (word, count) in tags]) - -def send_mail(mfrom, mto, feed_title, article_title, description): - """ - Send the article via mail. - """ - # Create the body of the message (a plain-text and an HTML version). - html = """\n\n%s\n\n\n%s\n\n""" % \ - (feed_title + ": " + article_title, description) - text = clear_string(description) - - # Create message container - the correct MIME type is multipart/alternative. - msg = MIMEMultipart('alternative') - msg['Subject'] = '[pyAggr3g470r] ' + feed_title + ": " + article_title - msg['From'] = mfrom - msg['To'] = mto - - # Record the MIME types of both parts - text/plain and text/html. - part1 = MIMEText(text, 'plain') - part2 = MIMEText(html, 'html') - - # Attach parts into message container. - # According to RFC 2046, the last part of a multipart message, in this case - # the HTML message, is best and preferred. - msg.attach(part1) - msg.attach(part2) - - # Send the message via local SMTP server. - s = smtplib.SMTP(smtp_server) - s.login(username, password) - # sendmail function takes 3 arguments: sender's address, recipient's address - # and message to send - here it is sent as one string. - s.sendmail(mfrom, mto, msg.as_string()) - s.quit() - -def string_to_datetime(stringtime): - """ - Convert a string to datetime. - """ - date, time = stringtime.split(' ') - year, month, day = date.split('-') - hour, minute, second = time.split(':') - return datetime(year=int(year), month=int(month), day=int(day), \ - hour=int(hour), minute=int(minute), second=int(second)) - -def compare(stringtime1, stringtime2): - """ - Compare two dates in the format 'yyyy-mm-dd hh:mm:ss'. - """ - datetime1 = string_to_datetime(stringtime1) - datetime2 = string_to_datetime(stringtime2) - if datetime1 < datetime2: - return -1 - elif datetime1 > datetime2: - return 1 - return 0 - -def add_feed(feed_url): - """ - Add the URL feed_url in the file feed.lst. - """ - if os.path.exists("./var/feed.lst"): - for line in open("./var/feed.lst", "r"): - if feed_url in line: - # if the feed is already in the file - return False - with open("./var/feed.lst", "a") as f: - f.write(feed_url + "\n") - return True - -def change_feed_url(old_feed_url, new_feed_url): - """ - Change the URL of a feed given in parameter. - """ - # 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 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 change_feed_logo(feed_url, new_feed_logo): - """ - Change the logo of a feed given in parameter. - """ - try: - conn = sqlite3.connect(sqlite_base, isolation_level = None) - c = conn.cursor() - c.execute('UPDATE feeds SET feed_image_link="' + new_feed_logo + '" 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. - """ - feeds = [] - # Remove the URL from the file feed.lst - if os.path.exists("./var/feed.lst"): - for line in open("./var/feed.lst", "r"): - if feed_url not in line: - feeds.append(line.replace("\n", "")) - with open("./var/feed.lst", "w") as f: - f.write("\n".join(feeds) + "\n") - -def search_feed(url): - """ - Search a feed in a HTML page. - """ - soup = None - try: - page = urllib2.urlopen(url) - soup = BeautifulSoup(page) - except: - return None - feed_links = soup('link', type='application/atom+xml') - feed_links.extend(soup('link', type='application/rss+xml')) - for feed_link in feed_links: - if url not in feed_link['href']: - return urlparse.urljoin(url, feed_link['href']) - return feed_link['href'] - return None \ No newline at end of file diff --git a/var/feed.lst b/var/feed.lst deleted file mode 100755 index 51cd1936..00000000 --- a/var/feed.lst +++ /dev/null @@ -1,37 +0,0 @@ -http://feeds2.feedburner.com/diveintomark/all -http://www.foo.be/cgi-bin/wiki.pl?action=journal&tile=AdulauMessyDesk -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/news.atom -http://rss.slashdot.org/Slashdot/slashdot -http://theinvisiblethings.blogspot.com/feeds/posts/default -http://torvalds-family.blogspot.com/feeds/posts/default -http://www.python.org/channews.rdf -http://www.kde.org/dotkdeorg.rdf -http://feeds.feedburner.com/internetactu/bcmJ -http://www.april.org/fr/rss.xml -http://www.framablog.org/index.php/feed/atom -http://tarekziade.wordpress.com/feed/ -http://formats-ouverts.org/rss.php -http://lwn.net/headlines/newrss -http://kernelnewbies.org/RecentChanges?action=rss_rc&ddiffs=1&unique=1 -http://www.kroah.com/log/index.rss -http://www.lessentiel.lu/rss/news.tmpl -http://www.jeffersonswheel.org/?feed=rss2 -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/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 -http://python-history.blogspot.com/feeds/posts/default -http://www.haypocalc.com/wordpress/feed -http://www.crypto.com/blog/rss10.xml -http://spaf.wordpress.com/feed/ -http://neopythonic.blogspot.com/feeds/posts/default -http://www.quuxlabs.com/feed/ -http://etbe.coker.com.au/feed/ -- cgit