diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index b1be656..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,82 +0,0 @@ -## Contributing to Shaarli (community repository) - -### Bugs and feature requests -**Reporting bugs, feature requests: issues management** - -You can look through existing bugs/requests and help reporting them [here](https://github.com/shaarli/Shaarli/issues). - -Constructive input/experience reports/helping other users is welcome. - -The general guideline of the fork is to keep Shaarli simple (project and code maintenance, and features-wise), while providing customization capabilities (plugin system, making more settings configurable). - -Check the [milestones](https://github.com/shaarli/Shaarli/milestones) to see what issues have priority. - - * The issues list should preferably contain **only tasks that can be actioned immediately**. Anyone should be able to open the issues list, pick one and start working on it immediately. - * If you have a clear idea of a **feature you expect, or have a specific bug/defect to report**, [search the issues list, both open and closed](https://github.com/shaarli/Shaarli/issues?q=is%3Aissue) to check if it has been discussed, and comment on the appropriate issue. If you can't find one, please open a [new issue](https://github.com/shaarli/Shaarli/issues/new) - * **General discussions** fit in #44 so that we don't follow a slope where users and contributors have to track 90 "maybe" items in the bug tracker. Separate issues about clear, separate steps can be opened after discussion. - * You can also join instant discussion at https://gitter.im/shaarli/Shaarli, or via IRC as described [here](https://github.com/shaarli/Shaarli/issues/44#issuecomment-77745105) - -### Documentation -**the [wiki](https://github.com/shaarli/Shaarli/wiki) is world-writable** - anyone can edit or add chapters and pages. - - * Large changes should preferably be discussed in [General discussion](https://github.com/shaarli/Shaarli/issues/44) beforehand (you can post a draft there and edit it). - * If you create a new page, please link it from the new page (eg from the [Other links](https://github.com/shaarli/Shaarli/wiki#other-links) section. - * The wiki is a general documentation about Shaarli: usage, development, hacks, usage tricks, related links, projects. Try to keep it organized. - * The wiki will be synced to Shaarli's `doc/` directory on each release. Keep that in mind when reviewing the quality of your edits. - -You can make the project known by publishing blog posts/articles/videos about it and adding them to the links section in the wiki. - -### Translations -Currently Shaarli has no translation/internationalization/localization system available and is single-language. You can help by proposing an i18n system (issue https://github.com/shaarli/Shaarli/issues/121) - -### Beta testing -You can help testing Shaarli releases by immediately upgrading your installation after a [new version has been releases](https://github.com/shaarli/Shaarli/releases). - -All current development happens in [Pull Requests](https://github.com/shaarli/Shaarli/pulls). You can test proposed patches by cloning the Shaarli repo, adding the Pull Request branch and `git checkout` to it. You can also merge multiple Pull Requests to a testing branch. - -```bash -git clone https://github.com/shaarli/Shaarli -git remote add pull-request-25 owner/cool-new-feature -git remote add pull-request-26 anotherowner/bugfix -git remote update -git checkout -b testing -git merge cool-new-feature -git merge bugfix -``` -Or see [Checkout Github Pull Requests locally](https://gist.github.com/piscisaureus/3342247) - -Please report any problem you might find. - - -### Contributing code - -#### Adding your own changes - - * Pick or open an issue - * Fork the Shaarli repository on github - * `git clone` your fork - * starting from branch ` master`, switch to a new branch (eg. `git checkout -b my-awesome-feature`) - * edit the required files (from the Github web interface or your text editor) - * add and commit your changes with a meaningful commit message (eg `Cool new feature, fixes issue #1001`) - * run unit tests against your patched version, see [Running unit tests](https://github.com/shaarli/Shaarli/wiki/Running-unit-tests) - * Open your fork in the Github web interface and click the "Compare and Pull Request" button, enter required info and submit your Pull Request. - -All changes you will do on the `my-awesome-feature` in the future will be added to your Pull Request. Don't work directly on the master branch, don't do unrelated work on your `my-awesome-feature` branch. - -#### Contributing to an existing Pull Request - -TODO - -#### Useful links -If you are not familiar with Git or Github, here are a few links to set you on track: - - * https://try.github.io/ - 10 minutes Github workflow interactive tutorial - * http://ndpsoftware.com/git-cheatsheet.html - A Git cheatsheet - * http://www.wei-wang.com/ExplainGitWithD3 - Helps you understand some basic Git concepts visually - * https://www.atlassian.com/git/tutorial - Git tutorials - * https://www.atlassian.com/git/workflows - Git workflows - * http://git-scm.com/book - The official Git book, multiple languages - * http://www.vogella.com/tutorials/Git/article.html - Git tutorials - * http://think-like-a-git.net/resources.html - Guide to Git - * http://gitready.com/ - medium to advanced Git docs/tips/blog/articles - * https://github.com/btford/participating-in-open-source - Participating in Open Source diff --git a/COPYING b/COPYING deleted file mode 100644 index 2893910..0000000 --- a/COPYING +++ /dev/null @@ -1,816 +0,0 @@ -Files: * -License: zlib/libpng -Copyright: (c) 2011-2015 Sébastien SAUVAGE - (c) 2011-2015 Alexandre Alapetite - (c) 2011-2015 David Sferruzza - (c) 2011-2015 Christophe HENRY - (c) 2011-2015 Mathieu Chabanon - (c) 2011-2015 BoboTiG - (c) 2011-2015 Bronco - (c) 2011-2015 Emilien Klein - (c) 2011-2015 Knah Tsaeb - (c) 2011-2015 Lionel Martin - (c) 2011-2015 lehollandaisvolant - (c) 2011-2015 timo van neerden - (c) 2011-2015 nodiscc - (c) 2011-2015 Florian Eula - (c) 2011-2015 Arthur Hoaro - (c) 2011-2015 Aurélien "VirtualTam" Tamisier - (c) 2011-2015 qwertygc - (c) 2011-2015 idleman - (c) 2015 Alexis Ju - (c) 2015 dimtion - (c) 2015 Fanch - (c) 2015 Guillaume Virlet - (c) 2015 Felix Bartels - (c) 2015 Marsup - (c) 2015 Miloš Jovanović - (c) 2015 Nicolás Danelón - (c) 2015 TsT - - -Files: inc/reset.css -License: BSD (http://opensource.org/licenses/BSD-3-Clause) -Copyright: (c) 2010, Yahoo! Inc. - -Files: images/calendar.png, images/edit_icon.png, images/feed-icon-14x14.png, images/private.png, images/private_16x16.png, images/private_16x16_active.png, images/tag_blue.png -License: CC-BY (http://creativecommons.org/licenses/by/3.0/) -Copyright: (c) 2014 Yusuke Kamiyamane -Source: http://p.yusukekamiyamane.com/ - -Files: images/delete_icon.png -License: CC-BY (http://creativecommons.org/licenses/by/3.0/) -Copyright: (c) 2014 Designmodo -Source: http://designmodo.com/linecons-free/ - -Files: images/floral_left.png, images/floral_right.png, images/squiggle.png, images/squiggle2.png, images/squiggle_closing.png -Licence: Public Domain -Source: https://openclipart.org/people/j4p4n/j4p4n_ornimental_bookend_-_left.svg - -Files: images/Paper_texture_v5_by_bashcorpo_w1000.jpg -Licence: Public Domain -Source: http://bashcorpo.deviantart.com/art/Grungy-paper-texture-v-5-22966998 - -Files: images/logo.png -License: zlib/libpng -Copyright: (c) 2011-2014 idleman idleman@idleman.fr - -Files: inc/blazy*.js -License: MIT License (http://opensource.org/licenses/MIT) -Copyright: (C) Bjoern Klinggaard - @bklinggaard - http://dinbror.dk/blazy - -Files: inc/rain.tpl.class.php -Copyright: 2011-2012, Federico Ulfo - 2011-2012, The Rain Team -License: LGPL-3+ (https://www.gnu.org/licenses/lgpl-3.0.txt) - -Files: inc/awesomplete* -License: MIT License (http://opensource.org/licenses/MIT) -Copyright: (C) 2015 Lea Verou - https://github.com/LeaVerou/awesomplete - -Files: plugins/wallabag/wallabag.png -License: MIT License (http://opensource.org/licenses/MIT) -Copyright: (C) 2015 Nicolas Lœuillet - https://github.com/wallabag/wallabag - -Files: plugins/markdown/Parsedown.php -License: MIT License (http://opensource.org/licenses/MIT) -Copyright: (C) 2015 Emanuil Rusev - https://github.com/erusev/parsedown - ----------------------------------------------------- -ZLIB/LIBPNG LICENSE - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from -the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would - be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must - not be misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source distribution. - ----------------------------------------------------- -GPLv3 LICENSE - -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. - ----------------------------------------------------- -MIT LICENSE - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - ----------------------------------------------------- -Creative Commons License (CC-BY 3.0) -Creative Commons Legal Code - -Attribution 3.0 Unported - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR - DAMAGES RESULTING FROM ITS USE. - -License - -THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE -COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY -COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS -AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. - -BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE -TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY -BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS -CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND -CONDITIONS. - -1. Definitions - - a. "Adaptation" means a work based upon the Work, or upon the Work and - other pre-existing works, such as a translation, adaptation, - derivative work, arrangement of music or other alterations of a - literary or artistic work, or phonogram or performance and includes - cinematographic adaptations or any other form in which the Work may be - recast, transformed, or adapted including in any form recognizably - derived from the original, except that a work that constitutes a - Collection will not be considered an Adaptation for the purpose of - this License. For the avoidance of doubt, where the Work is a musical - work, performance or phonogram, the synchronization of the Work in - timed-relation with a moving image ("synching") will be considered an - Adaptation for the purpose of this License. - b. "Collection" means a collection of literary or artistic works, such as - encyclopedias and anthologies, or performances, phonograms or - broadcasts, or other works or subject matter other than works listed - in Section 1(f) below, which, by reason of the selection and - arrangement of their contents, constitute intellectual creations, in - which the Work is included in its entirety in unmodified form along - with one or more other contributions, each constituting separate and - independent works in themselves, which together are assembled into a - collective whole. A work that constitutes a Collection will not be - considered an Adaptation (as defined above) for the purposes of this - License. - c. "Distribute" means to make available to the public the original and - copies of the Work or Adaptation, as appropriate, through sale or - other transfer of ownership. - d. "Licensor" means the individual, individuals, entity or entities that - offer(s) the Work under the terms of this License. - e. "Original Author" means, in the case of a literary or artistic work, - the individual, individuals, entity or entities who created the Work - or if no individual or entity can be identified, the publisher; and in - addition (i) in the case of a performance the actors, singers, - musicians, dancers, and other persons who act, sing, deliver, declaim, - play in, interpret or otherwise perform literary or artistic works or - expressions of folklore; (ii) in the case of a phonogram the producer - being the person or legal entity who first fixes the sounds of a - performance or other sounds; and, (iii) in the case of broadcasts, the - organization that transmits the broadcast. - f. "Work" means the literary and/or artistic work offered under the terms - of this License including without limitation any production in the - literary, scientific and artistic domain, whatever may be the mode or - form of its expression including digital form, such as a book, - pamphlet and other writing; a lecture, address, sermon or other work - of the same nature; a dramatic or dramatico-musical work; a - choreographic work or entertainment in dumb show; a musical - composition with or without words; a cinematographic work to which are - assimilated works expressed by a process analogous to cinematography; - a work of drawing, painting, architecture, sculpture, engraving or - lithography; a photographic work to which are assimilated works - expressed by a process analogous to photography; a work of applied - art; an illustration, map, plan, sketch or three-dimensional work - relative to geography, topography, architecture or science; a - performance; a broadcast; a phonogram; a compilation of data to the - extent it is protected as a copyrightable work; or a work performed by - a variety or circus performer to the extent it is not otherwise - considered a literary or artistic work. - g. "You" means an individual or entity exercising rights under this - License who has not previously violated the terms of this License with - respect to the Work, or who has received express permission from the - Licensor to exercise rights under this License despite a previous - violation. - h. "Publicly Perform" means to perform public recitations of the Work and - to communicate to the public those public recitations, by any means or - process, including by wire or wireless means or public digital - performances; to make available to the public Works in such a way that - members of the public may access these Works from a place and at a - place individually chosen by them; to perform the Work to the public - by any means or process and the communication to the public of the - performances of the Work, including by public digital performance; to - broadcast and rebroadcast the Work by any means including signs, - sounds or images. - i. "Reproduce" means to make copies of the Work by any means including - without limitation by sound or visual recordings and the right of - fixation and reproducing fixations of the Work, including storage of a - protected performance or phonogram in digital form or other electronic - medium. - -2. Fair Dealing Rights. Nothing in this License is intended to reduce, -limit, or restrict any uses free from copyright or rights arising from -limitations or exceptions that are provided for in connection with the -copyright protection under copyright law or other applicable laws. - -3. License Grant. Subject to the terms and conditions of this License, -Licensor hereby grants You a worldwide, royalty-free, non-exclusive, -perpetual (for the duration of the applicable copyright) license to -exercise the rights in the Work as stated below: - - a. to Reproduce the Work, to incorporate the Work into one or more - Collections, and to Reproduce the Work as incorporated in the - Collections; - b. to create and Reproduce Adaptations provided that any such Adaptation, - including any translation in any medium, takes reasonable steps to - clearly label, demarcate or otherwise identify that changes were made - to the original Work. For example, a translation could be marked "The - original work was translated from English to Spanish," or a - modification could indicate "The original work has been modified."; - c. to Distribute and Publicly Perform the Work including as incorporated - in Collections; and, - d. to Distribute and Publicly Perform Adaptations. - e. For the avoidance of doubt: - - i. Non-waivable Compulsory License Schemes. In those jurisdictions in - which the right to collect royalties through any statutory or - compulsory licensing scheme cannot be waived, the Licensor - reserves the exclusive right to collect such royalties for any - exercise by You of the rights granted under this License; - ii. Waivable Compulsory License Schemes. In those jurisdictions in - which the right to collect royalties through any statutory or - compulsory licensing scheme can be waived, the Licensor waives the - exclusive right to collect such royalties for any exercise by You - of the rights granted under this License; and, - iii. Voluntary License Schemes. The Licensor waives the right to - collect royalties, whether individually or, in the event that the - Licensor is a member of a collecting society that administers - voluntary licensing schemes, via that society, from any exercise - by You of the rights granted under this License. - -The above rights may be exercised in all media and formats whether now -known or hereafter devised. The above rights include the right to make -such modifications as are technically necessary to exercise the rights in -other media and formats. Subject to Section 8(f), all rights not expressly -granted by Licensor are hereby reserved. - -4. Restrictions. The license granted in Section 3 above is expressly made -subject to and limited by the following restrictions: - - a. You may Distribute or Publicly Perform the Work only under the terms - of this License. You must include a copy of, or the Uniform Resource - Identifier (URI) for, this License with every copy of the Work You - Distribute or Publicly Perform. You may not offer or impose any terms - on the Work that restrict the terms of this License or the ability of - the recipient of the Work to exercise the rights granted to that - recipient under the terms of the License. You may not sublicense the - Work. You must keep intact all notices that refer to this License and - to the disclaimer of warranties with every copy of the Work You - Distribute or Publicly Perform. When You Distribute or Publicly - Perform the Work, You may not impose any effective technological - measures on the Work that restrict the ability of a recipient of the - Work from You to exercise the rights granted to that recipient under - the terms of the License. This Section 4(a) applies to the Work as - incorporated in a Collection, but this does not require the Collection - apart from the Work itself to be made subject to the terms of this - License. If You create a Collection, upon notice from any Licensor You - must, to the extent practicable, remove from the Collection any credit - as required by Section 4(b), as requested. If You create an - Adaptation, upon notice from any Licensor You must, to the extent - practicable, remove from the Adaptation any credit as required by - Section 4(b), as requested. - b. If You Distribute, or Publicly Perform the Work or any Adaptations or - Collections, You must, unless a request has been made pursuant to - Section 4(a), keep intact all copyright notices for the Work and - provide, reasonable to the medium or means You are utilizing: (i) the - name of the Original Author (or pseudonym, if applicable) if supplied, - and/or if the Original Author and/or Licensor designate another party - or parties (e.g., a sponsor institute, publishing entity, journal) for - attribution ("Attribution Parties") in Licensor's copyright notice, - terms of service or by other reasonable means, the name of such party - or parties; (ii) the title of the Work if supplied; (iii) to the - extent reasonably practicable, the URI, if any, that Licensor - specifies to be associated with the Work, unless such URI does not - refer to the copyright notice or licensing information for the Work; - and (iv) , consistent with Section 3(b), in the case of an Adaptation, - a credit identifying the use of the Work in the Adaptation (e.g., - "French translation of the Work by Original Author," or "Screenplay - based on original Work by Original Author"). The credit required by - this Section 4 (b) may be implemented in any reasonable manner; - provided, however, that in the case of a Adaptation or Collection, at - a minimum such credit will appear, if a credit for all contributing - authors of the Adaptation or Collection appears, then as part of these - credits and in a manner at least as prominent as the credits for the - other contributing authors. For the avoidance of doubt, You may only - use the credit required by this Section for the purpose of attribution - in the manner set out above and, by exercising Your rights under this - License, You may not implicitly or explicitly assert or imply any - connection with, sponsorship or endorsement by the Original Author, - Licensor and/or Attribution Parties, as appropriate, of You or Your - use of the Work, without the separate, express prior written - permission of the Original Author, Licensor and/or Attribution - Parties. - c. Except as otherwise agreed in writing by the Licensor or as may be - otherwise permitted by applicable law, if You Reproduce, Distribute or - Publicly Perform the Work either by itself or as part of any - Adaptations or Collections, You must not distort, mutilate, modify or - take other derogatory action in relation to the Work which would be - prejudicial to the Original Author's honor or reputation. Licensor - agrees that in those jurisdictions (e.g. Japan), in which any exercise - of the right granted in Section 3(b) of this License (the right to - make Adaptations) would be deemed to be a distortion, mutilation, - modification or other derogatory action prejudicial to the Original - Author's honor and reputation, the Licensor will waive or not assert, - as appropriate, this Section, to the fullest extent permitted by the - applicable national law, to enable You to reasonably exercise Your - right under Section 3(b) of this License (right to make Adaptations) - but not otherwise. - -5. Representations, Warranties and Disclaimer - -UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR -OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY -KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, -INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, -FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF -LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, -WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION -OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. - -6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE -LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR -ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES -ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS -BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. Termination - - a. This License and the rights granted hereunder will terminate - automatically upon any breach by You of the terms of this License. - Individuals or entities who have received Adaptations or Collections - from You under this License, however, will not have their licenses - terminated provided such individuals or entities remain in full - compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will - survive any termination of this License. - b. Subject to the above terms and conditions, the license granted here is - perpetual (for the duration of the applicable copyright in the Work). - Notwithstanding the above, Licensor reserves the right to release the - Work under different license terms or to stop distributing the Work at - any time; provided, however that any such election will not serve to - withdraw this License (or any other license that has been, or is - required to be, granted under the terms of this License), and this - License will continue in full force and effect unless terminated as - stated above. - -8. Miscellaneous - - a. Each time You Distribute or Publicly Perform the Work or a Collection, - the Licensor offers to the recipient a license to the Work on the same - terms and conditions as the license granted to You under this License. - b. Each time You Distribute or Publicly Perform an Adaptation, Licensor - offers to the recipient a license to the original Work on the same - terms and conditions as the license granted to You under this License. - c. If any provision of this License is invalid or unenforceable under - applicable law, it shall not affect the validity or enforceability of - the remainder of the terms of this License, and without further action - by the parties to this agreement, such provision shall be reformed to - the minimum extent necessary to make such provision valid and - enforceable. - d. No term or provision of this License shall be deemed waived and no - breach consented to unless such waiver or consent shall be in writing - and signed by the party to be charged with such waiver or consent. - e. This License constitutes the entire agreement between the parties with - respect to the Work licensed here. There are no understandings, - agreements or representations with respect to the Work not specified - here. Licensor shall not be bound by any additional provisions that - may appear in any communication from You. This License may not be - modified without the mutual written agreement of the Licensor and You. - f. The rights granted under, and the subject matter referenced, in this - License were drafted utilizing the terminology of the Berne Convention - for the Protection of Literary and Artistic Works (as amended on - September 28, 1979), the Rome Convention of 1961, the WIPO Copyright - Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 - and the Universal Copyright Convention (as revised on July 24, 1971). - These rights and subject matter take effect in the relevant - jurisdiction in which the License terms are sought to be enforced - according to the corresponding provisions of the implementation of - those treaty provisions in the applicable national law. If the - standard suite of rights granted under applicable copyright law - includes additional rights not granted under this License, such - additional rights are deemed to be included in the License; this - License is not intended to restrict the license of any rights under - applicable law. - - -Creative Commons Notice - - Creative Commons is not a party to this License, and makes no warranty - whatsoever in connection with the Work. Creative Commons will not be - liable to You or any party on any legal theory for any damages - whatsoever, including without limitation any general, special, - incidental or consequential damages arising in connection to this - license. Notwithstanding the foregoing two (2) sentences, if Creative - Commons has expressly identified itself as the Licensor hereunder, it - shall have all rights and obligations of Licensor. - - Except for the limited purpose of indicating to the public that the - Work is licensed under the CCPL, Creative Commons does not authorize - the use by either party of the trademark "Creative Commons" or any - related trademark or logo of Creative Commons without the prior - written consent of Creative Commons. Any permitted use will be in - compliance with Creative Commons' then-current trademark usage - guidelines, as may be published on its website or otherwise made - available upon request from time to time. For the avoidance of doubt, - this trademark restriction does not form part of this License. - - Creative Commons may be contacted at https://creativecommons.org/. - - - ----------------------------------------------------- -BSD License - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ------------------------------------------------------- -LGPL License - - GNU LESSER 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. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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 -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/README.md b/README.md index 5d5b743..c205f4f 100644 --- a/README.md +++ b/README.md @@ -1,114 +1 @@ -![Shaarli logo](doc/images/doc-logo.png) - -The personal, minimalist, super-fast, database free, bookmarking service. - -_Do you want to share the links you discover?_ -_Shaarli is a minimalist delicious clone that you can install on your own server._ -_It is designed to be personal (single-user), fast and handy._ - -[![](https://img.shields.io/travis/shaarli/Shaarli.svg?label=master)](https://travis-ci.org/shaarli/Shaarli) -[![](https://img.shields.io/travis/shaarli/Shaarli/stable.svg?label=stable)](https://travis-ci.org/shaarli/Shaarli) -[![](https://img.shields.io/github/release/shaarli/shaarli.svg)](https://github.com/shaarli/Shaarli/releases/latest/) -[![Docker repository](https://img.shields.io/docker/pulls/shaarli/shaarli.svg)](https://hub.docker.com/r/shaarli/shaarli/) - -[![Join the chat at https://gitter.im/shaarli/Shaarli](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/shaarli/Shaarli) -[![Bountysource](https://www.bountysource.com/badge/team?team_id=19583&style=bounties_received)](https://www.bountysource.com/teams/shaarli/issues) - -## Quickstart -- [Wiki/documentation](https://github.com/shaarli/Shaarli/wiki) -- [Bugs/Feature requests/Discussion](https://github.com/shaarli/Shaarli/issues/) - -### Demo -You can use this [public demo instance of Shaarli](http://shaarlidemo.tuxfamily.org/Shaarli). -It runs the latest development version of Shaarli and is updated/reset daily. - -Login: `demo`; Password: `demo` - -### Installation & upgrade -- [Download and installation](https://github.com/shaarli/Shaarli/wiki/Download-and-Installation) -- [Upgrade and migration](https://github.com/shaarli/Shaarli/wiki/Upgrade-and-migration) -- [Server requirements](https://github.com/shaarli/Shaarli/wiki/Server-requirements) -- [Server configuration](https://github.com/shaarli/Shaarli/wiki/Server-configuration) -- [Shaarli configuration](https://github.com/shaarli/Shaarli/wiki/Shaarli-configuration) - -## Features -### Interface -- minimalist design (simple is beautiful) -- FAST -- ATOM and RSS feeds -- views: - - paginated link list - - tag cloud - - picture wall: image and video thumbnails - - daily: newspaper-like daily digest - - daily RSS feed -- permalinks for easy reference -- links can be public or private -- extensible through [plugins](https://github.com/shaarli/Shaarli/wiki/Plugins#plugin-usage) - -### Tag, view and search your links! -- add a custom title and description to archived links -- add tags to classify and search links - - features tag autocompletion, renaming, merging and deletion -- full-text and tag search - -### Easy setup -- dead-simple installation: drop the files, open the page -- links are stored in a file - - compact storage - - no database required - - easy backup: simply copy the datastore file -- import and export links as Netscape bookmarks - -### Accessibility -- Firefox bookmarlet to share links in one click -- support for mobile browsers -- works with Javascript disabled -- easy page customization through HTML/CSS/RainTPL - -### Security -- bruteforce-proof login form -- protected against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) -and session cookie hijacking - -### Goodies -- thumbnail generation for images and video services: -dailymotion, flickr, imageshack, imgur, vimeo, xkcd, youtube... - - lazy-loading with [bLazy](http://dinbror.dk/blazy/) -- [PubSubHubbub](https://code.google.com/p/pubsubhubbub/) protocol support -- URL cleanup: automatic removal of `?utm_source=...`, `fb=...` -- discreet pop-up notification when a new release is available - -### Other usages -Though Shaarli is primarily a bookmarking application, it can serve other purposes -(see [usage examples](https://github.com/shaarli/Shaarli/wiki#usage-examples)): -- micro-blogging -- pastebin -- online notepad -- snippet archive - -## About -### Shaarli community fork -This friendly fork is maintained by the Shaarli community at https://github.com/shaarli/Shaarli - -This is a community fork of the original [Shaarli](https://github.com/sebsauvage/Shaarli/) project by [Sébastien Sauvage](http://sebsauvage.net/). - -The original project is currently unmaintained, and the developer [has informed us](https://github.com/sebsauvage/Shaarli/issues/191) -that he would have no time to work on Shaarli in the near future. -The Shaarli community has carried on the work to provide -[many patches](https://github.com/shaarli/Shaarli/compare/sebsauvage:master...master) -for [bug fixes and enhancements](https://github.com/shaarli/Shaarli/issues?q=is%3Aclosed+) -in this repository, and will keep maintaining the project for the foreseeable future, while keeping Shaarli simple and efficient. - -### Contributing -If you'd like to help, please: -- have a look at the open [issues](https://github.com/shaarli/Shaarli/issues) -and [pull requests](https://github.com/shaarli/Shaarli/pulls) -- feel free to report bugs (feedback is much appreciated) -- suggest new features and improvements to both code and [documentation](https://github.com/shaarli/Shaarli/wiki) -- propose solutions to existing problems -- submit pull requests :-) - - -### License -Shaarli is [Free Software](http://en.wikipedia.org/wiki/Free_software). See [COPYING](COPYING) for a detail of the contributors and licenses for each individual component. +See https://salsa.debian.org/php-team/pear/shaarli diff --git a/application/.htaccess b/application/.htaccess deleted file mode 100644 index b584d98..0000000 --- a/application/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Allow from none -Deny from all diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php deleted file mode 100644 index e67b290..0000000 --- a/application/ApplicationUtils.php +++ /dev/null @@ -1,193 +0,0 @@ -'; - - /** - * Gets the latest version code from the Git repository - * - * The code is read from the raw content of the version file on the Git server. - * - * @return mixed the version code from the repository if available, else 'false' - */ - public static function getLatestGitVersionCode($url, $timeout=2) - { - list($headers, $data) = get_http_response($url, $timeout); - - if (strpos($headers[0], '200 OK') === false) { - error_log('Failed to retrieve ' . $url); - return false; - } - - return str_replace( - array(self::$VERSION_START_TAG, self::$VERSION_END_TAG, PHP_EOL), - array('', '', ''), - $data - ); - } - - /** - * Checks if a new Shaarli version has been published on the Git repository - * - * Updates checks are run periodically, according to the following criteria: - * - the update checks are enabled (install, global config); - * - the user is logged in (or this is an open instance); - * - the last check is older than a given interval; - * - the check is non-blocking if the HTTPS connection to Git fails; - * - in case of failure, the update file's modification date is updated, - * to avoid intempestive connection attempts. - * - * @param string $currentVersion the current version code - * @param string $updateFile the file where to store the latest version code - * @param int $checkInterval the minimum interval between update checks (in seconds - * @param bool $enableCheck whether to check for new versions - * @param bool $isLoggedIn whether the user is logged in - * - * @throws Exception an invalid branch has been set for update checks - * - * @return mixed the new version code if available and greater, else 'false' - */ - public static function checkUpdate($currentVersion, - $updateFile, - $checkInterval, - $enableCheck, - $isLoggedIn, - $branch='stable') - { - if (! $isLoggedIn) { - // Do not check versions for visitors - return false; - } - - if (empty($enableCheck)) { - // Do not check if the user doesn't want to - return false; - } - - if (is_file($updateFile) && (filemtime($updateFile) > time() - $checkInterval)) { - // Shaarli has checked for updates recently - skip HTTP query - $latestKnownVersion = file_get_contents($updateFile); - - if (version_compare($latestKnownVersion, $currentVersion) == 1) { - return $latestKnownVersion; - } - return false; - } - - if (! in_array($branch, self::$GIT_BRANCHES)) { - throw new Exception( - 'Invalid branch selected for updates: "' . $branch . '"' - ); - } - - // Late Static Binding allows overriding within tests - // See http://php.net/manual/en/language.oop5.late-static-bindings.php - $latestVersion = static::getLatestGitVersionCode( - self::$GIT_URL . '/' . $branch . '/' . self::$VERSION_FILE - ); - - if (! $latestVersion) { - // Only update the file's modification date - file_put_contents($updateFile, $currentVersion); - return false; - } - - // Update the file's content and modification date - file_put_contents($updateFile, $latestVersion); - - if (version_compare($latestVersion, $currentVersion) == 1) { - return $latestVersion; - } - - return false; - } - - /** - * Checks the PHP version to ensure Shaarli can run - * - * @param string $minVersion minimum PHP required version - * @param string $curVersion current PHP version (use PHP_VERSION) - * - * @throws Exception the PHP version is not supported - */ - public static function checkPHPVersion($minVersion, $curVersion) - { - if (version_compare($curVersion, $minVersion) < 0) { - throw new Exception( - 'Your PHP version is obsolete!' - .' Shaarli requires at least PHP '.$minVersion.', and thus cannot run.' - .' Your PHP version has known security vulnerabilities and should be' - .' updated as soon as possible.' - ); - } - } - - /** - * Checks Shaarli has the proper access permissions to its resources - * - * @param ConfigManager $conf Configuration Manager instance. - * - * @return array A list of the detected configuration issues - */ - public static function checkResourcePermissions($conf) - { - $errors = array(); - - // Check script and template directories are readable - foreach (array( - 'application', - 'inc', - 'plugins', - $conf->get('resource.raintpl_tpl'), - ) as $path) { - if (! is_readable(realpath($path))) { - $errors[] = '"'.$path.'" directory is not readable'; - } - } - - // Check cache and data directories are readable and writeable - foreach (array( - $conf->get('resource.thumbnails_cache'), - $conf->get('resource.data_dir'), - $conf->get('resource.page_cache'), - $conf->get('resource.raintpl_tmp'), - ) as $path) { - if (! is_readable(realpath($path))) { - $errors[] = '"'.$path.'" directory is not readable'; - } - if (! is_writable(realpath($path))) { - $errors[] = '"'.$path.'" directory is not writable'; - } - } - - // Check configuration files are readable and writeable - foreach (array( - $conf->getConfigFileExt(), - $conf->get('resource.datastore'), - $conf->get('resource.ban_file'), - $conf->get('resource.log'), - $conf->get('resource.update_check'), - ) as $path) { - if (! is_file(realpath($path))) { - # the file may not exist yet - continue; - } - - if (! is_readable(realpath($path))) { - $errors[] = '"'.$path.'" file is not readable'; - } - if (! is_writable(realpath($path))) { - $errors[] = '"'.$path.'" file is not writable'; - } - } - - return $errors; - } -} diff --git a/application/Cache.php b/application/Cache.php deleted file mode 100644 index 5d05016..0000000 --- a/application/Cache.php +++ /dev/null @@ -1,38 +0,0 @@ -cacheDir = $cacheDir; - $this->url = $url; - $this->filename = $this->cacheDir.'/'.sha1($url).'.cache'; - $this->shouldBeCached = $shouldBeCached; - } - - /** - * Returns the cached version of a page, if it exists and should be cached - * - * @return a cached version of the page if it exists, null otherwise - */ - public function cachedVersion() - { - if (!$this->shouldBeCached) { - return null; - } - if (is_file($this->filename)) { - return file_get_contents($this->filename); - } - return null; - } - - /** - * Puts a page in the cache - * - * @param string $pageContent XML content to cache - */ - public function cache($pageContent) - { - if (!$this->shouldBeCached) { - return; - } - file_put_contents($this->filename, $pageContent); - } -} diff --git a/application/FeedBuilder.php b/application/FeedBuilder.php deleted file mode 100644 index ddefe6c..0000000 --- a/application/FeedBuilder.php +++ /dev/null @@ -1,279 +0,0 @@ -linkDB = $linkDB; - $this->feedType = $feedType; - $this->serverInfo = $serverInfo; - $this->userInput = $userInput; - $this->isLoggedIn = $isLoggedIn; - } - - /** - * Build data for feed templates. - * - * @return array Formatted data for feeds templates. - */ - public function buildData() - { - // Optionally filter the results: - $linksToDisplay = $this->linkDB->filterSearch($this->userInput); - - $nblinksToDisplay = $this->getNbLinks(count($linksToDisplay)); - - // Can't use array_keys() because $link is a LinkDB instance and not a real array. - $keys = array(); - foreach ($linksToDisplay as $key => $value) { - $keys[] = $key; - } - - $pageaddr = escape(index_url($this->serverInfo)); - $linkDisplayed = array(); - for ($i = 0; $i < $nblinksToDisplay && $i < count($keys); $i++) { - $linkDisplayed[$keys[$i]] = $this->buildItem($linksToDisplay[$keys[$i]], $pageaddr); - } - - $data['language'] = $this->getTypeLanguage(); - $data['pubsubhub_url'] = $this->pubsubhubUrl; - $data['last_update'] = $this->getLatestDateFormatted(); - $data['show_dates'] = !$this->hideDates || $this->isLoggedIn; - // Remove leading slash from REQUEST_URI. - $data['self_link'] = $pageaddr . escape(ltrim($this->serverInfo['REQUEST_URI'], '/')); - $data['index_url'] = $pageaddr; - $data['usepermalinks'] = $this->usePermalinks === true; - $data['links'] = $linkDisplayed; - - return $data; - } - - /** - * Build a feed item (one per shaare). - * - * @param array $link Single link array extracted from LinkDB. - * @param string $pageaddr Index URL. - * - * @return array Link array with feed attributes. - */ - protected function buildItem($link, $pageaddr) - { - $link['guid'] = $pageaddr .'?'. smallHash($link['linkdate']); - // Check for both signs of a note: starting with ? and 7 chars long. - if ($link['url'][0] === '?' && strlen($link['url']) === 7) { - $link['url'] = $pageaddr . $link['url']; - } - if ($this->usePermalinks === true) { - $permalink = 'Direct link'; - } else { - $permalink = 'Permalink'; - } - $link['description'] = format_description($link['description']) . PHP_EOL .'
— '. $permalink; - - $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); - - if ($this->feedType == self::$FEED_RSS) { - $link['iso_date'] = $date->format(DateTime::RSS); - } else { - $link['iso_date'] = $date->format(DateTime::ATOM); - } - - // Save the more recent item. - if (empty($this->latestDate) || $this->latestDate < $date) { - $this->latestDate = $date; - } - - $taglist = array_filter(explode(' ', $link['tags']), 'strlen'); - uasort($taglist, 'strcasecmp'); - $link['taglist'] = $taglist; - - return $link; - } - - /** - * Assign PubSub hub URL. - * - * @param string $pubsubhubUrl PubSub hub url. - */ - public function setPubsubhubUrl($pubsubhubUrl) - { - $this->pubsubhubUrl = $pubsubhubUrl; - } - - /** - * Set this to true to use permalinks instead of direct links. - * - * @param boolean $usePermalinks true to force permalinks. - */ - public function setUsePermalinks($usePermalinks) - { - $this->usePermalinks = $usePermalinks; - } - - /** - * Set this to true to hide timestamps in feeds. - * - * @param boolean $hideDates true to enable. - */ - public function setHideDates($hideDates) - { - $this->hideDates = $hideDates; - } - - /** - * Set the locale. Used to show feed language. - * - * @param string $locale The locale (eg. 'fr_FR.UTF8'). - */ - public function setLocale($locale) - { - $this->locale = strtolower($locale); - } - - /** - * Get the language according to the feed type, based on the locale: - * - * - RSS format: en-us (default: 'en-en'). - * - ATOM format: fr (default: 'en'). - * - * @return string The language. - */ - public function getTypeLanguage() - { - // Use the locale do define the language, if available. - if (! empty($this->locale) && preg_match('/^\w{2}[_\-]\w{2}/', $this->locale)) { - $length = ($this->feedType == self::$FEED_RSS) ? 5 : 2; - return str_replace('_', '-', substr($this->locale, 0, $length)); - } - return ($this->feedType == self::$FEED_RSS) ? 'en-en' : 'en'; - } - - /** - * Format the latest item date found according to the feed type. - * - * Return an empty string if invalid DateTime is passed. - * - * @return string Formatted date. - */ - protected function getLatestDateFormatted() - { - if (empty($this->latestDate) || !$this->latestDate instanceof DateTime) { - return ''; - } - - $type = ($this->feedType == self::$FEED_RSS) ? DateTime::RSS : DateTime::ATOM; - return $this->latestDate->format($type); - } - - /** - * Returns the number of link to display according to 'nb' user input parameter. - * - * If 'nb' not set or invalid, default value: $DEFAULT_NB_LINKS. - * If 'nb' is set to 'all', display all filtered links (max parameter). - * - * @param int $max maximum number of links to display. - * - * @return int number of links to display. - */ - public function getNbLinks($max) - { - if (empty($this->userInput['nb'])) { - return self::$DEFAULT_NB_LINKS; - } - - if ($this->userInput['nb'] == 'all') { - return $max; - } - - $intNb = intval($this->userInput['nb']); - if (! is_int($intNb) || $intNb == 0) { - return self::$DEFAULT_NB_LINKS; - } - - return $intNb; - } -} diff --git a/application/FileUtils.php b/application/FileUtils.php deleted file mode 100644 index 6cac982..0000000 --- a/application/FileUtils.php +++ /dev/null @@ -1,21 +0,0 @@ -path = $path; - $this->message = empty($message) ? 'Error accessing' : $message; - $this->message .= PHP_EOL . $this->path; - } -} diff --git a/application/HttpUtils.php b/application/HttpUtils.php deleted file mode 100644 index 27a39d3..0000000 --- a/application/HttpUtils.php +++ /dev/null @@ -1,357 +0,0 @@ -idnToAscii(); - - if (!filter_var($cleanUrl, FILTER_VALIDATE_URL) || !$urlObj->isHttp()) { - return array(array(0 => 'Invalid HTTP Url'), false); - } - - $userAgent = - 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:45.0)' - . ' Gecko/20100101 Firefox/45.0'; - $acceptLanguage = - substr(setlocale(LC_COLLATE, 0), 0, 2) . ',en-US;q=0.7,en;q=0.3'; - $maxRedirs = 3; - - if (!function_exists('curl_init')) { - return get_http_response_fallback( - $cleanUrl, - $timeout, - $maxBytes, - $userAgent, - $acceptLanguage, - $maxRedirs - ); - } - - $ch = curl_init($cleanUrl); - if ($ch === false) { - return array(array(0 => 'curl_init() error'), false); - } - - // General cURL settings - curl_setopt($ch, CURLOPT_AUTOREFERER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt( - $ch, - CURLOPT_HTTPHEADER, - array('Accept-Language: ' . $acceptLanguage) - ); - curl_setopt($ch, CURLOPT_MAXREDIRS, $maxRedirs); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); - - // Max download size management - curl_setopt($ch, CURLOPT_BUFFERSIZE, 1024); - curl_setopt($ch, CURLOPT_NOPROGRESS, false); - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, - function($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes) - { - if (version_compare(phpversion(), '5.5', '<')) { - // PHP version lower than 5.5 - // Callback has 4 arguments - $downloaded = $arg1; - } else { - // Callback has 5 arguments - $downloaded = $arg2; - } - // Non-zero return stops downloading - return ($downloaded > $maxBytes) ? 1 : 0; - } - ); - - $response = curl_exec($ch); - $errorNo = curl_errno($ch); - $errorStr = curl_error($ch); - $headSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); - curl_close($ch); - - if ($response === false) { - if ($errorNo == CURLE_COULDNT_RESOLVE_HOST) { - /* - * Workaround to match fallback method behaviour - * Removing this would require updating - * GetHttpUrlTest::testGetInvalidRemoteUrl() - */ - return array(false, false); - } - return array(array(0 => 'curl_exec() error: ' . $errorStr), false); - } - - // Formatting output like the fallback method - $rawHeaders = substr($response, 0, $headSize); - - // Keep only headers from latest redirection - $rawHeadersArrayRedirs = explode("\r\n\r\n", trim($rawHeaders)); - $rawHeadersLastRedir = end($rawHeadersArrayRedirs); - - $content = substr($response, $headSize); - $headers = array(); - foreach (preg_split('~[\r\n]+~', $rawHeadersLastRedir) as $line) { - if (empty($line) or ctype_space($line)) { - continue; - } - $splitLine = explode(': ', $line, 2); - if (count($splitLine) > 1) { - $key = $splitLine[0]; - $value = $splitLine[1]; - if (array_key_exists($key, $headers)) { - if (!is_array($headers[$key])) { - $headers[$key] = array(0 => $headers[$key]); - } - $headers[$key][] = $value; - } else { - $headers[$key] = $value; - } - } else { - $headers[] = $splitLine[0]; - } - } - - return array($headers, $content); -} - -/** - * GET an HTTP URL to retrieve its content (fallback method) - * - * @param string $cleanUrl URL to get (http://... valid and in ASCII form) - * @param int $timeout network timeout (in seconds) - * @param int $maxBytes maximum downloaded bytes - * @param string $userAgent "User-Agent" header - * @param string $acceptLanguage "Accept-Language" header - * @param int $maxRedr maximum amount of redirections followed - * - * @return array HTTP response headers, downloaded content - * - * Output format: - * [0] = associative array containing HTTP response headers - * [1] = URL content (downloaded data) - * - * @see http://php.net/manual/en/function.file-get-contents.php - * @see http://php.net/manual/en/function.stream-context-create.php - * @see http://php.net/manual/en/function.get-headers.php - */ -function get_http_response_fallback( - $cleanUrl, - $timeout, - $maxBytes, - $userAgent, - $acceptLanguage, - $maxRedr -) { - $options = array( - 'http' => array( - 'method' => 'GET', - 'timeout' => $timeout, - 'user_agent' => $userAgent, - 'header' => "Accept: */*\r\n" - . 'Accept-Language: ' . $acceptLanguage - ) - ); - - stream_context_set_default($options); - list($headers, $finalUrl) = get_redirected_headers($cleanUrl, $maxRedr); - if (! $headers || strpos($headers[0], '200 OK') === false) { - $options['http']['request_fulluri'] = true; - stream_context_set_default($options); - list($headers, $finalUrl) = get_redirected_headers($cleanUrl, $maxRedr); - } - - if (! $headers) { - return array($headers, false); - } - - try { - // TODO: catch Exception in calling code (thumbnailer) - $context = stream_context_create($options); - $content = file_get_contents($finalUrl, false, $context, -1, $maxBytes); - } catch (Exception $exc) { - return array(array(0 => 'HTTP Error'), $exc->getMessage()); - } - - return array($headers, $content); -} - -/** - * Retrieve HTTP headers, following n redirections (temporary and permanent ones). - * - * @param string $url initial URL to reach. - * @param int $redirectionLimit max redirection follow. - * - * @return array HTTP headers, or false if it failed. - */ -function get_redirected_headers($url, $redirectionLimit = 3) -{ - $headers = get_headers($url, 1); - if (!empty($headers['location']) && empty($headers['Location'])) { - $headers['Location'] = $headers['location']; - } - - // Headers found, redirection found, and limit not reached. - if ($redirectionLimit-- > 0 - && !empty($headers) - && (strpos($headers[0], '301') !== false || strpos($headers[0], '302') !== false) - && !empty($headers['Location'])) { - - $redirection = is_array($headers['Location']) ? end($headers['Location']) : $headers['Location']; - if ($redirection != $url) { - $redirection = getAbsoluteUrl($url, $redirection); - return get_redirected_headers($redirection, $redirectionLimit); - } - } - - return array($headers, $url); -} - -/** - * Get an absolute URL from a complete one, and another absolute/relative URL. - * - * @param string $originalUrl The original complete URL. - * @param string $newUrl The new one, absolute or relative. - * - * @return string Final URL: - * - $newUrl if it was already an absolute URL. - * - if it was relative, absolute URL from $originalUrl path. - */ -function getAbsoluteUrl($originalUrl, $newUrl) -{ - $newScheme = parse_url($newUrl, PHP_URL_SCHEME); - // Already an absolute URL. - if (!empty($newScheme)) { - return $newUrl; - } - - $parts = parse_url($originalUrl); - $final = $parts['scheme'] .'://'. $parts['host']; - $final .= (!empty($parts['port'])) ? $parts['port'] : ''; - $final .= '/'; - if ($newUrl[0] != '/') { - $final .= substr(ltrim($parts['path'], '/'), 0, strrpos($parts['path'], '/')); - } - $final .= ltrim($newUrl, '/'); - return $final; -} - -/** - * Returns the server's base URL: scheme://domain.tld[:port] - * - * @param array $server the $_SERVER array - * - * @return string the server's base URL - * - * @see http://www.ietf.org/rfc/rfc7239.txt - * @see http://www.ietf.org/rfc/rfc6648.txt - * @see http://stackoverflow.com/a/3561399 - * @see http://stackoverflow.com/q/452375 - */ -function server_url($server) -{ - $scheme = 'http'; - $port = ''; - - // Shaarli is served behind a proxy - if (isset($server['HTTP_X_FORWARDED_PROTO'])) { - // Keep forwarded scheme - if (strpos($server['HTTP_X_FORWARDED_PROTO'], ',') !== false) { - $schemes = explode(',', $server['HTTP_X_FORWARDED_PROTO']); - $scheme = trim($schemes[0]); - } else { - $scheme = $server['HTTP_X_FORWARDED_PROTO']; - } - - if (isset($server['HTTP_X_FORWARDED_PORT'])) { - // Keep forwarded port - if (strpos($server['HTTP_X_FORWARDED_PORT'], ',') !== false) { - $ports = explode(',', $server['HTTP_X_FORWARDED_PORT']); - $port = ':' . trim($ports[0]); - } else { - $port = ':' . $server['HTTP_X_FORWARDED_PORT']; - } - } - - return $scheme.'://'.$server['SERVER_NAME'].$port; - } - - // SSL detection - if ((! empty($server['HTTPS']) && strtolower($server['HTTPS']) == 'on') - || (isset($server['SERVER_PORT']) && $server['SERVER_PORT'] == '443')) { - $scheme = 'https'; - } - - // Do not append standard port values - if (($scheme == 'http' && $server['SERVER_PORT'] != '80') - || ($scheme == 'https' && $server['SERVER_PORT'] != '443')) { - $port = ':'.$server['SERVER_PORT']; - } - - return $scheme.'://'.$server['SERVER_NAME'].$port; -} - -/** - * Returns the absolute URL of the current script, without the query - * - * If the resource is "index.php", then it is removed (for better-looking URLs) - * - * @param array $server the $_SERVER array - * - * @return string the absolute URL of the current script, without the query - */ -function index_url($server) -{ - $scriptname = $server['SCRIPT_NAME']; - if (endsWith($scriptname, 'index.php')) { - $scriptname = substr($scriptname, 0, -9); - } - return server_url($server) . $scriptname; -} - -/** - * Returns the absolute URL of the current script, with the query - * - * If the resource is "index.php", then it is removed (for better-looking URLs) - * - * @param array $server the $_SERVER array - * - * @return string the absolute URL of the current script, with the query - */ -function page_url($server) -{ - if (! empty($server['QUERY_STRING'])) { - return index_url($server).'?'.$server['QUERY_STRING']; - } - return index_url($server); -} diff --git a/application/Languages.php b/application/Languages.php deleted file mode 100644 index c8b0a25..0000000 --- a/application/Languages.php +++ /dev/null @@ -1,21 +0,0 @@ - 1 ? $nText : $text; - return sprintf($actualForm, $nb); -} diff --git a/application/LinkDB.php b/application/LinkDB.php deleted file mode 100644 index d80434b..0000000 --- a/application/LinkDB.php +++ /dev/null @@ -1,477 +0,0 @@ -'; - - // List of links (associative array) - // - key: link date (e.g. "20110823_124546"), - // - value: associative array (keys: title, description...) - private $_links; - - // List of all recorded URLs (key=url, value=linkdate) - // for fast reserve search (url-->linkdate) - private $_urls; - - // List of linkdate keys (for the Iterator interface implementation) - private $_keys; - - // Position in the $this->_keys array (for the Iterator interface) - private $_position; - - // Is the user logged in? (used to filter private links) - private $_loggedIn; - - // Hide public links - private $_hidePublicLinks; - - // link redirector set in user settings. - private $_redirector; - - /** - * Set this to `true` to urlencode link behind redirector link, `false` to leave it untouched. - * - * Example: - * anonym.to needs clean URL while dereferer.org needs urlencoded URL. - * - * @var boolean $redirectorEncode parameter: true or false - */ - private $redirectorEncode; - - /** - * Creates a new LinkDB - * - * Checks if the datastore exists; else, attempts to create a dummy one. - * - * @param string $datastore datastore file path. - * @param boolean $isLoggedIn is the user logged in? - * @param boolean $hidePublicLinks if true all links are private. - * @param string $redirector link redirector set in user settings. - * @param boolean $redirectorEncode Enable urlencode on redirected urls (default: true). - */ - function __construct( - $datastore, - $isLoggedIn, - $hidePublicLinks, - $redirector = '', - $redirectorEncode = true - ) - { - $this->_datastore = $datastore; - $this->_loggedIn = $isLoggedIn; - $this->_hidePublicLinks = $hidePublicLinks; - $this->_redirector = $redirector; - $this->redirectorEncode = $redirectorEncode === true; - $this->_checkDB(); - $this->_readDB(); - } - - /** - * Countable - Counts elements of an object - */ - public function count() - { - return count($this->_links); - } - - /** - * ArrayAccess - Assigns a value to the specified offset - */ - public function offsetSet($offset, $value) - { - // TODO: use exceptions instead of "die" - if (!$this->_loggedIn) { - die('You are not authorized to add a link.'); - } - if (empty($value['linkdate']) || empty($value['url'])) { - die('Internal Error: A link should always have a linkdate and URL.'); - } - if (empty($offset)) { - die('You must specify a key.'); - } - $this->_links[$offset] = $value; - $this->_urls[$value['url']]=$offset; - } - - /** - * ArrayAccess - Whether or not an offset exists - */ - public function offsetExists($offset) - { - return array_key_exists($offset, $this->_links); - } - - /** - * ArrayAccess - Unsets an offset - */ - public function offsetUnset($offset) - { - if (!$this->_loggedIn) { - // TODO: raise an exception - die('You are not authorized to delete a link.'); - } - $url = $this->_links[$offset]['url']; - unset($this->_urls[$url]); - unset($this->_links[$offset]); - } - - /** - * ArrayAccess - Returns the value at specified offset - */ - public function offsetGet($offset) - { - return isset($this->_links[$offset]) ? $this->_links[$offset] : null; - } - - /** - * Iterator - Returns the current element - */ - function current() - { - return $this->_links[$this->_keys[$this->_position]]; - } - - /** - * Iterator - Returns the key of the current element - */ - function key() - { - return $this->_keys[$this->_position]; - } - - /** - * Iterator - Moves forward to next element - */ - function next() - { - ++$this->_position; - } - - /** - * Iterator - Rewinds the Iterator to the first element - * - * Entries are sorted by date (latest first) - */ - function rewind() - { - $this->_keys = array_keys($this->_links); - rsort($this->_keys); - $this->_position = 0; - } - - /** - * Iterator - Checks if current position is valid - */ - function valid() - { - return isset($this->_keys[$this->_position]); - } - - /** - * Checks if the DB directory and file exist - * - * If no DB file is found, creates a dummy DB. - */ - private function _checkDB() - { - if (file_exists($this->_datastore)) { - return; - } - - // Create a dummy database for example - $this->_links = array(); - $link = array( - 'title'=>' Shaarli: the personal, minimalist, super-fast, no-database delicious clone', - 'url'=>'https://github.com/shaarli/Shaarli/wiki', - 'description'=>'Welcome to Shaarli! This is your first public bookmark. To edit or delete me, you must first login. - -To learn how to use Shaarli, consult the link "Help/documentation" at the bottom of this page. - -You use the community supported version of the original Shaarli project, by Sebastien Sauvage.', - 'private'=>0, - 'linkdate'=> date('Ymd_His'), - 'tags'=>'opensource software' - ); - $this->_links[$link['linkdate']] = $link; - - $link = array( - 'title'=>'My secret stuff... - Pastebin.com', - 'url'=>'http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8=', - 'description'=>'Shhhh! I\'m a private link only YOU can see. You can delete me too.', - 'private'=>1, - 'linkdate'=> date('Ymd_His', strtotime('-1 minute')), - 'tags'=>'secretstuff' - ); - $this->_links[$link['linkdate']] = $link; - - // Write database to disk - $this->writeDB(); - } - - /** - * Reads database from disk to memory - */ - private function _readDB() - { - - // Public links are hidden and user not logged in => nothing to show - if ($this->_hidePublicLinks && !$this->_loggedIn) { - $this->_links = array(); - return; - } - - // Read data - // Note that gzinflate is faster than gzuncompress. - // See: http://www.php.net/manual/en/function.gzdeflate.php#96439 - $this->_links = array(); - - if (file_exists($this->_datastore)) { - $this->_links = unserialize(gzinflate(base64_decode( - substr(file_get_contents($this->_datastore), - strlen(self::$phpPrefix), -strlen(self::$phpSuffix))))); - } - - // If user is not logged in, filter private links. - if (!$this->_loggedIn) { - $toremove = array(); - foreach ($this->_links as $link) { - if ($link['private'] != 0) { - $toremove[] = $link['linkdate']; - } - } - foreach ($toremove as $linkdate) { - unset($this->_links[$linkdate]); - } - } - - $this->_urls = array(); - foreach ($this->_links as &$link) { - // Keep the list of the mapping URLs-->linkdate up-to-date. - $this->_urls[$link['url']] = $link['linkdate']; - - // Sanitize data fields. - sanitizeLink($link); - - // Remove private tags if the user is not logged in. - if (! $this->_loggedIn) { - $link['tags'] = preg_replace('/(^|\s+)\.[^($|\s)]+\s*/', ' ', $link['tags']); - } - - // Do not use the redirector for internal links (Shaarli note URL starting with a '?'). - if (!empty($this->_redirector) && !startsWith($link['url'], '?')) { - $link['real_url'] = $this->_redirector; - if ($this->redirectorEncode) { - $link['real_url'] .= urlencode(unescape($link['url'])); - } else { - $link['real_url'] .= $link['url']; - } - } - else { - $link['real_url'] = $link['url']; - } - } - } - - /** - * Saves the database from memory to disk - * - * @throws IOException the datastore is not writable - */ - private function writeDB() - { - if (is_file($this->_datastore) && !is_writeable($this->_datastore)) { - // The datastore exists but is not writeable - throw new IOException($this->_datastore); - } else if (!is_file($this->_datastore) && !is_writeable(dirname($this->_datastore))) { - // The datastore does not exist and its parent directory is not writeable - throw new IOException(dirname($this->_datastore)); - } - - file_put_contents( - $this->_datastore, - self::$phpPrefix.base64_encode(gzdeflate(serialize($this->_links))).self::$phpSuffix - ); - - } - - /** - * Saves the database from memory to disk - * - * @param string $pageCacheDir page cache directory - */ - public function savedb($pageCacheDir) - { - if (!$this->_loggedIn) { - // TODO: raise an Exception instead - die('You are not authorized to change the database.'); - } - - $this->writeDB(); - - invalidateCaches($pageCacheDir); - } - - /** - * Returns the link for a given URL, or False if it does not exist. - * - * @param string $url URL to search for - * - * @return mixed the existing link if it exists, else 'false' - */ - public function getLinkFromUrl($url) - { - if (isset($this->_urls[$url])) { - return $this->_links[$this->_urls[$url]]; - } - return false; - } - - /** - * Returns the shaare corresponding to a smallHash. - * - * @param string $request QUERY_STRING server parameter. - * - * @return array $filtered array containing permalink data. - * - * @throws LinkNotFoundException if the smallhash is malformed or doesn't match any link. - */ - public function filterHash($request) - { - $request = substr($request, 0, 6); - $linkFilter = new LinkFilter($this->_links); - return $linkFilter->filter(LinkFilter::$FILTER_HASH, $request); - } - - /** - * Returns the list of articles for a given day. - * - * @param string $request day to filter. Format: YYYYMMDD. - * - * @return array list of shaare found. - */ - public function filterDay($request) { - $linkFilter = new LinkFilter($this->_links); - return $linkFilter->filter(LinkFilter::$FILTER_DAY, $request); - } - - /** - * Filter links according to search parameters. - * - * @param array $filterRequest Search request content. Supported keys: - * - searchtags: list of tags - * - searchterm: term search - * @param bool $casesensitive Optional: Perform case sensitive filter - * @param bool $privateonly Optional: Returns private links only if true. - * - * @return array filtered links, all links if no suitable filter was provided. - */ - public function filterSearch($filterRequest = array(), $casesensitive = false, $privateonly = false) - { - // Filter link database according to parameters. - $searchtags = !empty($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; - $searchterm = !empty($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; - - // Search tags + fullsearch. - if (! empty($searchtags) && ! empty($searchterm)) { - $type = LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT; - $request = array($searchtags, $searchterm); - } - // Search by tags. - elseif (! empty($searchtags)) { - $type = LinkFilter::$FILTER_TAG; - $request = $searchtags; - } - // Fulltext search. - elseif (! empty($searchterm)) { - $type = LinkFilter::$FILTER_TEXT; - $request = $searchterm; - } - // Otherwise, display without filtering. - else { - $type = ''; - $request = ''; - } - - $linkFilter = new LinkFilter($this->_links); - return $linkFilter->filter($type, $request, $casesensitive, $privateonly); - } - - /** - * Returns the list of all tags - * Output: associative array key=tags, value=0 - */ - public function allTags() - { - $tags = array(); - $caseMapping = array(); - foreach ($this->_links as $link) { - foreach (preg_split('/\s+/', $link['tags'], 0, PREG_SPLIT_NO_EMPTY) as $tag) { - if (empty($tag)) { - continue; - } - // The first case found will be displayed. - if (!isset($caseMapping[strtolower($tag)])) { - $caseMapping[strtolower($tag)] = $tag; - $tags[$caseMapping[strtolower($tag)]] = 0; - } - $tags[$caseMapping[strtolower($tag)]]++; - } - } - // Sort tags by usage (most used tag first) - arsort($tags); - return $tags; - } - - /** - * Returns the list of days containing articles (oldest first) - * Output: An array containing days (in format YYYYMMDD). - */ - public function days() - { - $linkDays = array(); - foreach (array_keys($this->_links) as $day) { - $linkDays[substr($day, 0, 8)] = 0; - } - $linkDays = array_keys($linkDays); - sort($linkDays); - - return $linkDays; - } -} diff --git a/application/LinkFilter.php b/application/LinkFilter.php deleted file mode 100644 index d4fe28d..0000000 --- a/application/LinkFilter.php +++ /dev/null @@ -1,361 +0,0 @@ -links = $links; - } - - /** - * Filter links according to parameters. - * - * @param string $type Type of filter (eg. tags, permalink, etc.). - * @param mixed $request Filter content. - * @param bool $casesensitive Optional: Perform case sensitive filter if true. - * @param bool $privateonly Optional: Only returns private links if true. - * - * @return array filtered link list. - */ - public function filter($type, $request, $casesensitive = false, $privateonly = false) - { - switch($type) { - case self::$FILTER_HASH: - return $this->filterSmallHash($request); - case self::$FILTER_TAG | self::$FILTER_TEXT: - if (!empty($request)) { - $filtered = $this->links; - if (isset($request[0])) { - $filtered = $this->filterTags($request[0], $casesensitive, $privateonly); - } - if (isset($request[1])) { - $lf = new LinkFilter($filtered); - $filtered = $lf->filterFulltext($request[1], $privateonly); - } - return $filtered; - } - return $this->noFilter($privateonly); - case self::$FILTER_TEXT: - return $this->filterFulltext($request, $privateonly); - case self::$FILTER_TAG: - return $this->filterTags($request, $casesensitive, $privateonly); - case self::$FILTER_DAY: - return $this->filterDay($request); - default: - return $this->noFilter($privateonly); - } - } - - /** - * Unknown filter, but handle private only. - * - * @param bool $privateonly returns private link only if true. - * - * @return array filtered links. - */ - private function noFilter($privateonly = false) - { - if (! $privateonly) { - krsort($this->links); - return $this->links; - } - - $out = array(); - foreach ($this->links as $value) { - if ($value['private']) { - $out[$value['linkdate']] = $value; - } - } - - krsort($out); - return $out; - } - - /** - * Returns the shaare corresponding to a smallHash. - * - * @param string $smallHash permalink hash. - * - * @return array $filtered array containing permalink data. - * - * @throws LinkNotFoundException if the smallhash doesn't match any link. - */ - private function filterSmallHash($smallHash) - { - $filtered = array(); - foreach ($this->links as $l) { - if ($smallHash == smallHash($l['linkdate'])) { - // Yes, this is ugly and slow - $filtered[$l['linkdate']] = $l; - return $filtered; - } - } - - if (empty($filtered)) { - throw new LinkNotFoundException(); - } - - return $filtered; - } - - /** - * Returns the list of links corresponding to a full-text search - * - * Searches: - * - in the URLs, title and description; - * - are case-insensitive; - * - terms surrounded by quotes " are exact terms search. - * - terms starting with a dash - are excluded (except exact terms). - * - * Example: - * print_r($mydb->filterFulltext('hollandais')); - * - * mb_convert_case($val, MB_CASE_LOWER, 'UTF-8') - * - allows to perform searches on Unicode text - * - see https://github.com/shaarli/Shaarli/issues/75 for examples - * - * @param string $searchterms search query. - * @param bool $privateonly return only private links if true. - * - * @return array search results. - */ - private function filterFulltext($searchterms, $privateonly = false) - { - if (empty($searchterms)) { - return $this->links; - } - - $filtered = array(); - $search = mb_convert_case(html_entity_decode($searchterms), MB_CASE_LOWER, 'UTF-8'); - $exactRegex = '/"([^"]+)"/'; - // Retrieve exact search terms. - preg_match_all($exactRegex, $search, $exactSearch); - $exactSearch = array_values(array_filter($exactSearch[1])); - - // Remove exact search terms to get AND terms search. - $explodedSearchAnd = explode(' ', trim(preg_replace($exactRegex, '', $search))); - $explodedSearchAnd = array_values(array_filter($explodedSearchAnd)); - - // Filter excluding terms and update andSearch. - $excludeSearch = array(); - $andSearch = array(); - foreach ($explodedSearchAnd as $needle) { - if ($needle[0] == '-' && strlen($needle) > 1) { - $excludeSearch[] = substr($needle, 1); - } else { - $andSearch[] = $needle; - } - } - - $keys = array('title', 'description', 'url', 'tags'); - - // Iterate over every stored link. - foreach ($this->links as $link) { - - // ignore non private links when 'privatonly' is on. - if (! $link['private'] && $privateonly === true) { - continue; - } - - // Concatenate link fields to search across fields. - // Adds a '\' separator for exact search terms. - $content = ''; - foreach ($keys as $key) { - $content .= mb_convert_case($link[$key], MB_CASE_LOWER, 'UTF-8') . '\\'; - } - - // Be optimistic - $found = true; - - // First, we look for exact term search - for ($i = 0; $i < count($exactSearch) && $found; $i++) { - $found = strpos($content, $exactSearch[$i]) !== false; - } - - // Iterate over keywords, if keyword is not found, - // no need to check for the others. We want all or nothing. - for ($i = 0; $i < count($andSearch) && $found; $i++) { - $found = strpos($content, $andSearch[$i]) !== false; - } - - // Exclude terms. - for ($i = 0; $i < count($excludeSearch) && $found; $i++) { - $found = strpos($content, $excludeSearch[$i]) === false; - } - - if ($found) { - $filtered[$link['linkdate']] = $link; - } - } - - krsort($filtered); - return $filtered; - } - - /** - * Returns the list of links associated with a given list of tags - * - * You can specify one or more tags, separated by space or a comma, e.g. - * print_r($mydb->filterTags('linux programming')); - * - * @param string $tags list of tags separated by commas or blank spaces. - * @param bool $casesensitive ignore case if false. - * @param bool $privateonly returns private links only. - * - * @return array filtered links. - */ - public function filterTags($tags, $casesensitive = false, $privateonly = false) - { - // Implode if array for clean up. - $tags = is_array($tags) ? trim(implode(' ', $tags)) : $tags; - if (empty($tags)) { - return $this->links; - } - - $searchtags = self::tagsStrToArray($tags, $casesensitive); - $filtered = array(); - if (empty($searchtags)) { - return $filtered; - } - - foreach ($this->links as $link) { - // ignore non private links when 'privatonly' is on. - if (! $link['private'] && $privateonly === true) { - continue; - } - - $linktags = self::tagsStrToArray($link['tags'], $casesensitive); - - $found = true; - for ($i = 0 ; $i < count($searchtags) && $found; $i++) { - // Exclusive search, quit if tag found. - // Or, tag not found in the link, quit. - if (($searchtags[$i][0] == '-' - && $this->searchTagAndHashTag(substr($searchtags[$i], 1), $linktags, $link['description'])) - || ($searchtags[$i][0] != '-') - && ! $this->searchTagAndHashTag($searchtags[$i], $linktags, $link['description']) - ) { - $found = false; - } - } - - if ($found) { - $filtered[$link['linkdate']] = $link; - } - } - krsort($filtered); - return $filtered; - } - - /** - * Returns the list of articles for a given day, chronologically sorted - * - * Day must be in the form 'YYYYMMDD' (e.g. '20120125'), e.g. - * print_r($mydb->filterDay('20120125')); - * - * @param string $day day to filter. - * - * @return array all link matching given day. - * - * @throws Exception if date format is invalid. - */ - public function filterDay($day) - { - if (! checkDateFormat('Ymd', $day)) { - throw new Exception('Invalid date format'); - } - - $filtered = array(); - foreach ($this->links as $l) { - if (startsWith($l['linkdate'], $day)) { - $filtered[$l['linkdate']] = $l; - } - } - ksort($filtered); - return $filtered; - } - - /** - * Check if a tag is found in the taglist, or as an hashtag in the link description. - * - * @param string $tag Tag to search. - * @param array $taglist List of tags for the current link. - * @param string $description Link description. - * - * @return bool True if found, false otherwise. - */ - protected function searchTagAndHashTag($tag, $taglist, $description) - { - if (in_array($tag, $taglist)) { - return true; - } - - if (preg_match('/(^| )#'. $tag .'([^'. self::$HASHTAG_CHARS .']|$)/mui', $description) > 0) { - return true; - } - - return false; - } - - /** - * Convert a list of tags (str) to an array. Also - * - handle case sensitivity. - * - accepts spaces commas as separator. - * - * @param string $tags string containing a list of tags. - * @param bool $casesensitive will convert everything to lowercase if false. - * - * @return array filtered tags string. - */ - public static function tagsStrToArray($tags, $casesensitive) - { - // We use UTF-8 conversion to handle various graphemes (i.e. cyrillic, or greek) - $tagsOut = $casesensitive ? $tags : mb_convert_case($tags, MB_CASE_LOWER, 'UTF-8'); - $tagsOut = str_replace(',', ' ', $tagsOut); - - return array_values(array_filter(explode(' ', trim($tagsOut)), 'strlen')); - } -} - -class LinkNotFoundException extends Exception -{ - protected $message = 'The link you are trying to reach does not exist or has been deleted.'; -} diff --git a/application/LinkUtils.php b/application/LinkUtils.php deleted file mode 100644 index eeca631..0000000 --- a/application/LinkUtils.php +++ /dev/null @@ -1,170 +0,0 @@ -(.*?)!is', $html, $matches)) { - return trim(str_replace("\n", '', $matches[1])); - } - return false; -} - -/** - * Determine charset from downloaded page. - * Priority: - * 1. HTTP headers (Content type). - * 2. HTML content page (tag ). - * 3. Use a default charset (default: UTF-8). - * - * @param array $headers HTTP headers array. - * @param string $htmlContent HTML content where to look for charset. - * @param string $defaultCharset Default charset to apply if other methods failed. - * - * @return string Determined charset. - */ -function get_charset($headers, $htmlContent, $defaultCharset = 'utf-8') -{ - if ($charset = headers_extract_charset($headers)) { - return $charset; - } - - if ($charset = html_extract_charset($htmlContent)) { - return $charset; - } - - return $defaultCharset; -} - -/** - * Extract charset from HTTP headers if it's defined. - * - * @param array $headers HTTP headers array. - * - * @return bool|string Charset string if found (lowercase), false otherwise. - */ -function headers_extract_charset($headers) -{ - if (! empty($headers['Content-Type']) && strpos($headers['Content-Type'], 'charset=') !== false) { - preg_match('/charset="?([^; ]+)/i', $headers['Content-Type'], $match); - if (! empty($match[1])) { - return strtolower(trim($match[1])); - } - } - - return false; -} - -/** - * Extract charset HTML content (tag ). - * - * @param string $html HTML content where to look for charset. - * - * @return bool|string Charset string if found, false otherwise. - */ -function html_extract_charset($html) -{ - // Get encoding specified in HTML header. - preg_match('#/]+)["\']? */?>#Usi', $html, $enc); - if (!empty($enc[1])) { - return strtolower($enc[1]); - } - - return false; -} - -/** - * Count private links in given linklist. - * - * @param array $links Linklist. - * - * @return int Number of private links. - */ -function count_private($links) -{ - $cpt = 0; - foreach ($links as $link) { - $cpt = $link['private'] == true ? $cpt + 1 : $cpt; - } - - return $cpt; -} - -/** - * In a string, converts URLs to clickable links. - * - * @param string $text input string. - * @param string $redirector if a redirector is set, use it to gerenate links. - * - * @return string returns $text with all links converted to HTML links. - * - * @see Function inspired from http://www.php.net/manual/en/function.preg-replace.php#85722 - */ -function text2clickable($text, $redirector = '') -{ - $regex = '!(((?:https?|ftp|file)://|apt:|magnet:)\S+[[:alnum:]]/?)!si'; - - if (empty($redirector)) { - return preg_replace($regex, '$1', $text); - } - // Redirector is set, urlencode the final URL. - return preg_replace_callback( - $regex, - function ($matches) use ($redirector) { - return ''. $matches[1] .''; - }, - $text - ); -} - -/** - * Auto-link hashtags. - * - * @param string $description Given description. - * @param string $indexUrl Root URL. - * - * @return string Description with auto-linked hashtags. - */ -function hashtag_autolink($description, $indexUrl = '') -{ - /* - * To support unicode: http://stackoverflow.com/a/35498078/1484919 - * \p{Pc} - to match underscore - * \p{N} - numeric character in any script - * \p{L} - letter from any language - * \p{Mn} - any non marking space (accents, umlauts, etc) - */ - $regex = '/(^|\s)#([\p{Pc}\p{N}\p{L}\p{Mn}]+)/mui'; - $replacement = '$1#$2'; - return preg_replace($regex, $replacement, $description); -} - -/** - * This function inserts   where relevant so that multiple spaces are properly displayed in HTML - * even in the absence of
  (This is used in description to keep text formatting).
- *
- * @param string $text input text.
- *
- * @return string formatted text.
- */
-function space2nbsp($text)
-{
-    return preg_replace('/(^| ) /m', '$1 ', $text);
-}
-
-/**
- * Format Shaarli's description
- *
- * @param string $description shaare's description.
- * @param string $redirector  if a redirector is set, use it to gerenate links.
- *
- * @return string formatted description.
- */
-function format_description($description, $redirector = '', $indexUrl = '') {
-    return nl2br(space2nbsp(hashtag_autolink(text2clickable($description, $redirector), $indexUrl)));
-}
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php
deleted file mode 100644
index c318125..0000000
--- a/application/NetscapeBookmarkUtils.php
+++ /dev/null
@@ -1,195 +0,0 @@
-getTimestamp();
-            $link['taglist'] = str_replace(' ', ',', $link['tags']);
-
-            if (startsWith($link['url'], '?') && $prependNoteUrl) {
-                $link['url'] = $indexUrl . $link['url'];
-            }
-
-            $bookmarkLinks[] = $link;
-        }
-
-        return $bookmarkLinks;
-    }
-
-    /**
-     * Generates an import status summary
-     *
-     * @param string $filename       name of the file to import
-     * @param int    $filesize       size of the file to import
-     * @param int    $importCount    how many links were imported
-     * @param int    $overwriteCount how many links were overwritten
-     * @param int    $skipCount      how many links were skipped
-     *
-     * @return string Summary of the bookmark import status
-     */
-    private static function importStatus(
-        $filename,
-        $filesize,
-        $importCount=0,
-        $overwriteCount=0,
-        $skipCount=0
-    )
-    {
-        $status = 'File '.$filename.' ('.$filesize.' bytes) ';
-        if ($importCount == 0 && $overwriteCount == 0 && $skipCount == 0) {
-            $status .= 'has an unknown file format. Nothing was imported.';
-        } else {
-            $status .= 'was successfully processed: '.$importCount.' links imported, ';
-            $status .= $overwriteCount.' links overwritten, ';
-            $status .= $skipCount.' links skipped.';
-        }
-        return $status;
-    }
-
-    /**
-     * Imports Web bookmarks from an uploaded Netscape bookmark dump
-     *
-     * @param array  $post      Server $_POST parameters
-     * @param array  $file      Server $_FILES parameters
-     * @param LinkDB $linkDb    Loaded LinkDB instance
-     * @param string $pagecache Page cache
-     *
-     * @return string Summary of the bookmark import status
-     */
-    public static function import($post, $files, $linkDb, $pagecache)
-    {
-        $filename = $files['filetoupload']['name'];
-        $filesize = $files['filetoupload']['size'];
-        $data = file_get_contents($files['filetoupload']['tmp_name']);
-
-        if (strpos($data, '') === false) {
-            return self::importStatus($filename, $filesize);
-        }
-
-        // Overwrite existing links?
-        $overwrite = ! empty($post['overwrite']);
-
-        // Add tags to all imported links?
-        if (empty($post['default_tags'])) {
-            $defaultTags = array();
-        } else {
-            $defaultTags = preg_split(
-                '/[\s,]+/',
-                escape($post['default_tags'])
-            );
-        }
-
-        // links are imported as public by default
-        $defaultPrivacy = 0;
-
-        $parser = new NetscapeBookmarkParser(
-            true,                       // nested tag support
-            $defaultTags,               // additional user-specified tags
-            strval(1 - $defaultPrivacy) // defaultPub = 1 - defaultPrivacy
-        );
-        $bookmarks = $parser->parseString($data);
-
-        $importCount = 0;
-        $overwriteCount = 0;
-        $skipCount = 0;
-
-        foreach ($bookmarks as $bkm) {
-            $private = $defaultPrivacy;
-            if (empty($post['privacy']) || $post['privacy'] == 'default') {
-                // use value from the imported file
-                $private = $bkm['pub'] == '1' ? 0 : 1;
-            } else if ($post['privacy'] == 'private') {
-                // all imported links are private
-                $private = 1;
-            } else if ($post['privacy'] == 'public') {
-                // all imported links are public
-                $private = 0;
-            }                
-
-            $newLink = array(
-                'title' => $bkm['title'],
-                'url' => $bkm['uri'],
-                'description' => $bkm['note'],
-                'private' => $private,
-                'linkdate'=> '',
-                'tags' => $bkm['tags']
-            );
-
-            $existingLink = $linkDb->getLinkFromUrl($bkm['uri']);
-
-            if ($existingLink !== false) {
-                if ($overwrite === false) {
-                    // Do not overwrite an existing link
-                    $skipCount++;
-                    continue;
-                }
-
-                // Overwrite an existing link, keep its date
-                $newLink['linkdate'] = $existingLink['linkdate'];
-                $linkDb[$existingLink['linkdate']] = $newLink;
-                $importCount++;
-                $overwriteCount++;
-                continue;
-            }
-
-            // Add a new link
-            $newLinkDate = new DateTime('@'.strval($bkm['time']));
-            while (!empty($linkDb[$newLinkDate->format(LinkDB::LINK_DATE_FORMAT)])) {
-                // Ensure the date/time is not already used
-                // - this hack is necessary as the date/time acts as a primary key
-                // - apply 1 second increments until an unused index is found
-                // See https://github.com/shaarli/Shaarli/issues/351
-                $newLinkDate->add(new DateInterval('PT1S'));
-            }
-            $linkDbDate = $newLinkDate->format(LinkDB::LINK_DATE_FORMAT);
-            $newLink['linkdate'] = $linkDbDate;
-            $linkDb[$linkDbDate] = $newLink;
-            $importCount++;
-        }
-
-        $linkDb->savedb($pagecache);
-        return self::importStatus(
-            $filename,
-            $filesize,
-            $importCount,
-            $overwriteCount,
-            $skipCount
-        );
-    }
-}
diff --git a/application/PageBuilder.php b/application/PageBuilder.php
deleted file mode 100644
index 42932f3..0000000
--- a/application/PageBuilder.php
+++ /dev/null
@@ -1,152 +0,0 @@
-assign('myfield','myvalue');
- * $p->renderPage('mytemplate');
- */
-class PageBuilder
-{
-    /**
-     * @var RainTPL RainTPL instance.
-     */
-    private $tpl;
-
-    /**
-     * @var ConfigManager $conf Configuration Manager instance.
-     */
-    protected $conf;
-
-    /**
-     * PageBuilder constructor.
-     * $tpl is initialized at false for lazy loading.
-     *
-     * @param ConfigManager $conf Configuration Manager instance (reference).
-     */
-    function __construct(&$conf)
-    {
-        $this->tpl = false;
-        $this->conf = $conf;
-    }
-
-    /**
-     * Initialize all default tpl tags.
-     */
-    private function initialize()
-    {
-        $this->tpl = new RainTPL();
-
-        try {
-            $version = ApplicationUtils::checkUpdate(
-                shaarli_version,
-                $this->conf->get('resource.update_check'),
-                $this->conf->get('updates.check_updates_interval'),
-                $this->conf->get('updates.check_updates'),
-                isLoggedIn(),
-                $this->conf->get('updates.check_updates_branch')
-            );
-            $this->tpl->assign('newVersion', escape($version));
-            $this->tpl->assign('versionError', '');
-
-        } catch (Exception $exc) {
-            logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage());
-            $this->tpl->assign('newVersion', '');
-            $this->tpl->assign('versionError', escape($exc->getMessage()));
-        }
-
-        $this->tpl->assign('feedurl', escape(index_url($_SERVER)));
-        $searchcrits = ''; // Search criteria
-        if (!empty($_GET['searchtags'])) {
-            $searchcrits .= '&searchtags=' . urlencode($_GET['searchtags']);
-        }
-        if (!empty($_GET['searchterm'])) {
-            $searchcrits .= '&searchterm=' . urlencode($_GET['searchterm']);
-        }
-        $this->tpl->assign('searchcrits', $searchcrits);
-        $this->tpl->assign('source', index_url($_SERVER));
-        $this->tpl->assign('version', shaarli_version);
-        $this->tpl->assign('scripturl', index_url($_SERVER));
-        $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links?
-        $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli'));
-        if ($this->conf->exists('general.header_link')) {
-            $this->tpl->assign('titleLink', $this->conf->get('general.header_link'));
-        }
-        $this->tpl->assign('shaarlititle', $this->conf->get('general.title', 'Shaarli'));
-        $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false));
-        $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false));
-        $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false));
-        if (!empty($GLOBALS['plugin_errors'])) {
-            $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']);
-        }
-        $this->tpl->assign('token', getToken($this->conf));
-        // To be removed with a proper theme configuration.
-        $this->tpl->assign('conf', $this->conf);
-    }
-
-    /**
-     * The following assign() method is basically the same as RainTPL (except lazy loading)
-     *
-     * @param string $placeholder Template placeholder.
-     * @param mixed  $value       Value to assign.
-     */
-    public function assign($placeholder, $value)
-    {
-        if ($this->tpl === false) {
-            $this->initialize();
-        }
-        $this->tpl->assign($placeholder, $value);
-    }
-
-    /**
-     * Assign an array of data to the template builder.
-     *
-     * @param array $data Data to assign.
-     *
-     * @return false if invalid data.
-     */
-    public function assignAll($data)
-    {
-        if ($this->tpl === false) {
-            $this->initialize();
-        }
-
-        if (empty($data) || !is_array($data)){
-            return false;
-        }
-
-        foreach ($data as $key => $value) {
-            $this->assign($key, $value);
-        }
-        return true;
-    }
-
-    /**
-     * Render a specific page (using a template file).
-     * e.g. $pb->renderPage('picwall');
-     *
-     * @param string $page Template filename (without extension).
-     */
-    public function renderPage($page)
-    {
-        if ($this->tpl === false) {
-            $this->initialize();
-        }
-
-        $this->tpl->draw($page);
-    }
-
-    /**
-     * Render a 404 page (uses the template : tpl/404.tpl)
-     * usage : $PAGE->render404('The link was deleted')
-     *
-     * @param string $message A messate to display what is not found
-     */
-    public function render404($message = 'The page you are trying to reach does not exist or has been deleted.')
-    {
-        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
-        $this->tpl->assign('error_message', $message);
-        $this->renderPage('404');
-    }
-}
diff --git a/application/PluginManager.php b/application/PluginManager.php
deleted file mode 100644
index 1e132a7..0000000
--- a/application/PluginManager.php
+++ /dev/null
@@ -1,217 +0,0 @@
-conf = $conf;
-    }
-
-    /**
-     * Load plugins listed in $authorizedPlugins.
-     *
-     * @param array $authorizedPlugins Names of plugin authorized to be loaded.
-     *
-     * @return void
-     */
-    public function load($authorizedPlugins)
-    {
-        $this->authorizedPlugins = $authorizedPlugins;
-
-        $dirs = glob(self::$PLUGINS_PATH . '/*', GLOB_ONLYDIR);
-        $dirnames = array_map('basename', $dirs);
-        foreach ($this->authorizedPlugins as $plugin) {
-            $index = array_search($plugin, $dirnames);
-
-            // plugin authorized, but its folder isn't listed
-            if ($index === false) {
-                continue;
-            }
-
-            try {
-                $this->loadPlugin($dirs[$index], $plugin);
-            }
-            catch (PluginFileNotFoundException $e) {
-                error_log($e->getMessage());
-            }
-        }
-    }
-
-    /**
-     * Execute all plugins registered hook.
-     *
-     * @param string        $hook   name of the hook to trigger.
-     * @param array         $data   list of data to manipulate passed by reference.
-     * @param array         $params additional parameters such as page target.
-     *
-     * @return void
-     */
-    public function executeHooks($hook, &$data, $params = array())
-    {
-        if (!empty($params['target'])) {
-            $data['_PAGE_'] = $params['target'];
-        }
-
-        if (isset($params['loggedin'])) {
-            $data['_LOGGEDIN_'] = $params['loggedin'];
-        }
-
-        foreach ($this->loadedPlugins as $plugin) {
-            $hookFunction = $this->buildHookName($hook, $plugin);
-
-            if (function_exists($hookFunction)) {
-                $data = call_user_func($hookFunction, $data, $this->conf);
-            }
-        }
-    }
-
-    /**
-     * Load a single plugin from its files.
-     * Add them in $loadedPlugins if successful.
-     *
-     * @param string $dir        plugin's directory.
-     * @param string $pluginName plugin's name.
-     *
-     * @return void
-     * @throws PluginFileNotFoundException - plugin files not found.
-     */
-    private function loadPlugin($dir, $pluginName)
-    {
-        if (!is_dir($dir)) {
-            throw new PluginFileNotFoundException($pluginName);
-        }
-
-        $pluginFilePath = $dir . '/' . $pluginName . '.php';
-        if (!is_file($pluginFilePath)) {
-            throw new PluginFileNotFoundException($pluginName);
-        }
-
-        $conf = $this->conf;
-        include_once $pluginFilePath;
-
-        $this->loadedPlugins[] = $pluginName;
-    }
-
-    /**
-     * Construct normalize hook name for a specific plugin.
-     *
-     * Format:
-     *      hook__
-     *
-     * @param string $hook       hook name.
-     * @param string $pluginName plugin name.
-     *
-     * @return string - plugin's hook name.
-     */
-    public function buildHookName($hook, $pluginName)
-    {
-        return 'hook_' . $pluginName . '_' . $hook;
-    }
-
-    /**
-     * Retrieve plugins metadata from *.meta (INI) files into an array.
-     * Metadata contains:
-     *   - plugin description [description]
-     *   - parameters split with ';' [parameters]
-     *
-     * Respects plugins order from settings.
-     *
-     * @return array plugins metadata.
-     */
-    public function getPluginsMeta()
-    {
-        $metaData = array();
-        $dirs = glob(self::$PLUGINS_PATH . '/*', GLOB_ONLYDIR | GLOB_MARK);
-
-        // Browse all plugin directories.
-        foreach ($dirs as $pluginDir) {
-            $plugin = basename($pluginDir);
-            $metaFile = $pluginDir . $plugin . '.' . self::$META_EXT;
-            if (!is_file($metaFile) || !is_readable($metaFile)) {
-                continue;
-            }
-
-            $metaData[$plugin] = parse_ini_file($metaFile);
-            $metaData[$plugin]['order'] = array_search($plugin, $this->authorizedPlugins);
-
-            // Read parameters and format them into an array.
-            if (isset($metaData[$plugin]['parameters'])) {
-                $params = explode(';', $metaData[$plugin]['parameters']);
-            } else {
-                $params = array();
-            }
-            $metaData[$plugin]['parameters'] = array();
-            foreach ($params as $param) {
-                if (empty($param)) {
-                    continue;
-                }
-
-                $metaData[$plugin]['parameters'][$param]['value'] = '';
-                // Optional parameter description in parameter.PARAM_NAME=
-                if (isset($metaData[$plugin]['parameter.'. $param])) {
-                    $metaData[$plugin]['parameters'][$param]['desc'] = $metaData[$plugin]['parameter.'. $param];
-                }
-            }
-        }
-
-        return $metaData;
-    }
-}
-
-/**
- * Class PluginFileNotFoundException
- *
- * Raise when plugin files can't be found.
- */
-class PluginFileNotFoundException extends Exception
-{
-    /**
-     * Construct exception with plugin name.
-     * Generate message.
-     *
-     * @param string $pluginName name of the plugin not found
-     */
-    public function __construct($pluginName)
-    {
-        $this->message = 'Plugin "'. $pluginName .'" files not found.';
-    }
-}
diff --git a/application/Router.php b/application/Router.php
deleted file mode 100644
index caed4a2..0000000
--- a/application/Router.php
+++ /dev/null
@@ -1,141 +0,0 @@
-'.$city.'';
-        }
-    }
-
-    $continentsHtml = '';
-    $continents = array_keys($continents);
-
-    foreach ($continents as $continent) {
-        $continentsHtml .= '
'; - die; - } - if (!isset($_SESSION['session_tested'])) - { // Step 1 : Try to store data in session and reload page. - $_SESSION['session_tested'] = 'Working'; // Try to set a variable in session. - header('Location: '.index_url($_SERVER).'?test_session'); // Redirect to check stored data. - } - if (isset($_GET['test_session'])) - { // Step 3: Sessions are OK. Remove test parameter from URL. - header('Location: '.index_url($_SERVER)); - } - - - if (!empty($_POST['setlogin']) && !empty($_POST['setpassword'])) - { - $tz = 'UTC'; - if (!empty($_POST['continent']) && !empty($_POST['city']) - && isTimeZoneValid($_POST['continent'], $_POST['city']) - ) { - $tz = $_POST['continent'].'/'.$_POST['city']; - } - $conf->set('general.timezone', $tz); - $login = $_POST['setlogin']; - $conf->set('credentials.login', $login); - $salt = sha1(uniqid('', true) .'_'. mt_rand()); - $conf->set('credentials.salt', $salt); - $conf->set('credentials.hash', sha1($_POST['setpassword'] . $login . $salt)); - if (!empty($_POST['title'])) { - $conf->set('general.title', escape($_POST['title'])); - } else { - $conf->set('general.title', 'Shared links on '.escape(index_url($_SERVER))); - } - $conf->set('updates.check_updates', !empty($_POST['updateCheck'])); - try { - // Everything is ok, let's create config file. - $conf->write(isLoggedIn()); - } - catch(Exception $e) { - error_log( - 'ERROR while writing config file after installation.' . PHP_EOL . - $e->getMessage() - ); - - // TODO: do not handle exceptions/errors in JS. - echo ''; - exit; - } - echo ''; - exit; - } - - // Display config form: - list($timezone_form, $timezone_js) = generateTimeZoneForm(); - $timezone_html = ''; - if ($timezone_form != '') { - $timezone_html = 'Timezone:'.$timezone_form.''; - } - - $PAGE = new PageBuilder($conf); - $PAGE->assign('timezone_html',$timezone_html); - $PAGE->assign('timezone_js',$timezone_js); - $PAGE->renderPage('install'); - exit; -} - -/** - * Because some f*cking services like flickr require an extra HTTP request to get the thumbnail URL, - * I have deported the thumbnail URL code generation here, otherwise this would slow down page generation. - * The following function takes the URL a link (e.g. a flickr page) and return the proper thumbnail. - * This function is called by passing the URL: - * http://mywebsite.com/shaarli/?do=genthumbnail&hmac=[HMAC]&url=[URL] - * [URL] is the URL of the link (e.g. a flickr page) - * [HMAC] is the signature for the [URL] (so that these URL cannot be forged). - * The function below will fetch the image from the webservice and store it in the cache. - * - * @param ConfigManager $conf Configuration Manager instance, - */ -function genThumbnail($conf) -{ - // Make sure the parameters in the URL were generated by us. - $sign = hash_hmac('sha256', $_GET['url'], $conf->get('credentials.salt')); - if ($sign!=$_GET['hmac']) die('Naughty boy!'); - - $cacheDir = $conf->get('resource.thumbnails_cache', 'cache'); - // Let's see if we don't already have the image for this URL in the cache. - $thumbname=hash('sha1',$_GET['url']).'.jpg'; - if (is_file($cacheDir .'/'. $thumbname)) - { // We have the thumbnail, just serve it: - header('Content-Type: image/jpeg'); - echo file_get_contents($cacheDir .'/'. $thumbname); - return; - } - // We may also serve a blank image (if service did not respond) - $blankname=hash('sha1',$_GET['url']).'.gif'; - if (is_file($cacheDir .'/'. $blankname)) - { - header('Content-Type: image/gif'); - echo file_get_contents($cacheDir .'/'. $blankname); - return; - } - - // Otherwise, generate the thumbnail. - $url = $_GET['url']; - $domain = parse_url($url,PHP_URL_HOST); - - if ($domain=='flickr.com' || endsWith($domain,'.flickr.com')) - { - // Crude replacement to handle new flickr domain policy (They prefer www. now) - $url = str_replace('http://flickr.com/','http://www.flickr.com/',$url); - - // Is this a link to an image, or to a flickr page ? - $imageurl=''; - if (endsWith(parse_url($url, PHP_URL_PATH), '.jpg')) - { // This is a direct link to an image. e.g. http://farm1.staticflickr.com/5/5921913_ac83ed27bd_o.jpg - preg_match('!(http://farm\d+\.staticflickr\.com/\d+/\d+_\w+_)\w.jpg!',$url,$matches); - if (!empty($matches[1])) $imageurl=$matches[1].'m.jpg'; - } - else // This is a flickr page (html) - { - // Get the flickr html page. - list($headers, $content) = get_http_response($url, 20); - if (strpos($headers[0], '200 OK') !== false) - { - // flickr now nicely provides the URL of the thumbnail in each flickr page. - preg_match('! - if ($imageurl=='') - { - preg_match('! tag on that page - // http://www.ted.com/talks/mikko_hypponen_fighting_viruses_defending_the_net.html - // - list($headers, $content) = get_http_response($url, 5); - if (strpos($headers[0], '200 OK') !== false) { - // Extract the link to the thumbnail - preg_match('!link rel="image_src" href="(http://images.ted.com/images/ted/.+_\d+x\d+\.jpg)"!', $content, $matches); - if (!empty($matches[1])) - { // Let's download the image. - $imageurl=$matches[1]; - // No control on image size, so wait long enough - list($headers, $content) = get_http_response($imageurl, 20); - if (strpos($headers[0], '200 OK') !== false) { - $filepath = $cacheDir .'/'. $thumbname; - file_put_contents($filepath, $content); // Save image to cache. - if (resizeImage($filepath)) - { - header('Content-Type: image/jpeg'); - echo file_get_contents($filepath); - return; - } - } - } - } - } - - elseif ($domain=='xkcd.com' || endsWith($domain,'.xkcd.com')) - { - // There is no thumbnail available for xkcd comics, so download the whole image and resize it. - // http://xkcd.com/327/ - // <BLABLA> - list($headers, $content) = get_http_response($url, 5); - if (strpos($headers[0], '200 OK') !== false) { - // Extract the link to the thumbnail - preg_match('!` to includes.html template; then add `
` in the linklist template where you want the comments (in the linklist_plugins loop for example) - - -Problem: by default, Isso thread ID is guessed from the current url (only one thread per page). -if we want multiple threads on a single page (shaarli linklist), we must use : the `data-isso-id` client config, -with data-isso-id being the permalink of an item. - -`
` -`data-isso-id: Set a custom thread id, defaults to current URI.` - -Problem: feature is currently broken https://github.com/posativ/isso/issues/27 - -Another option, only display isso threads when current URL is a permalink (`\?(A-Z|a-z|0-9|-){7}`) (only show thread -when displaying only this link), and just display a "comments" button on each linklist item. Optionally show the comment -count on each item using the API (http://posativ.org/isso/docs/extras/api/#get-comment-count). API requests can be done -by raintpl `{function` or client-side with js. The former should be faster if isso and shaarli are on ther same server. - -Showing all full isso threads in the linklist would destroy layout - ------------------------------------------------------------ - -http://www.git-attitude.fr/2014/11/04/git-rerere/ for the merge diff --git a/plugins/addlink_toolbar/addlink_toolbar.css b/plugins/addlink_toolbar/addlink_toolbar.css deleted file mode 100644 index b6a612f..0000000 --- a/plugins/addlink_toolbar/addlink_toolbar.css +++ /dev/null @@ -1,4 +0,0 @@ -#addlink_toolbar { - display: inline; - margin: 0 0 0 25px; -} \ No newline at end of file diff --git a/plugins/addlink_toolbar/addlink_toolbar.html b/plugins/addlink_toolbar/addlink_toolbar.html deleted file mode 100644 index f38c41a..0000000 --- a/plugins/addlink_toolbar/addlink_toolbar.html +++ /dev/null @@ -1,6 +0,0 @@ - \ No newline at end of file diff --git a/plugins/addlink_toolbar/addlink_toolbar.meta b/plugins/addlink_toolbar/addlink_toolbar.meta deleted file mode 100644 index 2f0b586..0000000 --- a/plugins/addlink_toolbar/addlink_toolbar.meta +++ /dev/null @@ -1 +0,0 @@ -description="Adds the addlink input on the linklist page." diff --git a/plugins/addlink_toolbar/addlink_toolbar.php b/plugins/addlink_toolbar/addlink_toolbar.php deleted file mode 100644 index cfd7420..0000000 --- a/plugins/addlink_toolbar/addlink_toolbar.php +++ /dev/null @@ -1,38 +0,0 @@ - diff --git a/plugins/archiveorg/archiveorg.meta b/plugins/archiveorg/archiveorg.meta deleted file mode 100644 index 8b5703e..0000000 --- a/plugins/archiveorg/archiveorg.meta +++ /dev/null @@ -1 +0,0 @@ -description="For each link, add an Archive.org icon." diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php deleted file mode 100644 index 7d17258..0000000 --- a/plugins/archiveorg/archiveorg.php +++ /dev/null @@ -1,25 +0,0 @@ -DEMO_buttons_toolbar'; - } - - // Fields in toolbar - $data['fields_toolbar'][] = 'DEMO_fields_toolbar'; - } - // Another button always displayed - $data['buttons_toolbar'][] = '
  • DEMO
  • '; - - return $data; -} - -/** - * Hook render_includes. - * Executed on every page redering. - * - * Template placeholders: - * - css_files - * - * Data: - * - _PAGE_: current page - * - _LOGGEDIN_: true/false - * - * @param array $data data passed to plugin - * - * @return array altered $data. - */ -function hook_demo_plugin_render_includes($data) -{ - // List of plugin's CSS files. - // Note that you just need to specify CSS path. - $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/demo_plugin/custom_demo.css'; - - return $data; -} - -/** - * Hook render_footer. - * Executed on every page redering. - * - * Template placeholders: - * - text - * - endofpage - * - js_files - * - * Data: - * - _PAGE_: current page - * - _LOGGEDIN_: true/false - * - * @param array $data data passed to plugin - * - * @return array altered $data. - */ -function hook_demo_plugin_render_footer($data) -{ - // footer text - $data['text'][] = 'Shaarli is now enhanced by the awesome demo_plugin.'; - - // Free elements at the end of the page. - $data['endofpage'][] = '' . - 'DEMO: it\'s 1999 all over again!' . - ''; - - // List of plugin's JS files. - // Note that you just need to specify CSS path. - $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/demo_plugin/demo_plugin.js'; - - return $data; -} - -/* - * SPECIFIC PAGES - */ - -/** - * Hook render_linklist. - * - * Template placeholders: - * - action_plugin: next to 'private only' button. - * - plugin_start_zone: page start - * - plugin_end_zone: page end - * - link_plugin: icons below each links. - * - * Data: - * - _LOGGEDIN_: true/false - * - * @param array $data data passed to plugin - * - * @return array altered $data. - */ -function hook_demo_plugin_render_linklist($data) -{ - // action_plugin - $data['action_plugin'][] = ''; - - if (isset($_GET['up'])) { - // Manipulate link data - foreach ($data['links'] as &$value) { - $value['description'] = strtoupper($value['description']); - $value['title'] = strtoupper($value['title']); - } - } - - // link_plugin (for each link) - foreach ($data['links'] as &$value) { - $value['link_plugin'][] = ' DEMO \o/'; - } - - // plugin_start_zone - $data['plugin_start_zone'][] = '
    BEFORE
    '; - // plugin_start_zone - $data['plugin_end_zone'][] = '
    AFTER
    '; - - return $data; -} - -/** - * Hook render_editlink. - * - * Template placeholders: - * - field_plugin: add link fields after tags. - * - * @param array $data data passed to plugin - * - * @return array altered $data. - */ -function hook_demo_plugin_render_editlink($data) -{ - // Load HTML into a string - $html = file_get_contents(PluginManager::$PLUGINS_PATH .'/demo_plugin/field.html'); - - // replace value in HTML if it exists in $data - if (!empty($data['link']['stuff'])) { - $html = sprintf($html, $data['link']['stuff']); - } else { - $html = sprintf($html, ''); - } - - // field_plugin - $data['edit_link_plugin'][] = $html; - - return $data; -} - -/** - * Hook render_tools. - * - * Template placeholders: - * - tools_plugin: after other tools. - * - * @param array $data data passed to plugin - * - * @return array altered $data. - */ -function hook_demo_plugin_render_tools($data) -{ - // field_plugin - $data['tools_plugin'][] = 'tools_plugin'; - - return $data; -} - -/** - * Hook render_picwall. - * - * Template placeholders: - * - plugin_start_zone: page start. - * - plugin_end_zone: page end. - * - * Data: - * - _LOGGEDIN_: true/false - * - * @param array $data data passed to plugin - * - * @return array altered $data. - */ -function hook_demo_plugin_render_picwall($data) -{ - // plugin_start_zone - $data['plugin_start_zone'][] = '
    BEFORE
    '; - // plugin_end_zone - $data['plugin_end_zone'][] = '
    AFTER
    '; - - return $data; -} - -/** - * Hook render_tagcloud. - * - * Template placeholders: - * - plugin_start_zone: page start. - * - plugin_end_zone: page end. - * - * Data: - * - _LOGGEDIN_: true/false - * - * @param array $data data passed to plugin - * - * @return array altered $data. - */ -function hook_demo_plugin_render_tagcloud($data) -{ - // plugin_start_zone - $data['plugin_start_zone'][] = '
    BEFORE
    '; - // plugin_end_zone - $data['plugin_end_zone'][] = '
    AFTER
    '; - - return $data; -} - -/** - * Hook render_daily. - * - * Template placeholders: - * - plugin_start_zone: page start. - * - plugin_end_zone: page end. - * - * Data: - * - _LOGGEDIN_: true/false - * - * @param array $data data passed to plugin - * - * @return array altered $data. - */ -function hook_demo_plugin_render_daily($data) -{ - // plugin_start_zone - $data['plugin_start_zone'][] = '
    BEFORE
    '; - // plugin_end_zone - $data['plugin_end_zone'][] = '
    AFTER
    '; - - - // Manipulate columns data - foreach ($data['cols'] as &$value) { - foreach ($value as &$value2) { - $value2['formatedDescription'] .= ' ಠ_ಠ'; - } - } - - // Add plugin content at the end of each link - foreach ($data['cols'] as &$value) { - foreach ($value as &$value2) { - $value2['link_plugin'][] = 'DEMO'; - } - } - - return $data; -} - -/* - * DATA SAVING HOOK. - */ - -/** - * Hook savelink. - * - * Triggered when a link is save (new or edit). - * All new links now contain a 'stuff' value. - * - * @param array $data contains the new link data. - * - * @return array altered $data. - */ -function hook_demo_plugin_save_link($data) -{ - - // Save stuff added in editlink field - if (!empty($_POST['lf_stuff'])) { - $data['stuff'] = escape($_POST['lf_stuff']); - } - - return $data; -} - -/** - * Hook delete_link. - * - * Triggered when a link is deleted. - * - * @param array $data contains the link to be deleted. - * - * @return array altered data. - */ -function hook_demo_plugin_delete_link($data) -{ - if (strpos($data['url'], 'youtube.com') !== false) { - exit('You can not delete a YouTube link. Don\'t ask.'); - } -} - -/** - * Execute render_feed hook. - * Called with ATOM and RSS feed. - * - * Special data keys: - * - _PAGE_: current page - * - _LOGGEDIN_: true/false - * - * @param array $data data passed to plugin - * - * @return array altered $data. - */ -function hook_demo_plugin_render_feed($data) -{ - foreach ($data['links'] as &$link) { - if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { - $link['description'] .= ' - ATOM Feed' ; - } - elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { - $link['description'] .= ' - RSS Feed'; - } - } - return $data; -} diff --git a/plugins/demo_plugin/field.html b/plugins/demo_plugin/field.html deleted file mode 100644 index 00281c4..0000000 --- a/plugins/demo_plugin/field.html +++ /dev/null @@ -1,2 +0,0 @@ -
    -
    \ No newline at end of file diff --git a/plugins/markdown/Parsedown.php b/plugins/markdown/Parsedown.php deleted file mode 100644 index 91e05dc..0000000 --- a/plugins/markdown/Parsedown.php +++ /dev/null @@ -1,1528 +0,0 @@ -DefinitionData = array(); - - # standardize line breaks - $text = str_replace(array("\r\n", "\r"), "\n", $text); - - # remove surrounding line breaks - $text = trim($text, "\n"); - - # split text into lines - $lines = explode("\n", $text); - - # iterate through lines to identify blocks - $markup = $this->lines($lines); - - # trim line breaks - $markup = trim($markup, "\n"); - - return $markup; - } - - # - # Setters - # - - function setBreaksEnabled($breaksEnabled) - { - $this->breaksEnabled = $breaksEnabled; - - return $this; - } - - protected $breaksEnabled; - - function setMarkupEscaped($markupEscaped) - { - $this->markupEscaped = $markupEscaped; - - return $this; - } - - protected $markupEscaped; - - function setUrlsLinked($urlsLinked) - { - $this->urlsLinked = $urlsLinked; - - return $this; - } - - protected $urlsLinked = true; - - # - # Lines - # - - protected $BlockTypes = array( - '#' => array('Header'), - '*' => array('Rule', 'List'), - '+' => array('List'), - '-' => array('SetextHeader', 'Table', 'Rule', 'List'), - '0' => array('List'), - '1' => array('List'), - '2' => array('List'), - '3' => array('List'), - '4' => array('List'), - '5' => array('List'), - '6' => array('List'), - '7' => array('List'), - '8' => array('List'), - '9' => array('List'), - ':' => array('Table'), - '<' => array('Comment', 'Markup'), - '=' => array('SetextHeader'), - '>' => array('Quote'), - '[' => array('Reference'), - '_' => array('Rule'), - '`' => array('FencedCode'), - '|' => array('Table'), - '~' => array('FencedCode'), - ); - - # ~ - - protected $unmarkedBlockTypes = array( - 'Code', - ); - - # - # Blocks - # - - private function lines(array $lines) - { - $CurrentBlock = null; - - foreach ($lines as $line) - { - if (chop($line) === '') - { - if (isset($CurrentBlock)) - { - $CurrentBlock['interrupted'] = true; - } - - continue; - } - - if (strpos($line, "\t") !== false) - { - $parts = explode("\t", $line); - - $line = $parts[0]; - - unset($parts[0]); - - foreach ($parts as $part) - { - $shortage = 4 - mb_strlen($line, 'utf-8') % 4; - - $line .= str_repeat(' ', $shortage); - $line .= $part; - } - } - - $indent = 0; - - while (isset($line[$indent]) and $line[$indent] === ' ') - { - $indent ++; - } - - $text = $indent > 0 ? substr($line, $indent) : $line; - - # ~ - - $Line = array('body' => $line, 'indent' => $indent, 'text' => $text); - - # ~ - - if (isset($CurrentBlock['continuable'])) - { - $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock); - - if (isset($Block)) - { - $CurrentBlock = $Block; - - continue; - } - else - { - if (method_exists($this, 'block'.$CurrentBlock['type'].'Complete')) - { - $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); - } - } - } - - # ~ - - $marker = $text[0]; - - # ~ - - $blockTypes = $this->unmarkedBlockTypes; - - if (isset($this->BlockTypes[$marker])) - { - foreach ($this->BlockTypes[$marker] as $blockType) - { - $blockTypes []= $blockType; - } - } - - # - # ~ - - foreach ($blockTypes as $blockType) - { - $Block = $this->{'block'.$blockType}($Line, $CurrentBlock); - - if (isset($Block)) - { - $Block['type'] = $blockType; - - if ( ! isset($Block['identified'])) - { - $Blocks []= $CurrentBlock; - - $Block['identified'] = true; - } - - if (method_exists($this, 'block'.$blockType.'Continue')) - { - $Block['continuable'] = true; - } - - $CurrentBlock = $Block; - - continue 2; - } - } - - # ~ - - if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted'])) - { - $CurrentBlock['element']['text'] .= "\n".$text; - } - else - { - $Blocks []= $CurrentBlock; - - $CurrentBlock = $this->paragraph($Line); - - $CurrentBlock['identified'] = true; - } - } - - # ~ - - if (isset($CurrentBlock['continuable']) and method_exists($this, 'block'.$CurrentBlock['type'].'Complete')) - { - $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); - } - - # ~ - - $Blocks []= $CurrentBlock; - - unset($Blocks[0]); - - # ~ - - $markup = ''; - - foreach ($Blocks as $Block) - { - if (isset($Block['hidden'])) - { - continue; - } - - $markup .= "\n"; - $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']); - } - - $markup .= "\n"; - - # ~ - - return $markup; - } - - # - # Code - - protected function blockCode($Line, $Block = null) - { - if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted'])) - { - return; - } - - if ($Line['indent'] >= 4) - { - $text = substr($Line['body'], 4); - - $Block = array( - 'element' => array( - 'name' => 'pre', - 'handler' => 'element', - 'text' => array( - 'name' => 'code', - 'text' => $text, - ), - ), - ); - - return $Block; - } - } - - protected function blockCodeContinue($Line, $Block) - { - if ($Line['indent'] >= 4) - { - if (isset($Block['interrupted'])) - { - $Block['element']['text']['text'] .= "\n"; - - unset($Block['interrupted']); - } - - $Block['element']['text']['text'] .= "\n"; - - $text = substr($Line['body'], 4); - - $Block['element']['text']['text'] .= $text; - - return $Block; - } - } - - protected function blockCodeComplete($Block) - { - $text = $Block['element']['text']['text']; - - $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8'); - - $Block['element']['text']['text'] = $text; - - return $Block; - } - - # - # Comment - - protected function blockComment($Line) - { - if ($this->markupEscaped) - { - return; - } - - if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') - { - $Block = array( - 'markup' => $Line['body'], - ); - - if (preg_match('/-->$/', $Line['text'])) - { - $Block['closed'] = true; - } - - return $Block; - } - } - - protected function blockCommentContinue($Line, array $Block) - { - if (isset($Block['closed'])) - { - return; - } - - $Block['markup'] .= "\n" . $Line['body']; - - if (preg_match('/-->$/', $Line['text'])) - { - $Block['closed'] = true; - } - - return $Block; - } - - # - # Fenced Code - - protected function blockFencedCode($Line) - { - if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches)) - { - $Element = array( - 'name' => 'code', - 'text' => '', - ); - - if (isset($matches[1])) - { - $class = 'language-'.$matches[1]; - - $Element['attributes'] = array( - 'class' => $class, - ); - } - - $Block = array( - 'char' => $Line['text'][0], - 'element' => array( - 'name' => 'pre', - 'handler' => 'element', - 'text' => $Element, - ), - ); - - return $Block; - } - } - - protected function blockFencedCodeContinue($Line, $Block) - { - if (isset($Block['complete'])) - { - return; - } - - if (isset($Block['interrupted'])) - { - $Block['element']['text']['text'] .= "\n"; - - unset($Block['interrupted']); - } - - if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text'])) - { - $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1); - - $Block['complete'] = true; - - return $Block; - } - - $Block['element']['text']['text'] .= "\n".$Line['body'];; - - return $Block; - } - - protected function blockFencedCodeComplete($Block) - { - $text = $Block['element']['text']['text']; - - $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8'); - - $Block['element']['text']['text'] = $text; - - return $Block; - } - - # - # Header - - protected function blockHeader($Line) - { - if (isset($Line['text'][1])) - { - $level = 1; - - while (isset($Line['text'][$level]) and $Line['text'][$level] === '#') - { - $level ++; - } - - if ($level > 6) - { - return; - } - - $text = trim($Line['text'], '# '); - - $Block = array( - 'element' => array( - 'name' => 'h' . min(6, $level), - 'text' => $text, - 'handler' => 'line', - ), - ); - - return $Block; - } - } - - # - # List - - protected function blockList($Line) - { - list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]'); - - if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches)) - { - $Block = array( - 'indent' => $Line['indent'], - 'pattern' => $pattern, - 'element' => array( - 'name' => $name, - 'handler' => 'elements', - ), - ); - - $Block['li'] = array( - 'name' => 'li', - 'handler' => 'li', - 'text' => array( - $matches[2], - ), - ); - - $Block['element']['text'] []= & $Block['li']; - - return $Block; - } - } - - protected function blockListContinue($Line, array $Block) - { - if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) - { - if (isset($Block['interrupted'])) - { - $Block['li']['text'] []= ''; - - unset($Block['interrupted']); - } - - unset($Block['li']); - - $text = isset($matches[1]) ? $matches[1] : ''; - - $Block['li'] = array( - 'name' => 'li', - 'handler' => 'li', - 'text' => array( - $text, - ), - ); - - $Block['element']['text'] []= & $Block['li']; - - return $Block; - } - - if ($Line['text'][0] === '[' and $this->blockReference($Line)) - { - return $Block; - } - - if ( ! isset($Block['interrupted'])) - { - $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); - - $Block['li']['text'] []= $text; - - return $Block; - } - - if ($Line['indent'] > 0) - { - $Block['li']['text'] []= ''; - - $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); - - $Block['li']['text'] []= $text; - - unset($Block['interrupted']); - - return $Block; - } - } - - # - # Quote - - protected function blockQuote($Line) - { - if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) - { - $Block = array( - 'element' => array( - 'name' => 'blockquote', - 'handler' => 'lines', - 'text' => (array) $matches[1], - ), - ); - - return $Block; - } - } - - protected function blockQuoteContinue($Line, array $Block) - { - if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) - { - if (isset($Block['interrupted'])) - { - $Block['element']['text'] []= ''; - - unset($Block['interrupted']); - } - - $Block['element']['text'] []= $matches[1]; - - return $Block; - } - - if ( ! isset($Block['interrupted'])) - { - $Block['element']['text'] []= $Line['text']; - - return $Block; - } - } - - # - # Rule - - protected function blockRule($Line) - { - if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text'])) - { - $Block = array( - 'element' => array( - 'name' => 'hr' - ), - ); - - return $Block; - } - } - - # - # Setext - - protected function blockSetextHeader($Line, array $Block = null) - { - if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) - { - return; - } - - if (chop($Line['text'], $Line['text'][0]) === '') - { - $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2'; - - return $Block; - } - } - - # - # Markup - - protected function blockMarkup($Line) - { - if ($this->markupEscaped) - { - return; - } - - if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches)) - { - $element = strtolower($matches[1]); - - if (in_array($element, $this->textLevelElements)) - { - return; - } - - $Block = array( - 'name' => $matches[1], - 'depth' => 0, - 'markup' => $Line['text'], - ); - - $length = strlen($matches[0]); - - $remainder = substr($Line['text'], $length); - - if (trim($remainder) === '') - { - if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) - { - $Block['closed'] = true; - - $Block['void'] = true; - } - } - else - { - if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) - { - return; - } - - if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder)) - { - $Block['closed'] = true; - } - } - - return $Block; - } - } - - protected function blockMarkupContinue($Line, array $Block) - { - if (isset($Block['closed'])) - { - return; - } - - if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open - { - $Block['depth'] ++; - } - - if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close - { - if ($Block['depth'] > 0) - { - $Block['depth'] --; - } - else - { - $Block['closed'] = true; - } - } - - if (isset($Block['interrupted'])) - { - $Block['markup'] .= "\n"; - - unset($Block['interrupted']); - } - - $Block['markup'] .= "\n".$Line['body']; - - return $Block; - } - - # - # Reference - - protected function blockReference($Line) - { - if (preg_match('/^\[(.+?)\]:[ ]*?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches)) - { - $id = strtolower($matches[1]); - - $Data = array( - 'url' => $matches[2], - 'title' => null, - ); - - if (isset($matches[3])) - { - $Data['title'] = $matches[3]; - } - - $this->DefinitionData['Reference'][$id] = $Data; - - $Block = array( - 'hidden' => true, - ); - - return $Block; - } - } - - # - # Table - - protected function blockTable($Line, array $Block = null) - { - if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) - { - return; - } - - if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '') - { - $alignments = array(); - - $divider = $Line['text']; - - $divider = trim($divider); - $divider = trim($divider, '|'); - - $dividerCells = explode('|', $divider); - - foreach ($dividerCells as $dividerCell) - { - $dividerCell = trim($dividerCell); - - if ($dividerCell === '') - { - continue; - } - - $alignment = null; - - if ($dividerCell[0] === ':') - { - $alignment = 'left'; - } - - if (substr($dividerCell, - 1) === ':') - { - $alignment = $alignment === 'left' ? 'center' : 'right'; - } - - $alignments []= $alignment; - } - - # ~ - - $HeaderElements = array(); - - $header = $Block['element']['text']; - - $header = trim($header); - $header = trim($header, '|'); - - $headerCells = explode('|', $header); - - foreach ($headerCells as $index => $headerCell) - { - $headerCell = trim($headerCell); - - $HeaderElement = array( - 'name' => 'th', - 'text' => $headerCell, - 'handler' => 'line', - ); - - if (isset($alignments[$index])) - { - $alignment = $alignments[$index]; - - $HeaderElement['attributes'] = array( - 'style' => 'text-align: '.$alignment.';', - ); - } - - $HeaderElements []= $HeaderElement; - } - - # ~ - - $Block = array( - 'alignments' => $alignments, - 'identified' => true, - 'element' => array( - 'name' => 'table', - 'handler' => 'elements', - ), - ); - - $Block['element']['text'] []= array( - 'name' => 'thead', - 'handler' => 'elements', - ); - - $Block['element']['text'] []= array( - 'name' => 'tbody', - 'handler' => 'elements', - 'text' => array(), - ); - - $Block['element']['text'][0]['text'] []= array( - 'name' => 'tr', - 'handler' => 'elements', - 'text' => $HeaderElements, - ); - - return $Block; - } - } - - protected function blockTableContinue($Line, array $Block) - { - if (isset($Block['interrupted'])) - { - return; - } - - if ($Line['text'][0] === '|' or strpos($Line['text'], '|')) - { - $Elements = array(); - - $row = $Line['text']; - - $row = trim($row); - $row = trim($row, '|'); - - preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches); - - foreach ($matches[0] as $index => $cell) - { - $cell = trim($cell); - - $Element = array( - 'name' => 'td', - 'handler' => 'line', - 'text' => $cell, - ); - - if (isset($Block['alignments'][$index])) - { - $Element['attributes'] = array( - 'style' => 'text-align: '.$Block['alignments'][$index].';', - ); - } - - $Elements []= $Element; - } - - $Element = array( - 'name' => 'tr', - 'handler' => 'elements', - 'text' => $Elements, - ); - - $Block['element']['text'][1]['text'] []= $Element; - - return $Block; - } - } - - # - # ~ - # - - protected function paragraph($Line) - { - $Block = array( - 'element' => array( - 'name' => 'p', - 'text' => $Line['text'], - 'handler' => 'line', - ), - ); - - return $Block; - } - - # - # Inline Elements - # - - protected $InlineTypes = array( - '"' => array('SpecialCharacter'), - '!' => array('Image'), - '&' => array('SpecialCharacter'), - '*' => array('Emphasis'), - ':' => array('Url'), - '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'), - '>' => array('SpecialCharacter'), - '[' => array('Link'), - '_' => array('Emphasis'), - '`' => array('Code'), - '~' => array('Strikethrough'), - '\\' => array('EscapeSequence'), - ); - - # ~ - - protected $inlineMarkerList = '!"*_&[:<>`~\\'; - - # - # ~ - # - - public function line($text) - { - $markup = ''; - - # $excerpt is based on the first occurrence of a marker - - while ($excerpt = strpbrk($text, $this->inlineMarkerList)) - { - $marker = $excerpt[0]; - - $markerPosition = strpos($text, $marker); - - $Excerpt = array('text' => $excerpt, 'context' => $text); - - foreach ($this->InlineTypes[$marker] as $inlineType) - { - $Inline = $this->{'inline'.$inlineType}($Excerpt); - - if ( ! isset($Inline)) - { - continue; - } - - # makes sure that the inline belongs to "our" marker - - if (isset($Inline['position']) and $Inline['position'] > $markerPosition) - { - continue; - } - - # sets a default inline position - - if ( ! isset($Inline['position'])) - { - $Inline['position'] = $markerPosition; - } - - # the text that comes before the inline - $unmarkedText = substr($text, 0, $Inline['position']); - - # compile the unmarked text - $markup .= $this->unmarkedText($unmarkedText); - - # compile the inline - $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']); - - # remove the examined text - $text = substr($text, $Inline['position'] + $Inline['extent']); - - continue 2; - } - - # the marker does not belong to an inline - - $unmarkedText = substr($text, 0, $markerPosition + 1); - - $markup .= $this->unmarkedText($unmarkedText); - - $text = substr($text, $markerPosition + 1); - } - - $markup .= $this->unmarkedText($text); - - return $markup; - } - - # - # ~ - # - - protected function inlineCode($Excerpt) - { - $marker = $Excerpt['text'][0]; - - if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(? strlen($matches[0]), - 'element' => array( - 'name' => 'code', - 'text' => $text, - ), - ); - } - } - - protected function inlineEmailTag($Excerpt) - { - if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) - { - $url = $matches[1]; - - if ( ! isset($matches[2])) - { - $url = 'mailto:' . $url; - } - - return array( - 'extent' => strlen($matches[0]), - 'element' => array( - 'name' => 'a', - 'text' => $matches[1], - 'attributes' => array( - 'href' => $url, - ), - ), - ); - } - } - - protected function inlineEmphasis($Excerpt) - { - if ( ! isset($Excerpt['text'][1])) - { - return; - } - - $marker = $Excerpt['text'][0]; - - if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) - { - $emphasis = 'strong'; - } - elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) - { - $emphasis = 'em'; - } - else - { - return; - } - - return array( - 'extent' => strlen($matches[0]), - 'element' => array( - 'name' => $emphasis, - 'handler' => 'line', - 'text' => $matches[1], - ), - ); - } - - protected function inlineEscapeSequence($Excerpt) - { - if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) - { - return array( - 'markup' => $Excerpt['text'][1], - 'extent' => 2, - ); - } - } - - protected function inlineImage($Excerpt) - { - if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') - { - return; - } - - $Excerpt['text']= substr($Excerpt['text'], 1); - - $Link = $this->inlineLink($Excerpt); - - if ($Link === null) - { - return; - } - - $Inline = array( - 'extent' => $Link['extent'] + 1, - 'element' => array( - 'name' => 'img', - 'attributes' => array( - 'src' => $Link['element']['attributes']['href'], - 'alt' => $Link['element']['text'], - ), - ), - ); - - $Inline['element']['attributes'] += $Link['element']['attributes']; - - unset($Inline['element']['attributes']['href']); - - return $Inline; - } - - protected function inlineLink($Excerpt) - { - $Element = array( - 'name' => 'a', - 'handler' => 'line', - 'text' => null, - 'attributes' => array( - 'href' => null, - 'title' => null, - ), - ); - - $extent = 0; - - $remainder = $Excerpt['text']; - - if (preg_match('/\[((?:[^][]|(?R))*)\]/', $remainder, $matches)) - { - $Element['text'] = $matches[1]; - - $extent += strlen($matches[0]); - - $remainder = substr($remainder, $extent); - } - else - { - return; - } - - if (preg_match('/^[(]((?:[^ ()]|[(][^ )]+[)])+)(?:[ ]+("[^"]*"|\'[^\']*\'))?[)]/', $remainder, $matches)) - { - $Element['attributes']['href'] = $matches[1]; - - if (isset($matches[2])) - { - $Element['attributes']['title'] = substr($matches[2], 1, - 1); - } - - $extent += strlen($matches[0]); - } - else - { - if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches)) - { - $definition = strlen($matches[1]) ? $matches[1] : $Element['text']; - $definition = strtolower($definition); - - $extent += strlen($matches[0]); - } - else - { - $definition = strtolower($Element['text']); - } - - if ( ! isset($this->DefinitionData['Reference'][$definition])) - { - return; - } - - $Definition = $this->DefinitionData['Reference'][$definition]; - - $Element['attributes']['href'] = $Definition['url']; - $Element['attributes']['title'] = $Definition['title']; - } - - $Element['attributes']['href'] = str_replace(array('&', '<'), array('&', '<'), $Element['attributes']['href']); - - return array( - 'extent' => $extent, - 'element' => $Element, - ); - } - - protected function inlineMarkup($Excerpt) - { - if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false) - { - return; - } - - if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w*[ ]*>/s', $Excerpt['text'], $matches)) - { - return array( - 'markup' => $matches[0], - 'extent' => strlen($matches[0]), - ); - } - - if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches)) - { - return array( - 'markup' => $matches[0], - 'extent' => strlen($matches[0]), - ); - } - - if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches)) - { - return array( - 'markup' => $matches[0], - 'extent' => strlen($matches[0]), - ); - } - } - - protected function inlineSpecialCharacter($Excerpt) - { - if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text'])) - { - return array( - 'markup' => '&', - 'extent' => 1, - ); - } - - $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot'); - - if (isset($SpecialCharacter[$Excerpt['text'][0]])) - { - return array( - 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';', - 'extent' => 1, - ); - } - } - - protected function inlineStrikethrough($Excerpt) - { - if ( ! isset($Excerpt['text'][1])) - { - return; - } - - if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) - { - return array( - 'extent' => strlen($matches[0]), - 'element' => array( - 'name' => 'del', - 'text' => $matches[1], - 'handler' => 'line', - ), - ); - } - } - - protected function inlineUrl($Excerpt) - { - if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') - { - return; - } - - if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) - { - $Inline = array( - 'extent' => strlen($matches[0][0]), - 'position' => $matches[0][1], - 'element' => array( - 'name' => 'a', - 'text' => $matches[0][0], - 'attributes' => array( - 'href' => $matches[0][0], - ), - ), - ); - - return $Inline; - } - } - - protected function inlineUrlTag($Excerpt) - { - if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) - { - $url = str_replace(array('&', '<'), array('&', '<'), $matches[1]); - - return array( - 'extent' => strlen($matches[0]), - 'element' => array( - 'name' => 'a', - 'text' => $url, - 'attributes' => array( - 'href' => $url, - ), - ), - ); - } - } - - # ~ - - protected function unmarkedText($text) - { - if ($this->breaksEnabled) - { - $text = preg_replace('/[ ]*\n/', "
    \n", $text); - } - else - { - $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "
    \n", $text); - $text = str_replace(" \n", "\n", $text); - } - - return $text; - } - - # - # Handlers - # - - protected function element(array $Element) - { - $markup = '<'.$Element['name']; - - if (isset($Element['attributes'])) - { - foreach ($Element['attributes'] as $name => $value) - { - if ($value === null) - { - continue; - } - - $markup .= ' '.$name.'="'.$value.'"'; - } - } - - if (isset($Element['text'])) - { - $markup .= '>'; - - if (isset($Element['handler'])) - { - $markup .= $this->{$Element['handler']}($Element['text']); - } - else - { - $markup .= $Element['text']; - } - - $markup .= ''; - } - else - { - $markup .= ' />'; - } - - return $markup; - } - - protected function elements(array $Elements) - { - $markup = ''; - - foreach ($Elements as $Element) - { - $markup .= "\n" . $this->element($Element); - } - - $markup .= "\n"; - - return $markup; - } - - # ~ - - protected function li($lines) - { - $markup = $this->lines($lines); - - $trimmedMarkup = trim($markup); - - if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '

    ') - { - $markup = $trimmedMarkup; - $markup = substr($markup, 3); - - $position = strpos($markup, "

    "); - - $markup = substr_replace($markup, '', $position, 4); - } - - return $markup; - } - - # - # Deprecated Methods - # - - function parse($text) - { - $markup = $this->text($text); - - return $markup; - } - - # - # Static Methods - # - - static function instance($name = 'default') - { - if (isset(self::$instances[$name])) - { - return self::$instances[$name]; - } - - $instance = new static(); - - self::$instances[$name] = $instance; - - return $instance; - } - - private static $instances = array(); - - # - # Fields - # - - protected $DefinitionData; - - # - # Read-Only - - protected $specialCharacters = array( - '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', - ); - - protected $StrongRegex = array( - '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', - '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us', - ); - - protected $EmRegex = array( - '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', - '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', - ); - - protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?'; - - protected $voidElements = array( - 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', - ); - - protected $textLevelElements = array( - 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', - 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', - 'i', 'rp', 'del', 'code', 'strike', 'marquee', - 'q', 'rt', 'ins', 'font', 'strong', - 's', 'tt', 'sub', 'mark', - 'u', 'xm', 'sup', 'nobr', - 'var', 'ruby', - 'wbr', 'span', - 'time', - ); -} \ No newline at end of file diff --git a/plugins/markdown/README.md b/plugins/markdown/README.md deleted file mode 100644 index 4f02187..0000000 --- a/plugins/markdown/README.md +++ /dev/null @@ -1,63 +0,0 @@ -## Markdown Shaarli plugin - -Convert all your shaares description to HTML formatted Markdown. - -[Read more about Markdown syntax](http://daringfireball.net/projects/markdown/syntax). - -Markdown processing is done with [Parsedown library](https://github.com/erusev/parsedown). - -### Installation - -As a default plugin, it should already be in `tpl/plugins/` directory. -If not, download and unpack it there. - -The directory structure should look like: - -``` ---- plugins - |--- markdown - |--- help.html - |--- markdown.css - |--- markdown.meta - |--- markdown.php - |--- Parsedown.php - |--- README.md -``` - -To enable the plugin, just check it in the plugin administration page. - -You can also add `markdown` to your list of enabled plugins in `data/config.php` -(`ENABLED_PLUGINS` array). - -This should look like: - -``` -$GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode', 'any_other_plugin', 'markdown') -``` - -### No Markdown tag - -If the tag `.nomarkdown` is set for a shaare, it won't be converted to Markdown syntax. - -> Note: it's a private tag (leading dot), so it won't be displayed to visitors. - -### Known issue - -#### Redirector - -If you're using a redirector, you *need* to add a space after a link, -otherwise the rest of the line will be `urlencode`. - -``` -[link](http://domain.tld)-->test -``` - -Will consider `http://domain.tld)-->test` as URL. - -Instead, add an additional space. - -``` -[link](http://domain.tld) -->test -``` - -> Won't fix because a `)` is a valid part of an URL. diff --git a/plugins/markdown/help.html b/plugins/markdown/help.html deleted file mode 100644 index 9c4e5ae..0000000 --- a/plugins/markdown/help.html +++ /dev/null @@ -1,5 +0,0 @@ -
    - Description will be rendered with - - Markdown syntax. -
    diff --git a/plugins/markdown/markdown.css b/plugins/markdown/markdown.css deleted file mode 100644 index 6789ce8..0000000 --- a/plugins/markdown/markdown.css +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Credit to Simon Laroche - * whom created the CSS which this file is based on. - * License: Unlicense - */ - -.markdown p{ - margin:0.75em 0; -} - -.markdown img{ - max-width:100%; -} - -.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6{ - font-weight:normal; - font-style:normal; - line-height:1em; - margin:0.75em 0; -} -.markdown h4, .markdown h5, .markdown h6{ font-weight: bold; } -.markdown h1{ font-size:2.5em; } -.markdown h2{ font-size:2em; } -.markdown h3{ font-size:1.5em; } -.markdown h4{ font-size:1.2em; } -.markdown h5{ font-size:1em; } -.markdown h6{ font-size:0.9em; } - -.markdown blockquote{ - color:#666666; - padding-left: 3em; - border-left: 0.5em #EEE solid; - margin:0.75em 0; -} -.markdown hr { display: block; height: 2px; border: 0; border-top: 1px solid #aaa;border-bottom: 1px solid #eee; margin: 1em 0; padding: 0; } -.markdown pre, .markdown code, .markdown kbd, .markdown samp { - font-family: monospace, 'courier new'; - font-size: 0.98em; -} -.markdown pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; } - -.markdown b, .markdown strong { font-weight: bold; } - -.markdown dfn, .markdown em { font-style: italic; } - -.markdown ins { background: #ff9; color: #000; text-decoration: none; } - -.markdown mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; } - -.markdown sub, .markdown sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } -.markdown sup { top: -0.5em; } -.markdown sub { bottom: -0.25em; } - -.markdown ul, .markdown ol { margin: 1em 0; padding: 0 0 0 2em; } -.markdown li p:last-child { margin:0 } -.markdown dd { margin: 0 0 0 2em; } - -.markdown img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; } - -.markdown table { border-collapse: collapse; border-spacing: 0; } -.markdown td { vertical-align: top; } - -@media only screen and (min-width: 480px) { - .markdown {font-size:0.9em;} -} - -@media only screen and (min-width: 768px) { - .markdown {font-size:1em;} -} - -#linklist .markdown li { - padding: 0; - border: none; - background: none; -} - -#linklist .markdown ul li { - list-style: circle; -} - -#linklist .markdown ol li { - list-style: decimal; -} - -.markdown table { - padding: 0; -} -.markdown table tr { - border-top: 1px solid #cccccc; - background-color: white; - margin: 0; - padding: 0; -} -.markdown table tr:nth-child(2n) { - background-color: #f8f8f8; -} -.markdown table tr th { - font-weight: bold; - border: 1px solid #cccccc; - text-align: left; - margin: 0; - padding: 6px 13px; -} -.markdown table tr td { - border: 1px solid #cccccc; - text-align: left; - margin: 0; - padding: 6px 13px; -} -.markdown table tr th :first-child, .markdown table tr td :first-child { - margin-top: 0; -} -.markdown table tr th :last-child, table tr td :last-child { - margin-bottom: 0; -} - -.markdown pre { - background-color: #eee; - padding: 4px 9px; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; - overflow: auto; - box-shadow: 0 -1px 0 #e5e5e5,0 0 1px rgba(0,0,0,0.12),0 1px 2px rgba(0,0,0,0.24); -} - -.markdown pre code { - color: black; - font-family: 'Consolas', 'Monaco', 'Andale Mono', monospace; - direction: ltr; - text-align: left; - white-space: pre; - word-spacing: normal; - word-break: normal; - line-height: 1.7; - font-size: 11.5px; - -moz-tab-size: 4; - -o-tab-size: 4; - tab-size: 4; - -webkit-hyphens: none; - -moz-hyphens: none; - -ms-hyphens: none; - hyphens: none; -} - -.markdown :not(pre) code { - background-color: #eee; - padding: 1px 3px; - border-radius: 1px; - box-shadow: 0 -1px 0 #e5e5e5,0 0 1px rgba(0,0,0,0.12),0 1px 1px rgba(0,0,0,0.24); -} - -.md_help { - color: white; -} - -/* - Remove header links style - */ -#pageheader .md_help a { - color: lightgray; - font-weight: bold; - text-decoration: underline; - - background: none; - box-shadow: none; - padding: 0; - margin: 0; -} - -#pageheader .md_help a:hover { - color: white; -} diff --git a/plugins/markdown/markdown.meta b/plugins/markdown/markdown.meta deleted file mode 100644 index e3904ed..0000000 --- a/plugins/markdown/markdown.meta +++ /dev/null @@ -1 +0,0 @@ -description="Render shaare description with Markdown syntax." diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php deleted file mode 100644 index 6b1c1d4..0000000 --- a/plugins/markdown/markdown.php +++ /dev/null @@ -1,281 +0,0 @@ - 0; - // Detect and toggle block of code - if (!$codeBlockOn) { - $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0; - } - elseif (preg_match('/^```/', $descriptionLine) > 0) { - $codeBlockOn = false; - } - - $hashtagTitle = ' title="Hashtag [^"]+"'; - // Reverse `inline code` hashtags. - $descriptionLine = preg_replace( - '!(`[^`\n]*)([^<]+)([^`\n]*`)!m', - '$1$2$3', - $descriptionLine - ); - - // Reverse hashtag links if we're in a code block. - $hashtagFilter = ($codeBlockOn || $codeLineOn) ? $hashtagTitle : ''; - $descriptionLine = preg_replace( - '!([^<]+)!m', - '$1', - $descriptionLine - ); - - $descriptionOut .= $descriptionLine; - if ($lineCount++ < count($descriptionLines) - 1) { - $descriptionOut .= PHP_EOL; - } - } - return $descriptionOut; -} - -/** - * Remove
    tag to let markdown handle it. - * - * @param string $description input description text. - * - * @return string $description without
    tags. - */ -function reverse_nl2br($description) -{ - return preg_replace('!
    !im', '', $description); -} - -/** - * Remove HTML spaces ' ' auto generated by Shaarli core system. - * - * @param string $description input description text. - * - * @return string $description without HTML links. - */ -function reverse_space2nbsp($description) -{ - return preg_replace('/(^| ) /m', '$1 ', $description); -} - -/** - * Remove dangerous HTML tags (tags, iframe, etc.). - * Doesn't affect content (already escaped by Parsedown). - * - * @param string $description input description text. - * - * @return string given string escaped. - */ -function sanitize_html($description) -{ - $escapeTags = array( - 'script', - 'style', - 'link', - 'iframe', - 'frameset', - 'frame', - ); - foreach ($escapeTags as $tag) { - $description = preg_replace_callback( - '#<\s*'. $tag .'[^>]*>(.*]*>)?#is', - function ($match) { return escape($match[0]); }, - $description); - } - $description = preg_replace( - '#(<[^>]+)on[a-z]*="[^"]*"#is', - '$1', - $description); - return $description; -} - -/** - * Render shaare contents through Markdown parser. - * 1. Remove HTML generated by Shaarli core. - * 2. Reverse the escape function. - * 3. Generate markdown descriptions. - * 4. Sanitize sensible HTML tags for security. - * 5. Wrap description in 'markdown' CSS class. - * - * @param string $description input description text. - * - * @return string HTML processed $description. - */ -function process_markdown($description) -{ - $parsedown = new Parsedown(); - - $processedDescription = $description; - $processedDescription = reverse_nl2br($processedDescription); - $processedDescription = reverse_space2nbsp($processedDescription); - $processedDescription = reverse_text2clickable($processedDescription); - $processedDescription = unescape($processedDescription); - $processedDescription = $parsedown - ->setMarkupEscaped(false) - ->setBreaksEnabled(true) - ->text($processedDescription); - $processedDescription = sanitize_html($processedDescription); - - if(!empty($processedDescription)){ - $processedDescription = '
    '. $processedDescription . '
    '; - } - - return $processedDescription; -} diff --git a/plugins/playvideos/README.md b/plugins/playvideos/README.md deleted file mode 100644 index b169847..0000000 --- a/plugins/playvideos/README.md +++ /dev/null @@ -1,79 +0,0 @@ -### ► Play Videos plugin for Shaarli - -Adds a `► Play Videos` button to [Shaarli](https://github.com/shaarli/Shaarli)'s toolbar. Click this button to play all videos on the page in an overlay HTML5 player. Nice for continuous stream of music, documentaries, talks... - - - -This uses code from https://zaius.github.io/youtube_playlist/ and is currently only compatible with Youtube videos. - -#### Installation and setup - -This is a default Shaarli plugin, you just have to enable it. See https://github.com/shaarli/Shaarli/wiki/Shaarli-configuration/ - - -#### Troubleshooting - -If your server has [Content Security Policy](http://content-security-policy.com/) headers enabled, this may prevent the script from loading fully. You should relax the CSP in your server settings. Example CSP rule for apache2: - -In `/etc/apache2/conf-available/shaarli-csp.conf`: - -```apache - - Header set Content-Security-Policy "script-src 'self' 'unsafe-inline' https://www.youtube.com https://s.ytimg.com 'unsafe-eval'" - -``` - -Then run `a2enconf shaarli-csp; service apache2 reload` - -### License -``` -File: youtube_playlist.js -Copyright: (c) 2010-2014, David Kelso -License: The ISC License (http://opensource.org/licenses/ISC) - -Files: jquery*.js -License: MIT License (http://opensource.org/licenses/MIT) -Copyright: (C) jQuery Foundation and other contributors, https://jquery.com/download/ - ------------------------------------------------------ - -The ISC License (http://opensource.org/licenses/ISC) - -Copyright (c) 2010-2014, David Kelso (david at kelso dot id dot au) -Copyright (c) 2010-2014, nodiscc (nodiscc at gmail dot com) - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE - ----------------------------------------------------- -MIT LICENSE - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - ----------------------------------------------------- -``` diff --git a/plugins/playvideos/playvideos.html b/plugins/playvideos/playvideos.html deleted file mode 100644 index fda3d54..0000000 --- a/plugins/playvideos/playvideos.html +++ /dev/null @@ -1 +0,0 @@ -► Play Videos \ No newline at end of file diff --git a/plugins/playvideos/playvideos.meta b/plugins/playvideos/playvideos.meta deleted file mode 100644 index c2b0908..0000000 --- a/plugins/playvideos/playvideos.meta +++ /dev/null @@ -1 +0,0 @@ -description="Add a button in the toolbar allowing to watch all videos." diff --git a/plugins/playvideos/playvideos.php b/plugins/playvideos/playvideos.php deleted file mode 100644 index 7645b77..0000000 --- a/plugins/playvideos/playvideos.php +++ /dev/null @@ -1,40 +0,0 @@ -= d.length) { - c -= d.length - } - return f() - }; - s = function () { - c--; - if (c < 0) { - c += d.length - } - return f() - }; - l = function () { - e("#shadow, #player_box").remove(); - return e(document).unbind("keyup.player") - }; - e(document).bind("keyup.player", function (e) { - if (e.keyCode === 27) { - l() - } - if (e.keyCode === 39) { - p() - } - if (e.keyCode === 37) { - return s() - } - }); - u = e("
    ", { - id: "shadow", - css: n.shadow, - click: l - }); - r = e("
    ", { - id: "player_box", - css: n.player_box - }); - o = e("
    ", { - id: g - }); - a = e("", { - href: "javascript:;", - text: "previous", - css: n.prev_button, - click: s - }); - t = e("", { - href: "javascript:;", - text: "next", - css: n.next_button, - click: p - }); - r.append(o).append(a).append(t); - e("body").append(u).append(r); - v = function (e) { - console.log("player ready"); - return e.target.playVideo() - }; - h = function (e) { - var n, t; - n = { - 2: "invalid video id", - 5: "video not supported in html5", - 100: "video removed or private", - 101: "video not embedable", - 150: "video not embedable" - }; - t = n[e.data] || "unknown error"; - console.log("Error", t); - d.splice(c, 1); - if (c >= d.length) { - c = 0 - } - return f() - }; - m = function (e) { - if (e.data === YT.PlayerState.ENDED) { - return p() - } - }; - return window.onYouTubeIframeAPIReady = function () { - return y = new YT.Player(g, { - height: "390", - width: "640", - videoId: d[0], - events: { - onReady: v, - onError: h, - onStateChange: m - } - }) - } - }; - o = false; - if (typeof jQuery !== "undefined" && jQuery !== null && jQuery.fn && jQuery.fn.jquery) { - r = jQuery.fn.jquery.split("."); - if (r.length === 3 && parseInt(r[1]) > 3) { - console.log("using in page jquery version", jQuery.fn.jquery); - e(jQuery); - o = true - } - } - if (!o) { - t("plugins/playvideos/jquery-1.11.2.min.js", function () { - return e(jQuery.noConflict(true)) - }) - } -}); - -var input = document.querySelector('#playvideos'); -input.addEventListener('click', function() -{ - run_playideos(); -}); diff --git a/plugins/qrcode/qr-1.1.3.js b/plugins/qrcode/qr-1.1.3.js deleted file mode 100644 index 4f127e6..0000000 --- a/plugins/qrcode/qr-1.1.3.js +++ /dev/null @@ -1,1215 +0,0 @@ -// [qr.js](http://neocotic.com/qr.js) -// (c) 2014 Alasdair Mercer -// Licensed under the GPL Version 3 license. -// Based on [jsqrencode](http://code.google.com/p/jsqrencode/) -// (c) 2010 tz@execpc.com -// Licensed under the GPL Version 3 license. -// For all details and documentation: -// - -(function (root) { - - 'use strict'; - - // Private constants - // ----------------- - - // Alignment pattern. - var ALIGNMENT_DELTA = [ - 0, 11, 15, 19, 23, 27, 31, - 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24, - 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28 - ]; - // Default MIME type. - var DEFAULT_MIME = 'image/png'; - // MIME used to initiate a browser download prompt when `qr.save` is called. - var DOWNLOAD_MIME = 'image/octet-stream'; - // There are four elements per version. The first two indicate the number of blocks, then the - // data width, and finally the ECC width. - var ECC_BLOCKS = [ - 1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17, - 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28, - 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22, - 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16, - 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22, - 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28, - 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26, - 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26, - 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24, - 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28, - 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24, - 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28, - 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22, - 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24, - 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24, - 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30, - 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28, - 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28, - 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26, - 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28, - 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30, - 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24, - 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30, - 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30, - 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30, - 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30, - 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30, - 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30, - 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30, - 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30, - 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30, - 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30, - 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30, - 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30, - 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30, - 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30, - 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30, - 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30, - 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30, - 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30 - ]; - // Map of human-readable ECC levels. - var ECC_LEVELS = { - L: 1, - M: 2, - Q: 3, - H: 4 - }; - // Final format bits with mask (level << 3 | mask). - var FINAL_FORMAT = [ - 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, /* L */ - 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, /* M */ - 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, /* Q */ - 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b /* H */ - ]; - // Galois field exponent table. - var GALOIS_EXPONENT = [ - 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, - 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, - 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23, - 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1, - 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, - 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2, - 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce, - 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc, - 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54, - 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73, - 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff, - 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41, - 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, - 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, - 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, - 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00 - ]; - // Galois field log table. - var GALOIS_LOG = [ - 0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, - 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, - 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, - 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, - 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, - 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, - 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, - 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, - 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, - 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, - 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, - 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, - 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, - 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, - 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, - 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf - ]; - // *Badness* coefficients. - var N1 = 3; - var N2 = 3; - var N3 = 40; - var N4 = 10; - // Version pattern. - var VERSION_BLOCK = [ - 0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532, - 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5, - 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69 - ]; - // Mode for node.js file system file writes. - var WRITE_MODE = parseInt('0666', 8); - - // Private variables - // ----------------- - - // Run lengths for badness. - var badBuffer = []; - // Constructor for `canvas` elements in the node.js environment. - var Canvas; - // Data block. - var dataBlock; - // ECC data blocks and tables. - var eccBlock, neccBlock1, neccBlock2; - // ECC buffer. - var eccBuffer = []; - // ECC level (defaults to **L**). - var eccLevel = 1; - // Image buffer. - var frameBuffer = []; - // Fixed part of the image. - var frameMask = []; - // File system within the node.js environment. - var fs; - // Constructor for `img` elements in the node.js environment. - var Image; - // Indicates whether or not this script is running in node.js. - var inNode = false; - // Generator polynomial. - var polynomial = []; - // Save the previous value of the `qr` variable. - var previousQr = root.qr; - // Data input buffer. - var stringBuffer = []; - // Version for the data. - var version; - // Data width is based on `version`. - var width; - - // Private functions - // ----------------- - - // Create a new canvas using `document.createElement` unless script is running in node.js, in - // which case the `canvas` module is used. - function createCanvas() { - return inNode ? new Canvas() : root.document.createElement('canvas'); - } - - // Create a new image using `document.createElement` unless script is running in node.js, in - // which case the `canvas` module is used. - function createImage() { - return inNode ? new Image() : root.document.createElement('img'); - } - - // Force the canvas image to be downloaded in the browser. - // Optionally, a `callback` function can be specified which will be called upon completed. Since - // this is not an asynchronous operation, this is merely convenient and helps simplify the - // calling code. - function download(cvs, data, callback) { - var mime = data.mime || DEFAULT_MIME; - - root.location.href = cvs.toDataURL(mime).replace(mime, DOWNLOAD_MIME); - - if (typeof callback === 'function') callback(); - } - - // Normalize the `data` that is provided to the main API. - function normalizeData(data) { - if (typeof data === 'string') data = { value: data }; - return data || {}; - } - - // Override the `qr` API methods that require HTML5 canvas support to throw a relevant error. - function overrideAPI(qr) { - var methods = [ 'canvas', 'image', 'save', 'saveSync', 'toDataURL' ]; - var i; - - function overrideMethod(name) { - qr[name] = function () { - throw new Error(name + ' requires HTML5 canvas element support'); - }; - } - - for (i = 0; i < methods.length; i++) { - overrideMethod(methods[i]); - } - } - - // Asynchronously write the data of the rendered canvas to a given file path. - function writeFile(cvs, data, callback) { - if (typeof data.path !== 'string') { - return callback(new TypeError('Invalid path type: ' + typeof data.path)); - } - - var fd, buff; - - // Write the buffer to the open file stream once both prerequisites are met. - function writeBuffer() { - fs.write(fd, buff, 0, buff.length, 0, function (error) { - fs.close(fd); - - callback(error); - }); - } - - // Create a buffer of the canvas' data. - cvs.toBuffer(function (error, _buff) { - if (error) return callback(error); - - buff = _buff; - if (fd) { - writeBuffer(); - } - }); - - // Open a stream for the file to be written. - fs.open(data.path, 'w', WRITE_MODE, function (error, _fd) { - if (error) return callback(error); - - fd = _fd; - if (buff) { - writeBuffer(); - } - }); - } - - // Write the data of the rendered canvas to a given file path. - function writeFileSync(cvs, data) { - if (typeof data.path !== 'string') { - throw new TypeError('Invalid path type: ' + typeof data.path); - } - - var buff = cvs.toBuffer(); - var fd = fs.openSync(data.path, 'w', WRITE_MODE); - - try { - fs.writeSync(fd, buff, 0, buff.length, 0); - } finally { - fs.closeSync(fd); - } - } - - // Set bit to indicate cell in frame is immutable (symmetric around diagonal). - function setMask(x, y) { - var bit; - - if (x > y) { - bit = x; - x = y; - y = bit; - } - - bit = y; - bit *= y; - bit += y; - bit >>= 1; - bit += x; - - frameMask[bit] = 1; - } - - // Enter alignment pattern. Foreground colour to frame, background to mask. Frame will be merged - // with mask later. - function addAlignment(x, y) { - var i; - - frameBuffer[x + width * y] = 1; - - for (i = -2; i < 2; i++) { - frameBuffer[(x + i) + width * (y - 2)] = 1; - frameBuffer[(x - 2) + width * (y + i + 1)] = 1; - frameBuffer[(x + 2) + width * (y + i)] = 1; - frameBuffer[(x + i + 1) + width * (y + 2)] = 1; - } - - for (i = 0; i < 2; i++) { - setMask(x - 1, y + i); - setMask(x + 1, y - i); - setMask(x - i, y - 1); - setMask(x + i, y + 1); - } - } - - // Exponentiation mod N. - function modN(x) { - while (x >= 255) { - x -= 255; - x = (x >> 8) + (x & 255); - } - - return x; - } - - // Calculate and append `ecc` data to the `data` block. If block is in the string buffer the - // indices to buffers are used. - function appendData(data, dataLength, ecc, eccLength) { - var bit, i, j; - - for (i = 0; i < eccLength; i++) { - stringBuffer[ecc + i] = 0; - } - - for (i = 0; i < dataLength; i++) { - bit = GALOIS_LOG[stringBuffer[data + i] ^ stringBuffer[ecc]]; - - if (bit !== 255) { - for (j = 1; j < eccLength; j++) { - stringBuffer[ecc + j - 1] = stringBuffer[ecc + j] ^ - GALOIS_EXPONENT[modN(bit + polynomial[eccLength - j])]; - } - } else { - for (j = ecc; j < ecc + eccLength; j++) { - stringBuffer[j] = stringBuffer[j + 1]; - } - } - - stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : - GALOIS_EXPONENT[modN(bit + polynomial[0])]; - } - } - - // Check mask since symmetricals use half. - function isMasked(x, y) { - var bit; - - if (x > y) { - bit = x; - x = y; - y = bit; - } - - bit = y; - bit += y * y; - bit >>= 1; - bit += x; - - return frameMask[bit] === 1; - } - - // Apply the selected mask out of the 8 options. - function applyMask(mask) { - var x, y, r3x, r3y; - - switch (mask) { - case 0: - for (y = 0; y < width; y++) { - for (x = 0; x < width; x++) { - if (!((x + y) & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 1: - for (y = 0; y < width; y++) { - for (x = 0; x < width; x++) { - if (!(y & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 2: - for (y = 0; y < width; y++) { - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!r3x && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 3: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = r3y, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!r3x && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 4: - for (y = 0; y < width; y++) { - for (r3x = 0, r3y = ((y >> 1) & 1), x = 0; x < width; x++, r3x++) { - if (r3x === 3) { - r3x = 0; - r3y = !r3y; - } - - if (!r3y && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 5: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!((x & y & 1) + !(!r3x | !r3y)) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 6: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!(((x & y & 1) + (r3x && (r3x === r3y))) & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 7: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!(((r3x && (r3x === r3y)) + ((x + y) & 1)) & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - } - } - - // Using the table for the length of each run, calculate the amount of bad image. Long runs or - // those that look like finders are called twice; once for X and Y. - function getBadRuns(length) { - var badRuns = 0; - var i; - - for (i = 0; i <= length; i++) { - if (badBuffer[i] >= 5) { - badRuns += N1 + badBuffer[i] - 5; - } - } - - // FBFFFBF as in finder. - for (i = 3; i < length - 1; i += 2) { - if (badBuffer[i - 2] === badBuffer[i + 2] && - badBuffer[i + 2] === badBuffer[i - 1] && - badBuffer[i - 1] === badBuffer[i + 1] && - badBuffer[i - 1] * 3 === badBuffer[i] && - // Background around the foreground pattern? Not part of the specs. - (badBuffer[i - 3] === 0 || i + 3 > length || - badBuffer[i - 3] * 3 >= badBuffer[i] * 4 || - badBuffer[i + 3] * 3 >= badBuffer[i] * 4)) { - badRuns += N3; - } - } - - return badRuns; - } - - // Calculate how bad the masked image is (e.g. blocks, imbalance, runs, or finders). - function checkBadness() { - var b, b1, bad, big, bw, count, h, x, y; - bad = bw = count = 0; - - // Blocks of same colour. - for (y = 0; y < width - 1; y++) { - for (x = 0; x < width - 1; x++) { - // All foreground colour. - if ((frameBuffer[x + width * y] && - frameBuffer[(x + 1) + width * y] && - frameBuffer[x + width * (y + 1)] && - frameBuffer[(x + 1) + width * (y + 1)]) || - // All background colour. - !(frameBuffer[x + width * y] || - frameBuffer[(x + 1) + width * y] || - frameBuffer[x + width * (y + 1)] || - frameBuffer[(x + 1) + width * (y + 1)])) { - bad += N2; - } - } - } - - // X runs. - for (y = 0; y < width; y++) { - badBuffer[0] = 0; - - for (h = b = x = 0; x < width; x++) { - if ((b1 = frameBuffer[x + width * y]) === b) { - badBuffer[h]++; - } else { - badBuffer[++h] = 1; - } - - b = b1; - bw += b ? 1 : -1; - } - - bad += getBadRuns(h); - } - - if (bw < 0) bw = -bw; - - big = bw; - big += big << 2; - big <<= 1; - - while (big > width * width) { - big -= width * width; - count++; - } - - bad += count * N4; - - // Y runs. - for (x = 0; x < width; x++) { - badBuffer[0] = 0; - - for (h = b = y = 0; y < width; y++) { - if ((b1 = frameBuffer[x + width * y]) === b) { - badBuffer[h]++; - } else { - badBuffer[++h] = 1; - } - - b = b1; - } - - bad += getBadRuns(h); - } - - return bad; - } - - // Generate the encoded QR image for the string provided. - function generateFrame(str) { - var i, j, k, m, t, v, x, y; - - // Find the smallest version that fits the string. - t = str.length; - - version = 0; - - do { - version++; - - k = (eccLevel - 1) * 4 + (version - 1) * 16; - - neccBlock1 = ECC_BLOCKS[k++]; - neccBlock2 = ECC_BLOCKS[k++]; - dataBlock = ECC_BLOCKS[k++]; - eccBlock = ECC_BLOCKS[k]; - - k = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (version <= 9); - - if (t <= k) break; - } while (version < 40); - - // FIXME: Ensure that it fits insted of being truncated. - width = 17 + 4 * version; - - // Allocate, clear and setup data structures. - v = dataBlock + (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2; - - for (t = 0; t < v; t++) { - eccBuffer[t] = 0; - } - - stringBuffer = str.slice(0); - - for (t = 0; t < width * width; t++) { - frameBuffer[t] = 0; - } - - for (t = 0; t < (width * (width + 1) + 1) / 2; t++) { - frameMask[t] = 0; - } - - // Insert finders: Foreground colour to frame and background to mask. - for (t = 0; t < 3; t++) { - k = y = 0; - - if (t === 1) k = (width - 7); - if (t === 2) y = (width - 7); - - frameBuffer[(y + 3) + width * (k + 3)] = 1; - - for (x = 0; x < 6; x++) { - frameBuffer[(y + x) + width * k] = 1; - frameBuffer[y + width * (k + x + 1)] = 1; - frameBuffer[(y + 6) + width * (k + x)] = 1; - frameBuffer[(y + x + 1) + width * (k + 6)] = 1; - } - - for (x = 1; x < 5; x++) { - setMask(y + x, k + 1); - setMask(y + 1, k + x + 1); - setMask(y + 5, k + x); - setMask(y + x + 1, k + 5); - } - - for (x = 2; x < 4; x++) { - frameBuffer[(y + x) + width * (k + 2)] = 1; - frameBuffer[(y + 2) + width * (k + x + 1)] = 1; - frameBuffer[(y + 4) + width * (k + x)] = 1; - frameBuffer[(y + x + 1) + width * (k + 4)] = 1; - } - } - - // Alignment blocks. - if (version > 1) { - t = ALIGNMENT_DELTA[version]; - y = width - 7; - - for (;;) { - x = width - 7; - - while (x > t - 3) { - addAlignment(x, y); - - if (x < t) break; - - x -= t; - } - - if (y <= t + 9) break; - - y -= t; - - addAlignment(6, y); - addAlignment(y, 6); - } - } - - // Single foreground cell. - frameBuffer[8 + width * (width - 8)] = 1; - - // Timing gap (mask only). - for (y = 0; y < 7; y++) { - setMask(7, y); - setMask(width - 8, y); - setMask(7, y + width - 7); - } - - for (x = 0; x < 8; x++) { - setMask(x, 7); - setMask(x + width - 8, 7); - setMask(x, width - 8); - } - - // Reserve mask, format area. - for (x = 0; x < 9; x++) { - setMask(x, 8); - } - - for (x = 0; x < 8; x++) { - setMask(x + width - 8, 8); - setMask(8, x); - } - - for (y = 0; y < 7; y++) { - setMask(8, y + width - 7); - } - - // Timing row/column. - for (x = 0; x < width - 14; x++) { - if (x & 1) { - setMask(8 + x, 6); - setMask(6, 8 + x); - } else { - frameBuffer[(8 + x) + width * 6] = 1; - frameBuffer[6 + width * (8 + x)] = 1; - } - } - - // Version block. - if (version > 6) { - t = VERSION_BLOCK[version - 7]; - k = 17; - - for (x = 0; x < 6; x++) { - for (y = 0; y < 3; y++, k--) { - if (1 & (k > 11 ? version >> (k - 12) : t >> k)) { - frameBuffer[(5 - x) + width * (2 - y + width - 11)] = 1; - frameBuffer[(2 - y + width - 11) + width * (5 - x)] = 1; - } else { - setMask(5 - x, 2 - y + width - 11); - setMask(2 - y + width - 11, 5 - x); - } - } - } - } - - // Sync mask bits. Only set above for background cells, so now add the foreground. - for (y = 0; y < width; y++) { - for (x = 0; x <= y; x++) { - if (frameBuffer[x + width * y]) { - setMask(x, y); - } - } - } - - // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji - // not supported). - v = stringBuffer.length; - - // String to array. - for (i = 0; i < v; i++) { - eccBuffer[i] = stringBuffer.charCodeAt(i); - } - - stringBuffer = eccBuffer.slice(0); - - // Calculate max string length. - x = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2; - - if (v >= x - 2) { - v = x - 2; - - if (version > 9) v--; - } - - // Shift and re-pack to insert length prefix. - i = v; - - if (version > 9) { - stringBuffer[i + 2] = 0; - stringBuffer[i + 3] = 0; - - while (i--) { - t = stringBuffer[i]; - - stringBuffer[i + 3] |= 255 & (t << 4); - stringBuffer[i + 2] = t >> 4; - } - - stringBuffer[2] |= 255 & (v << 4); - stringBuffer[1] = v >> 4; - stringBuffer[0] = 0x40 | (v >> 12); - } else { - stringBuffer[i + 1] = 0; - stringBuffer[i + 2] = 0; - - while (i--) { - t = stringBuffer[i]; - - stringBuffer[i + 2] |= 255 & (t << 4); - stringBuffer[i + 1] = t >> 4; - } - - stringBuffer[1] |= 255 & (v << 4); - stringBuffer[0] = 0x40 | (v >> 4); - } - - // Fill to end with pad pattern. - i = v + 3 - (version < 10); - - while (i < x) { - stringBuffer[i++] = 0xec; - stringBuffer[i++] = 0x11; - } - - // Calculate generator polynomial. - polynomial[0] = 1; - - for (i = 0; i < eccBlock; i++) { - polynomial[i + 1] = 1; - - for (j = i; j > 0; j--) { - polynomial[j] = polynomial[j] ? polynomial[j - 1] ^ - GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[j]] + i)] : polynomial[j - 1]; - } - - polynomial[0] = GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[0]] + i)]; - } - - // Use logs for generator polynomial to save calculation step. - for (i = 0; i <= eccBlock; i++) { - polynomial[i] = GALOIS_LOG[polynomial[i]]; - } - - // Append ECC to data buffer. - k = x; - y = 0; - - for (i = 0; i < neccBlock1; i++) { - appendData(y, dataBlock, k, eccBlock); - - y += dataBlock; - k += eccBlock; - } - - for (i = 0; i < neccBlock2; i++) { - appendData(y, dataBlock + 1, k, eccBlock); - - y += dataBlock + 1; - k += eccBlock; - } - - // Interleave blocks. - y = 0; - - for (i = 0; i < dataBlock; i++) { - for (j = 0; j < neccBlock1; j++) { - eccBuffer[y++] = stringBuffer[i + j * dataBlock]; - } - - for (j = 0; j < neccBlock2; j++) { - eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))]; - } - } - - for (j = 0; j < neccBlock2; j++) { - eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))]; - } - - for (i = 0; i < eccBlock; i++) { - for (j = 0; j < neccBlock1 + neccBlock2; j++) { - eccBuffer[y++] = stringBuffer[x + i + j * eccBlock]; - } - } - - stringBuffer = eccBuffer; - - // Pack bits into frame avoiding masked area. - x = y = width - 1; - k = v = 1; - - // inteleaved data and ECC codes. - m = (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2; - - for (i = 0; i < m; i++) { - t = stringBuffer[i]; - - for (j = 0; j < 8; j++, t <<= 1) { - if (0x80 & t) { - frameBuffer[x + width * y] = 1; - } - - // Find next fill position. - do { - if (v) { - x--; - } else { - x++; - - if (k) { - if (y !== 0) { - y--; - } else { - x -= 2; - k = !k; - - if (x === 6) { - x--; - y = 9; - } - } - } else { - if (y !== width - 1) { - y++; - } else { - x -= 2; - k = !k; - - if (x === 6) { - x--; - y -= 8; - } - } - } - } - - v = !v; - } while (isMasked(x, y)); - } - } - - // Save pre-mask copy of frame. - stringBuffer = frameBuffer.slice(0); - - t = 0; - y = 30000; - - // Using `for` instead of `while` since in original Arduino code if an early mask was *good - // enough* it wouldn't try for a better one since they get more complex and take longer. - for (k = 0; k < 8; k++) { - // Returns foreground-background imbalance. - applyMask(k); - - x = checkBadness(); - - // Is current mask better than previous best? - if (x < y) { - y = x; - t = k; - } - - // Don't increment `i` to a void redoing mask. - if (t === 7) break; - - // Reset for next pass. - frameBuffer = stringBuffer.slice(0); - } - - // Redo best mask as none were *good enough* (i.e. last wasn't `t`). - if (t !== k) { - applyMask(t); - } - - // Add in final mask/ECC level bytes. - y = FINAL_FORMAT[t + ((eccLevel - 1) << 3)]; - - // Low byte. - for (k = 0; k < 8; k++, y >>= 1) { - if (y & 1) { - frameBuffer[(width - 1 - k) + width * 8] = 1; - - if (k < 6) { - frameBuffer[8 + width * k] = 1; - } else { - frameBuffer[8 + width * (k + 1)] = 1; - } - } - } - - // High byte. - for (k = 0; k < 7; k++, y >>= 1) { - if (y & 1) { - frameBuffer[8 + width * (width - 7 + k)] = 1; - - if (k) { - frameBuffer[(6 - k) + width * 8] = 1; - } else { - frameBuffer[7 + width * 8] = 1; - } - } - } - - // Finally, return the image data. - return frameBuffer; - } - - // qr.js setup - // ----------- - - // Build the publicly exposed API. - var qr = { - - // Constants - // --------- - - // Current version of `qr`. - VERSION: '1.1.3', - - // QR functions - // ------------ - - // Generate the QR code using the data provided and render it on to a `` element. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - canvas: function(data) { - data = normalizeData(data); - - // Module size of the generated QR code (i.e. 1-10). - var size = data.size >= 1 && data.size <= 10 ? data.size : 4; - // Actual size of the QR code symbol and is scaled to 25 pixels (e.g. 1 = 25px, 3 = 75px). - size *= 25; - - // `` element used to render the QR code. - var cvs = data.canvas || createCanvas(); - // Retreive the 2D context of the canvas. - var c2d = cvs.getContext('2d'); - // Ensure the canvas has the correct dimensions. - c2d.canvas.width = size; - c2d.canvas.height = size; - // Fill the canvas with the correct background colour. - c2d.fillStyle = data.background || '#fff'; - c2d.fillRect(0, 0, size, size); - - // Determine the ECC level to be applied. - eccLevel = ECC_LEVELS[(data.level && data.level.toUpperCase()) || 'L']; - - // Generate the image frame for the given `value`. - var frame = generateFrame(data.value || ''); - - c2d.lineWidth = 1; - - // Determine the *pixel* size. - var px = size; - px /= width; - px = Math.floor(px); - - // Draw the QR code. - c2d.clearRect(0, 0, size, size); - c2d.fillStyle = data.background || '#fff'; - c2d.fillRect(0, 0, px * (width + 8), px * (width + 8)); - c2d.fillStyle = data.foreground || '#000'; - - var i, j; - - for (i = 0; i < width; i++) { - for (j = 0; j < width; j++) { - if (frame[j * width + i]) { - c2d.fillRect(px * i, px * j, px, px); - } - } - } - - return cvs; - }, - - // Generate the QR code using the data provided and render it on to a `` element. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - image: function(data) { - data = normalizeData(data); - - // `` element only which the QR code is rendered. - var cvs = this.canvas(data); - // `` element used to display the QR code. - var img = data.image || createImage(); - - // Apply the QR code to `img`. - img.src = cvs.toDataURL(data.mime || DEFAULT_MIME); - img.height = cvs.height; - img.width = cvs.width; - - return img; - }, - - // Generate the QR code using the data provided and render it on to a `` element and - // save it as an image file. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - // If called in a browser the `path` property/argument is ignored and will simply prompt the - // user to choose a location and file name. However, if called within node.js the file will be - // saved to specified path. - // A `callback` function must be provided which will be called once the saving process has - // started. If an error occurs it will be passed as the first argument to this function, - // otherwise this argument will be `null`. - save: function(data, path, callback) { - data = normalizeData(data); - - switch (typeof path) { - case 'function': - callback = path; - path = null; - break; - case 'string': - data.path = path; - break; - } - - // Callback function is required. - if (typeof callback !== 'function') { - throw new TypeError('Invalid callback type: ' + typeof callback); - } - - var completed = false; - // `` element only which the QR code is rendered. - var cvs = this.canvas(data); - - // Simple function to try and ensure that the `callback` function is only called once. - function done(error) { - if (!completed) { - completed = true; - - callback(error); - } - } - - if (inNode) { - writeFile(cvs, data, done); - } else { - download(cvs, data, done); - } - }, - - // Generate the QR code using the data provided and render it on to a `` element and - // save it as an image file. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - // If called in a browser the `path` property/argument is ignored and will simply prompt the - // user to choose a location and file name. However, if called within node.js the file will be - // saved to specified path. - saveSync: function(data, path) { - data = normalizeData(data); - - if (typeof path === 'string') data.path = path; - - // `` element only which the QR code is rendered. - var cvs = this.canvas(data); - - if (inNode) { - writeFileSync(cvs, data); - } else { - download(cvs, data); - } - }, - - // Generate the QR code using the data provided and render it on to a `` element before - // returning its data URI. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - toDataURL: function(data) { - data = normalizeData(data); - - return this.canvas(data).toDataURL(data.mime || DEFAULT_MIME); - }, - - // Utility functions - // ----------------- - - // Run qr.js in *noConflict* mode, returning the `qr` variable to its previous owner. - // Returns a reference to `qr`. - noConflict: function() { - root.qr = previousQr; - return this; - } - - }; - - // Support - // ------- - - // Export `qr` for node.js and CommonJS. - if (typeof exports !== 'undefined') { - inNode = true; - - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = qr; - } - exports.qr = qr; - - // Import required node.js modules. - Canvas = require('canvas'); - Image = Canvas.Image; - fs = require('fs'); - } else if (typeof define === 'function' && define.amd) { - define(function () { - return qr; - }); - } else { - // In non-HTML5 browser so strip base functionality. - if (!root.HTMLCanvasElement) { - overrideAPI(qr); - } - - root.qr = qr; - } - -})(this); diff --git a/plugins/qrcode/qr-1.1.3.min.js b/plugins/qrcode/qr-1.1.3.min.js deleted file mode 100644 index 19d704e..0000000 --- a/plugins/qrcode/qr-1.1.3.min.js +++ /dev/null @@ -1,5 +0,0 @@ -/*! qr-js v1.1.3 | (c) 2014 Alasdair Mercer | GPL v3 License -jsqrencode | (c) 2010 tz@execpc.com | GPL v3 License -*/ -!function(a){"use strict";function b(){return T?new r:a.document.createElement("canvas")}function c(){return T?new x:a.document.createElement("img")}function d(b,c,d){var e=c.mime||B;a.location.href=b.toDataURL(e).replace(e,C),"function"==typeof d&&d()}function e(a){return"string"==typeof a&&(a={value:a}),a||{}}function f(a){function b(b){a[b]=function(){throw new Error(b+" requires HTML5 canvas element support")}}var c,d=["canvas","image","save","saveSync","toDataURL"];for(c=0;cb&&(c=a,a=b,b=c),c=b,c*=b,c+=b,c>>=1,c+=a,S[c]=1}function j(a,b){var c;for(R[a+z*b]=1,c=-2;2>c;c++)R[a+c+z*(b-2)]=1,R[a-2+z*(b+c+1)]=1,R[a+2+z*(b+c)]=1,R[a+c+1+z*(b+2)]=1;for(c=0;2>c;c++)i(a-1,b+c),i(a+1,b-c),i(a-c,b-1),i(a+c,b+1)}function k(a){for(;a>=255;)a-=255,a=(a>>8)+(255&a);return a}function l(a,b,c,d){var e,f,g;for(f=0;d>f;f++)W[c+f]=0;for(f=0;b>f;f++){if(e=H[W[a+f]^W[c]],255!==e)for(g=1;d>g;g++)W[c+g-1]=W[c+g]^G[k(e+U[d-g])];else for(g=c;c+d>g;g++)W[g]=W[g+1];W[c+d-1]=255===e?0:G[k(e+U[0])]}}function m(a,b){var c;return a>b&&(c=a,a=b,b=c),c=b,c+=b*b,c>>=1,c+=a,1===S[c]}function n(a){var b,c,d,e;switch(a){case 0:for(c=0;z>c;c++)for(b=0;z>b;b++)b+c&1||m(b,c)||(R[b+c*z]^=1);break;case 1:for(c=0;z>c;c++)for(b=0;z>b;b++)1&c||m(b,c)||(R[b+c*z]^=1);break;case 2:for(c=0;z>c;c++)for(d=0,b=0;z>b;b++,d++)3===d&&(d=0),d||m(b,c)||(R[b+c*z]^=1);break;case 3:for(e=0,c=0;z>c;c++,e++)for(3===e&&(e=0),d=e,b=0;z>b;b++,d++)3===d&&(d=0),d||m(b,c)||(R[b+c*z]^=1);break;case 4:for(c=0;z>c;c++)for(d=0,e=c>>1&1,b=0;z>b;b++,d++)3===d&&(d=0,e=!e),e||m(b,c)||(R[b+c*z]^=1);break;case 5:for(e=0,c=0;z>c;c++,e++)for(3===e&&(e=0),d=0,b=0;z>b;b++,d++)3===d&&(d=0),(b&c&1)+!(!d|!e)||m(b,c)||(R[b+c*z]^=1);break;case 6:for(e=0,c=0;z>c;c++,e++)for(3===e&&(e=0),d=0,b=0;z>b;b++,d++)3===d&&(d=0),(b&c&1)+(d&&d===e)&1||m(b,c)||(R[b+c*z]^=1);break;case 7:for(e=0,c=0;z>c;c++,e++)for(3===e&&(e=0),d=0,b=0;z>b;b++,d++)3===d&&(d=0),(d&&d===e)+(b+c&1)&1||m(b,c)||(R[b+c*z]^=1)}}function o(a){var b,c=0;for(b=0;a>=b;b++)O[b]>=5&&(c+=I+O[b]-5);for(b=3;a-1>b;b+=2)O[b-2]===O[b+2]&&O[b+2]===O[b-1]&&O[b-1]===O[b+1]&&3*O[b-1]===O[b]&&(0===O[b-3]||b+3>a||3*O[b-3]>=4*O[b]||3*O[b+3]>=4*O[b])&&(c+=K);return c}function p(){var a,b,c,d,e,f,g,h,i;for(c=e=f=0,i=0;z-1>i;i++)for(h=0;z-1>h;h++)(R[h+z*i]&&R[h+1+z*i]&&R[h+z*(i+1)]&&R[h+1+z*(i+1)]||!(R[h+z*i]||R[h+1+z*i]||R[h+z*(i+1)]||R[h+1+z*(i+1)]))&&(c+=J);for(i=0;z>i;i++){for(O[0]=0,g=a=h=0;z>h;h++)(b=R[h+z*i])===a?O[g]++:O[++g]=1,a=b,e+=a?1:-1;c+=o(g)}for(0>e&&(e=-e),d=e,d+=d<<2,d<<=1;d>z*z;)d-=z*z,f++;for(c+=f*L,h=0;z>h;h++){for(O[0]=0,g=a=i=0;z>i;i++)(b=R[h+z*i])===a?O[g]++:O[++g]=1,a=b;c+=o(g)}return c}function q(a){var b,c,d,e,f,g,h,o;f=a.length,y=0;do if(y++,d=4*(Q-1)+16*(y-1),u=D[d++],v=D[d++],s=D[d++],t=D[d],d=s*(u+v)+v-3+(9>=y),d>=f)break;while(40>y);for(z=17+4*y,g=s+(s+t)*(u+v)+v,f=0;g>f;f++)P[f]=0;for(W=a.slice(0),f=0;z*z>f;f++)R[f]=0;for(f=0;(z*(z+1)+1)/2>f;f++)S[f]=0;for(f=0;3>f;f++){for(d=o=0,1===f&&(d=z-7),2===f&&(o=z-7),R[o+3+z*(d+3)]=1,h=0;6>h;h++)R[o+h+z*d]=1,R[o+z*(d+h+1)]=1,R[o+6+z*(d+h)]=1,R[o+h+1+z*(d+6)]=1;for(h=1;5>h;h++)i(o+h,d+1),i(o+1,d+h+1),i(o+5,d+h),i(o+h+1,d+5);for(h=2;4>h;h++)R[o+h+z*(d+2)]=1,R[o+2+z*(d+h+1)]=1,R[o+4+z*(d+h)]=1,R[o+h+1+z*(d+4)]=1}if(y>1)for(f=A[y],o=z-7;;){for(h=z-7;h>f-3&&(j(h,o),!(f>h));)h-=f;if(f+9>=o)break;o-=f,j(6,o),j(o,6)}for(R[8+z*(z-8)]=1,o=0;7>o;o++)i(7,o),i(z-8,o),i(7,o+z-7);for(h=0;8>h;h++)i(h,7),i(h+z-8,7),i(h,z-8);for(h=0;9>h;h++)i(h,8);for(h=0;8>h;h++)i(h+z-8,8),i(8,h);for(o=0;7>o;o++)i(8,o+z-7);for(h=0;z-14>h;h++)1&h?(i(8+h,6),i(6,8+h)):(R[8+h+6*z]=1,R[6+z*(8+h)]=1);if(y>6)for(f=M[y-7],d=17,h=0;6>h;h++)for(o=0;3>o;o++,d--)1&(d>11?y>>d-12:f>>d)?(R[5-h+z*(2-o+z-11)]=1,R[2-o+z-11+z*(5-h)]=1):(i(5-h,2-o+z-11),i(2-o+z-11,5-h));for(o=0;z>o;o++)for(h=0;o>=h;h++)R[h+z*o]&&i(h,o);for(g=W.length,b=0;g>b;b++)P[b]=W.charCodeAt(b);if(W=P.slice(0),h=s*(u+v)+v,g>=h-2&&(g=h-2,y>9&&g--),b=g,y>9){for(W[b+2]=0,W[b+3]=0;b--;)f=W[b],W[b+3]|=255&f<<4,W[b+2]=f>>4;W[2]|=255&g<<4,W[1]=g>>4,W[0]=64|g>>12}else{for(W[b+1]=0,W[b+2]=0;b--;)f=W[b],W[b+2]|=255&f<<4,W[b+1]=f>>4;W[1]|=255&g<<4,W[0]=64|g>>4}for(b=g+3-(10>y);h>b;)W[b++]=236,W[b++]=17;for(U[0]=1,b=0;t>b;b++){for(U[b+1]=1,c=b;c>0;c--)U[c]=U[c]?U[c-1]^G[k(H[U[c]]+b)]:U[c-1];U[0]=G[k(H[U[0]]+b)]}for(b=0;t>=b;b++)U[b]=H[U[b]];for(d=h,o=0,b=0;u>b;b++)l(o,s,d,t),o+=s,d+=t;for(b=0;v>b;b++)l(o,s+1,d,t),o+=s+1,d+=t;for(o=0,b=0;s>b;b++){for(c=0;u>c;c++)P[o++]=W[b+c*s];for(c=0;v>c;c++)P[o++]=W[u*s+b+c*(s+1)]}for(c=0;v>c;c++)P[o++]=W[u*s+b+c*(s+1)];for(b=0;t>b;b++)for(c=0;u+v>c;c++)P[o++]=W[h+b+c*t];for(W=P,h=o=z-1,d=g=1,e=(s+t)*(u+v)+v,b=0;e>b;b++)for(f=W[b],c=0;8>c;c++,f<<=1){128&f&&(R[h+z*o]=1);do g?h--:(h++,d?0!==o?o--:(h-=2,d=!d,6===h&&(h--,o=9)):o!==z-1?o++:(h-=2,d=!d,6===h&&(h--,o-=8))),g=!g;while(m(h,o))}for(W=R.slice(0),f=0,o=3e4,d=0;8>d&&(n(d),h=p(),o>h&&(o=h,f=d),7!==f);d++)R=W.slice(0);for(f!==d&&n(f),o=F[f+(Q-1<<3)],d=0;8>d;d++,o>>=1)1&o&&(R[z-1-d+8*z]=1,6>d?R[8+z*d]=1:R[8+z*(d+1)]=1);for(d=0;7>d;d++,o>>=1)1&o&&(R[8+z*(z-7+d)]=1,d?R[6-d+8*z]=1:R[7+8*z]=1);return R}var r,s,t,u,v,w,x,y,z,A=[0,11,15,19,23,27,31,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28],B="image/png",C="image/octet-stream",D=[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,26,2,0,17,18,2,0,13,22,1,0,80,20,2,0,32,18,2,0,24,26,4,0,9,16,1,0,108,26,2,0,43,24,2,2,15,18,2,2,11,22,2,0,68,18,4,0,27,16,4,0,19,24,4,0,15,28,2,0,78,20,4,0,31,18,2,4,14,18,4,1,13,26,2,0,97,24,2,2,38,22,4,2,18,22,4,2,14,26,2,0,116,30,3,2,36,22,4,4,16,20,4,4,12,24,2,2,68,18,4,1,43,26,6,2,19,24,6,2,15,28,4,0,81,20,1,4,50,30,4,4,22,28,3,8,12,24,2,2,92,24,6,2,36,22,4,6,20,26,7,4,14,28,4,0,107,26,8,1,37,22,8,4,20,24,12,4,11,22,3,1,115,30,4,5,40,24,11,5,16,20,11,5,12,24,5,1,87,22,5,5,41,24,5,7,24,30,11,7,12,24,5,1,98,24,7,3,45,28,15,2,19,24,3,13,15,30,1,5,107,28,10,1,46,28,1,15,22,28,2,17,14,28,5,1,120,30,9,4,43,26,17,1,22,28,2,19,14,28,3,4,113,28,3,11,44,26,17,4,21,26,9,16,13,26,3,5,107,28,3,13,41,26,15,5,24,30,15,10,15,28,4,4,116,28,17,0,42,26,17,6,22,28,19,6,16,30,2,7,111,28,17,0,46,28,7,16,24,30,34,0,13,24,4,5,121,30,4,14,47,28,11,14,24,30,16,14,15,30,6,4,117,30,6,14,45,28,11,16,24,30,30,2,16,30,8,4,106,26,8,13,47,28,7,22,24,30,22,13,15,30,10,2,114,28,19,4,46,28,28,6,22,28,33,4,16,30,8,4,122,30,22,3,45,28,8,26,23,30,12,28,15,30,3,10,117,30,3,23,45,28,4,31,24,30,11,31,15,30,7,7,116,30,21,7,45,28,1,37,23,30,19,26,15,30,5,10,115,30,19,10,47,28,15,25,24,30,23,25,15,30,13,3,115,30,2,29,46,28,42,1,24,30,23,28,15,30,17,0,115,30,10,23,46,28,10,35,24,30,19,35,15,30,17,1,115,30,14,21,46,28,29,19,24,30,11,46,15,30,13,6,115,30,14,23,46,28,44,7,24,30,59,1,16,30,12,7,121,30,12,26,47,28,39,14,24,30,22,41,15,30,6,14,121,30,6,34,47,28,46,10,24,30,2,64,15,30,17,4,122,30,29,14,46,28,49,10,24,30,24,46,15,30,4,18,122,30,13,32,46,28,48,14,24,30,42,32,15,30,20,4,117,30,40,7,47,28,43,22,24,30,10,67,15,30,19,6,118,30,18,31,47,28,34,34,24,30,20,61,15,30],E={L:1,M:2,Q:3,H:4},F=[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,14854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107],G=[1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142,0],H=[255,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175],I=3,J=3,K=40,L=10,M=[3220,1468,2713,1235,3062,1890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177],N=parseInt("0666",8),O=[],P=[],Q=1,R=[],S=[],T=!1,U=[],V=a.qr,W=[],X={VERSION:"1.1.3",canvas:function(a){a=e(a);var c=a.size>=1&&a.size<=10?a.size:4;c*=25;var d=a.canvas||b(),f=d.getContext("2d");f.canvas.width=c,f.canvas.height=c,f.fillStyle=a.background||"#fff",f.fillRect(0,0,c,c),Q=E[a.level&&a.level.toUpperCase()||"L"];var g=q(a.value||"");f.lineWidth=1;var h=c;h/=z,h=Math.floor(h),f.clearRect(0,0,c,c),f.fillStyle=a.background||"#fff",f.fillRect(0,0,h*(z+8),h*(z+8)),f.fillStyle=a.foreground||"#000";var i,j;for(i=0;z>i;i++)for(j=0;z>j;j++)g[j*z+i]&&f.fillRect(h*i,h*j,h,h);return d},image:function(a){a=e(a);var b=this.canvas(a),d=a.image||c();return d.src=b.toDataURL(a.mime||B),d.height=b.height,d.width=b.width,d},save:function(a,b,c){function f(a){h||(h=!0,c(a))}switch(a=e(a),typeof b){case"function":c=b,b=null;break;case"string":a.path=b}if("function"!=typeof c)throw new TypeError("Invalid callback type: "+typeof c);var h=!1,i=this.canvas(a);T?g(i,a,f):d(i,a,f)},saveSync:function(a,b){a=e(a),"string"==typeof b&&(a.path=b);var c=this.canvas(a);T?h(c,a):d(c,a)},toDataURL:function(a){return a=e(a),this.canvas(a).toDataURL(a.mime||B)},noConflict:function(){return a.qr=V,this}};"undefined"!=typeof exports?(T=!0,"undefined"!=typeof module&&module.exports&&(exports=module.exports=X),exports.qr=X,r=require("canvas"),x=r.Image,w=require("fs")):"function"==typeof define&&define.amd?define(function(){return X}):(a.HTMLCanvasElement||f(X),a.qr=X)}(this); -//# sourceMappingURL=qr.min.map \ No newline at end of file diff --git a/plugins/qrcode/qrcode.css b/plugins/qrcode/qrcode.css deleted file mode 100644 index 0d514a0..0000000 --- a/plugins/qrcode/qrcode.css +++ /dev/null @@ -1,23 +0,0 @@ -.linkqrcode { - display: inline; - position: relative; -} - -#permalinkQrcode { - position: absolute; - z-index: 200; - padding: 20px; - width: 220px; - height: 220px; - background-color: #ffffff; - border: 1px solid black; - top: -110px; - left: -110px; - text-align: center; - font-size: 8pt; - box-shadow: 2px 2px 20px 2px #333333; -} - -#permalinkQrcode img { - margin-bottom: 5px; -} diff --git a/plugins/qrcode/qrcode.html b/plugins/qrcode/qrcode.html deleted file mode 100644 index cebc564..0000000 --- a/plugins/qrcode/qrcode.html +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/plugins/qrcode/qrcode.meta b/plugins/qrcode/qrcode.meta deleted file mode 100644 index cbf371e..0000000 --- a/plugins/qrcode/qrcode.meta +++ /dev/null @@ -1 +0,0 @@ -description="For each link, add a QRCode icon ." diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php deleted file mode 100644 index 8bc610d..0000000 --- a/plugins/qrcode/qrcode.php +++ /dev/null @@ -1,61 +0,0 @@ -Click to close"; - caller.parentNode.appendChild(element); - - // Show the QRCode - qrcodeImage = document.getElementById('permalinkQrcode'); - // Workaround to deal with newly created element lag for transition. - window.getComputedStyle(qrcodeImage).opacity; - qrcodeImage.className = 'show'; - } - else - { - element.innerHTML = "Your browser does not seem to be HTML5 compatible."; - } - return false; -} - -// Remove any displayed QR-Code -function removeQrcode() -{ - var elem = document.getElementById('permalinkQrcode'); - if (elem) { - elem.parentNode.removeChild(elem); - } - return false; -} \ No newline at end of file diff --git a/plugins/readityourself/book-open.png b/plugins/readityourself/book-open.png deleted file mode 100644 index 36513d7..0000000 Binary files a/plugins/readityourself/book-open.png and /dev/null differ diff --git a/plugins/readityourself/readityourself.html b/plugins/readityourself/readityourself.html deleted file mode 100644 index e8c5f78..0000000 --- a/plugins/readityourself/readityourself.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/plugins/readityourself/readityourself.meta b/plugins/readityourself/readityourself.meta deleted file mode 100644 index bd611dd..0000000 --- a/plugins/readityourself/readityourself.meta +++ /dev/null @@ -1,2 +0,0 @@ -description="For each link, add a ReadItYourself icon to save the shaared URL." -parameters=READITYOUSELF_URL; \ No newline at end of file diff --git a/plugins/readityourself/readityourself.php b/plugins/readityourself/readityourself.php deleted file mode 100644 index 4bfcf50..0000000 --- a/plugins/readityourself/readityourself.php +++ /dev/null @@ -1,40 +0,0 @@ -get('plugins.READITYOUSELF_URL'); -if (empty($riyUrl)) { - $GLOBALS['plugin_errors'][] = 'Readityourself plugin error: '. - 'Please define the "READITYOUSELF_URL" setting in the plugin administration page.'; -} - -/** - * Add readityourself icon to link_plugin when rendering linklist. - * - * @param mixed $data Linklist data. - * @param ConfigManager $conf Configuration Manager instance. - * - * @return mixed - linklist data with readityourself plugin. - */ -function hook_readityourself_render_linklist($data, $conf) -{ - $riyUrl = $conf->get('plugins.READITYOUSELF_URL'); - if (empty($riyUrl)) { - return $data; - } - - $readityourself_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/readityourself/readityourself.html'); - - foreach ($data['links'] as &$value) { - $readityourself = sprintf($readityourself_html, $riyUrl, $value['url'], PluginManager::$PLUGINS_PATH); - $value['link_plugin'][] = $readityourself; - } - - return $data; -} diff --git a/plugins/wallabag/README.md b/plugins/wallabag/README.md deleted file mode 100644 index ea21a51..0000000 --- a/plugins/wallabag/README.md +++ /dev/null @@ -1,37 +0,0 @@ -## Save to Wallabag plugin for Shaarli - -For each link in your Shaarli, adds a button to save the target page in your [wallabag](https://www.wallabag.org/). - -### Installation - -Clone this repository inside your `tpl/plugins/` directory, or download the archive and unpack it there. -The directory structure should look like: - -```bash -└── tpl - └── plugins - └── wallabag - ├── README.md - ├── wallabag.html - ├── wallabag.meta - ├── wallabag.php - ├── wallabag.php - └── WallabagInstance.php -``` - -To enable the plugin, you can either: - - * enable it in the plugins administration page (`?do=pluginadmin`). - * add `wallabag` to your list of enabled plugins in `data/config.json.php` (`general.enabled_plugins` section). - -### Configuration - -Go to the plugin administration page, and edit the following settings (with the plugin enabled). - -**WALLABAG_URL**: *Wallabag instance URL* -Example value: `http://v2.wallabag.org` - -**WALLABAG_VERSION**: *Wallabag version* -Value: either `1` (for 1.x) or `2` (for 2.x) - -> Note: these settings can also be set in `data/config.json.php`, in the plugins section. diff --git a/plugins/wallabag/WallabagInstance.php b/plugins/wallabag/WallabagInstance.php deleted file mode 100644 index 72cc2e5..0000000 --- a/plugins/wallabag/WallabagInstance.php +++ /dev/null @@ -1,71 +0,0 @@ - '1.x', - 2 => '2.x', - ); - - /** - * @var array Static reference to WB endpoint according to the API version. - * - key: version name. - * - value: endpoint. - */ - private static $wallabagEndpoints = array( - '1.x' => '?plainurl=', - '2.x' => 'bookmarklet?url=', - ); - - /** - * @var string Wallabag user instance URL. - */ - private $instanceUrl; - - /** - * @var string Wallabag user instance API version. - */ - private $apiVersion; - - function __construct($instance, $version) - { - if ($this->isVersionAllowed($version)) { - $this->apiVersion = self::$wallabagVersions[$version]; - } else { - // Default API version: 1.x. - $this->apiVersion = self::$wallabagVersions[1]; - } - - $this->instanceUrl = add_trailing_slash($instance); - } - - /** - * Build the Wallabag URL to reach from instance URL and API version endpoint. - * - * @return string wallabag url. - */ - public function getWallabagUrl() - { - return $this->instanceUrl . self::$wallabagEndpoints[$this->apiVersion]; - } - - /** - * Checks version configuration. - * - * @param mixed $version given version ID. - * - * @return bool true if it's valid, false otherwise. - */ - private function isVersionAllowed($version) - { - return isset(self::$wallabagVersions[$version]); - } -} diff --git a/plugins/wallabag/wallabag.html b/plugins/wallabag/wallabag.html deleted file mode 100644 index c7b1d04..0000000 --- a/plugins/wallabag/wallabag.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/plugins/wallabag/wallabag.meta b/plugins/wallabag/wallabag.meta deleted file mode 100644 index 9c93f81..0000000 --- a/plugins/wallabag/wallabag.meta +++ /dev/null @@ -1,4 +0,0 @@ -description="For each link, add a Wallabag icon to save it in your instance." -parameters="WALLABAG_URL;WALLABAG_VERSION" -parameter.WALLABAG_URL="Wallabag API URL" -parameter.WALLABAG_VERSION="Wallabag API version (1 or 2)" \ No newline at end of file diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php deleted file mode 100644 index ec09c8a..0000000 --- a/plugins/wallabag/wallabag.php +++ /dev/null @@ -1,47 +0,0 @@ -get('plugins.WALLABAG_URL'); -if (empty($wallabagUrl)) { - $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '. - 'Please define the "WALLABAG_URL" setting in the plugin administration page.'; -} - -/** - * Add wallabag icon to link_plugin when rendering linklist. - * - * @param mixed $data Linklist data. - * @param ConfigManager $conf Configuration Manager instance. - * - * @return mixed - linklist data with wallabag plugin. - */ -function hook_wallabag_render_linklist($data, $conf) -{ - $wallabagUrl = $conf->get('plugins.WALLABAG_URL'); - if (empty($wallabagUrl)) { - return $data; - } - - $version = $conf->get('plugins.WALLABAG_VERSION'); - $wallabagInstance = new WallabagInstance($wallabagUrl, $version); - - $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); - - foreach ($data['links'] as &$value) { - $wallabag = sprintf( - $wallabagHtml, - $wallabagInstance->getWallabagUrl(), - urlencode($value['url']), - PluginManager::$PLUGINS_PATH - ); - $value['link_plugin'][] = $wallabag; - } - - return $data; -} - diff --git a/plugins/wallabag/wallabag.png b/plugins/wallabag/wallabag.png deleted file mode 100644 index 70aad33..0000000 Binary files a/plugins/wallabag/wallabag.png and /dev/null differ diff --git a/shaarli_version.php b/shaarli_version.php deleted file mode 100644 index eaab95c..0000000 --- a/shaarli_version.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tmp/.htaccess b/tmp/.htaccess deleted file mode 100644 index b584d98..0000000 --- a/tmp/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Allow from none -Deny from all diff --git a/tpl/404.html b/tpl/404.html deleted file mode 100644 index 53e98e2..0000000 --- a/tpl/404.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - {include="includes"} - - - -
    -

    404 Not found Oh crap!

    -

    {$error_message}

    -

    Would you mind clicking here?

    -
    -{include="page.footer"} - - diff --git a/tpl/addlink.html b/tpl/addlink.html deleted file mode 100644 index da50f45..0000000 --- a/tpl/addlink.html +++ /dev/null @@ -1,16 +0,0 @@ - - -{include="includes"} - - -{include="page.footer"} - - diff --git a/tpl/changepassword.html b/tpl/changepassword.html deleted file mode 100644 index c40daf9..0000000 --- a/tpl/changepassword.html +++ /dev/null @@ -1,15 +0,0 @@ - - -{include="includes"} - - -{include="page.footer"} - - \ No newline at end of file diff --git a/tpl/changetag.html b/tpl/changetag.html deleted file mode 100644 index 13cc5cf..0000000 --- a/tpl/changetag.html +++ /dev/null @@ -1,34 +0,0 @@ - - -{include="includes"} - - - - - - -
    -{include="page.footer"} - - diff --git a/tpl/configure.html b/tpl/configure.html deleted file mode 100644 index 983bcd0..0000000 --- a/tpl/configure.html +++ /dev/null @@ -1,93 +0,0 @@ - - -{include="includes"} - - -{include="page.footer"} - - diff --git a/tpl/daily.html b/tpl/daily.html deleted file mode 100644 index dde1f37..0000000 --- a/tpl/daily.html +++ /dev/null @@ -1,101 +0,0 @@ - - -{include="includes"} - - -
    -
    - {loop="$plugin_start_zone"} - {$value} - {/loop} -
    - -
    - All links of one day
    in a single page.
    - {if="$previousday"} <Previous day{else}<Previous day{/if} - - - {if="$nextday"}Next day>{else}Next day>{/if} -
    - - {loop="$daily_about_plugin"} - {$value} - {/loop} - -
    - rss_feedDaily RSS Feed -
    - -
    - floral_left - The Daily Shaarli - floral_right -
    - -
    - ——————————— - {function="strftime('%A %d, %B %Y', $day)"} - ——————————— -
    - -
    - - {if="$linksToDisplay"} - {loop="cols"} - {if="isset($value[0])"} -
    - {loop="value"} - {$link=$value} -
    - - {if="!$hide_timestamps || isLoggedIn()"} - - {/if} - {if="$link.tags"} -
    - {loop="link.taglist"} - {$value} - - {/loop} -
    - {/if} - - {if="$link.thumbnail"} -
    {$link.thumbnail}
    - {/if} -
    {$link.formatedDescription}
    - -
    - {loop="$link.link_plugin"} - {$value} - {/loop} -
    -
    - {/loop} -
    - {/if} - {/loop} - {else} -
    No articles on this day.
    - {/if} - -
    - -
    - {loop="$plugin_end_zone"} - {$value} - {/loop} -
    -
    -
    -
    -{include="page.footer"} - - diff --git a/tpl/dailyrss.html b/tpl/dailyrss.html deleted file mode 100644 index b14a385..0000000 --- a/tpl/dailyrss.html +++ /dev/null @@ -1,16 +0,0 @@ - - {$title} - {function="strftime('%A %e %B %Y', $daydate)"} - {$absurl} - {$absurl} - {$rssdate} - {$value.title} - {if="!$hide_timestamps"}{function="strftime('%c', $value.timestamp)"} - {/if}{if="$value.tags"}{$value.tags}{/if}
    - {$value.url}

    - {if="$value.thumbnail"}{$value.thumbnail}{/if}
    - {if="$value.description"}{$value.formatedDescription}{/if} -


    - {/loop} - ]]>
    -
    diff --git a/tpl/editlink.html b/tpl/editlink.html deleted file mode 100644 index 441b530..0000000 --- a/tpl/editlink.html +++ /dev/null @@ -1,52 +0,0 @@ - - -{include="includes"} - - - - -{if="$source !== 'firefoxsocialapi'"} -{include="page.footer"} -{/if} - - - - - diff --git a/tpl/export.bookmarks.html b/tpl/export.bookmarks.html deleted file mode 100644 index da73325..0000000 --- a/tpl/export.bookmarks.html +++ /dev/null @@ -1,10 +0,0 @@ - - -{ignore}The RainTPL loop is formatted to avoid generating extra newlines{/ignore} -{$pagetitle} -

    Shaarli export of {$selection} bookmarks on {$date}

    -

    {loop="links"} -

    {$value.title}{if="$value.description"}{$eol}
    {$value.description}{/if}{/loop} -

    diff --git a/tpl/export.html b/tpl/export.html deleted file mode 100644 index 67c3d05..0000000 --- a/tpl/export.html +++ /dev/null @@ -1,28 +0,0 @@ - - -{include="includes"} - -

    - {include="page.footer"} - - diff --git a/tpl/feed.atom.html b/tpl/feed.atom.html deleted file mode 100644 index 2ebb162..0000000 --- a/tpl/feed.atom.html +++ /dev/null @@ -1,40 +0,0 @@ - - - {$pagetitle} - Shaared links - {if="$show_dates"} - {$last_update} - {/if} - - {if="!empty($pubsubhub_url)"} - - - - {/if} - - {$index_url} - {$index_url} - - {$index_url} - Shaarli - {loop="links"} - - {$value.title} - {if="$usepermalinks"} - - {else} - - {/if} - {$value.guid} - {if="$show_dates"} - {$value.iso_date} - {/if} - - - - {loop="$value.taglist"} - - {/loop} - - {/loop} - diff --git a/tpl/feed.rss.html b/tpl/feed.rss.html deleted file mode 100644 index 26de7f1..0000000 --- a/tpl/feed.rss.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - {$pagetitle} - {$index_url} - Shaared links - {$language} - {$index_url} - Shaarli - - {if="!empty($pubsubhub_url)"} - - - {/if} - {loop="links"} - - {$value.title} - {$value.guid} - {if="$usepermalinks"} - {$value.guid} - {else} - {$value.url} - {/if} - {if="$show_dates"} - {$value.iso_date} - {/if} - - {loop="$value.taglist"} - {$value} - {/loop} - - {/loop} - - diff --git a/tpl/import.html b/tpl/import.html deleted file mode 100644 index 071e116..0000000 --- a/tpl/import.html +++ /dev/null @@ -1,33 +0,0 @@ - - -{include="includes"} - - -{include="page.footer"} - - diff --git a/tpl/includes.html b/tpl/includes.html deleted file mode 100644 index f94ce1b..0000000 --- a/tpl/includes.html +++ /dev/null @@ -1,14 +0,0 @@ -{$pagetitle} - - - - - - - - -{if="is_file('inc/user.css')"}{/if} -{loop="$plugins_includes.css_files"} - -{/loop} - \ No newline at end of file diff --git a/tpl/install.html b/tpl/install.html deleted file mode 100644 index 88eb540..0000000 --- a/tpl/install.html +++ /dev/null @@ -1,23 +0,0 @@ - - -{include="includes"}{$timezone_js} - -
    -

    Shaarli

    - It looks like it's the first time you run Shaarli. Please configure it:
    -
    - - - - {$timezone_html} - - - - -
    Login:
    Password:
    Page title:
    Update: -
    -
    -
    -{include="page.footer"} - - diff --git a/tpl/linklist.html b/tpl/linklist.html deleted file mode 100644 index 2316f14..0000000 --- a/tpl/linklist.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - - {include="includes"} - - - - - - - {include="page.footer"} - - - - - - diff --git a/tpl/linklist.paging.html b/tpl/linklist.paging.html deleted file mode 100644 index e91c8f8..0000000 --- a/tpl/linklist.paging.html +++ /dev/null @@ -1,25 +0,0 @@ -
    -{if="isLoggedIn()"} - -{/if} - {loop="$action_plugin"} - {$value} - {/loop} -
    - Links per page: 20 50 100 -
    -
    - {if="$previous_page_url"} ◄Older {/if} -
    page {$page_current} / {$page_max}
    - {if="$next_page_url"} Newer► {/if} -
    diff --git a/tpl/loginform.html b/tpl/loginform.html deleted file mode 100644 index a49b42d..0000000 --- a/tpl/loginform.html +++ /dev/null @@ -1,38 +0,0 @@ - - -{include="includes"} - - - -{include="page.footer"} - - diff --git a/tpl/opensearch.html b/tpl/opensearch.html deleted file mode 100644 index 3fcc30b..0000000 --- a/tpl/opensearch.html +++ /dev/null @@ -1,45 +0,0 @@ - - - Shaarli search - {$pagetitle} - Shaarli search - {$pagetitle} - - - - UTF-8 - Shaarli Community - https://github.com/shaarli/Shaarli/ - data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAHRklE - QVRIx5WWaWxU5xWG3++7986dfYYZb+MN2xiMDRiDFePUiQsNoiwpUNpAmhInJVEqpa0oQUlbJVKq - olaiqpLKUtOKhAJRm1BKRVWctuykpFjAgPcFx/uMl5mxPTOeuXPv3O3rjyiV0lIpfX+dc36c55xf - 70vwP9TZ2fFpSQCwT5u6unX4f0QeNLx27RoMQwfRveTd11T23M+8S9w+Z3NRma1W4Hk6/nEimFpM - Xnun9Xpmz1MPY+feOhBi/fwAAOjq7iJEqmQqCZf5i7NvyNZ/bJPYgAjCiJc2Zmhyw68SM/T1+NlK - uf61BPoH+tHU1PT5ACMjI8RXvACvpZ5NT0+fmrG+2TKqtDLV0BgA2AUfXS3+UtfDX2ixCf73E+oA - rat92CTkv9fRBwEkSaLDt/JZR/v0Q7qjb8dQ5hjSqmYSOCkzBbogL+ij2RN8bik9wK88Al9tH4tG - ow88lvb19yEyPwfGGLq6OungYD9fUlosrqwoQVVVUeOU8qE/mU0ZTq6KNvreNort+5hugkayQUgY - qQld/u6qnVRhkciscOdOkNy5E0RnZ+e/AbwsZxAaHyORZA+prW01CTlnGppOqAcwUnCmlDAkAyin - Dapb2t7lNeRijpwvTGlJROXugoKS+upz/S19Kj9lJjxXGY1VU49tGevt7WOCSMHTeAXclePsQts9 - Jq9oLR7rPVkHxpUYkK2c07ZDiieRNcAx3ZlNphcnsxbiMuEsXFSTZpabp+VVS17UNSV/8n7+gN75 - +C1DM6VEjkgatiz/5IOCAheiUdeyr+198keKZXLzTKYjMDk/ZzGJhkV9AiPSdWaYIAY4U7TYNJMR - pugMqgHcXTiJqDK8ycMv2+TPWyWtKFw3KEdtJxNz8u8+/PNYIqeUgY/Oz+Z7q5X3gtqvG7qip8yM - HqdZg5kGgwGACoQQQkEMQ2DMIFnGE04xCRQTZFaexUT6jEEImJ2njjxx9fr13hfqfULTQ4apHept - lxf4mrqS3Tek0w1toTc1K6WcXfAwnyWH8kSkIueEhdhNrzUAv16fSCUzNwR3vr/G2lKWojMqbxF4 - FWlLPDvBR+RBNpTsNqfkV7htuUe/UVq456qdzzvFh2KjdSH0I6ODs1ps9NHcw2jMfRYcEQyOCiox - aWR0fOQWVLFNUuOnrXJxfIPnpXLRKzocLpsJanhUU/bfjJ4gfwm/ys3JGX1cuS3UBvauLa/MBe9z - 5c/xGRdSKpiVmhhN98JK/w4DGgg4uLh8u1NfPhWbmzszeH3G1rxv3dL7+qXyGaXHJi46s4QQophp - TKSDkHWGlAqmGCbAGAUA3sY5LlRZv3w44Dhnm0iFzbnsGfJR5E+EEsppTBVXuBptL5b8YQMlwnO+ - Z2wtea4cl8Rc3KXJ4zShRm0CFaCaGhSDwGSMlbtLhSr7FnVhKhscC4+AO3L0x5PSFBdfE9i40SE6 - xLSWRCIbJ6phIqEysqvk+2aJ0vhB1NK353zyaL3GS76NgRbVYykkt2OXuaQqMwuxkk0FT+OJpS+z - piXPRP1KzRvz4dRvO68PaWCMEQAIDcbqFiLJtyaSA/Ef3NnMGttgvHS7mUUWw7cTMemtY/cPsw3n - oe2+4mGXpt7VGWPJ6zOn1V2Xfaz5AxgvBzexodmeGWmCbWWTDOGpSZIIqeAe2/IYvnXgWbomUj2T - lNlwUP7bV64lzuRIeoodqDxi1OKRs/e0i08dH/6JPWtk6KKaZd3xj2jAXkY3BvZGK1xrhZvRNktP - fNA0ubQrxyxV4jHpSkWoXJPKYqBetxeRpgsMWwE5b/bxaYxUDSWmzCLbStqQuy02LY4/cWLsqH8i - HYNbyEeJczkJSzH2855DwsXp932F9hXEKQSQ1UHa568iRAa3uFyeNVolMBmeIrzT4cTXm37KMuvA - xb8XXTqiDELRgKg8h/dGWwP9iSDaIzcYJSCbA/uNR3N2sNahV/hbsSA70vEdW66tCOOpj8FRkIgU - Q5ybLUopiTzeTpFWUoTXdR3knwQMzLANOyQX50fWhDktLeAX3UcIA2EEQHPgi6TBsrWzaLGm7emC - H7bY+GPlV6YumiEpDhslxGBgROApz+yyhROzduIEzwngDh48iD3jO0nBRAUUXtHcoq+ZWbI5EWWa - WTieFjoKsaVoN92T88J4vlz+asXqpb+hEcdotbdueZ47vyiqhpA2UoRQwpoLtpNHxR0382jR8RzT - k8xYMyCMMfR33Uc8rxdrA9tpuHPyS7pPOTRPZ1arepa4rUsybiWnnU9a39ZXxdur+XoGAGMdoXLi - M789axnfNxDr8omiDcvF1f3OhPf18efjF/nfz6PGvv6zlrlwWwYBgcBZbKH4WKHODLHEURDxbHDF - QWGePftHUlZWjsy8guYnH2EgwORfZ5cuavEqgGhLnL6+sycvRP1Fbux/fheIn3wCCN4N/qdPMwA4 - 2fYOeoe7kc6kcfCbh8n+r7YwAOjs6QCl9DNx5t7dew+MOf8CcuqqoLxlhwgAAAAASUVORK5CYII= - - diff --git a/tpl/page.footer.html b/tpl/page.footer.html deleted file mode 100644 index 006d1d6..0000000 --- a/tpl/page.footer.html +++ /dev/null @@ -1,31 +0,0 @@ - - -{loop="$plugins_footer.endofpage"} - {$value} -{/loop} - -{if="$newVersion"} -
    - Shaarli {$newVersion} is - available. -
    -{/if} -{if="$versionError"} -
    - Error: {$versionError} -
    -{/if} -{if="isLoggedIn()"} - -{/if} - -{loop="$plugins_footer.js_files"} - -{/loop} diff --git a/tpl/page.header.html b/tpl/page.header.html deleted file mode 100644 index 0012c68..0000000 --- a/tpl/page.header.html +++ /dev/null @@ -1,54 +0,0 @@ - - - -
    - {if="!empty($linkcount)"}{$linkcount} links{/if}
    - {if="!empty($privateLinkcount)"}{$privateLinkcount} private links{/if} -
    - - - -{if="!empty($plugin_errors) && isLoggedIn()"} -
      - {loop="plugin_errors"} -
    • {$value}
    • - {/loop} -
    -{/if} - -
    - - diff --git a/tpl/page.html b/tpl/page.html deleted file mode 100644 index 834915e..0000000 --- a/tpl/page.html +++ /dev/null @@ -1,9 +0,0 @@ - - -{include="includes"} - - - You body goes here... - {include="page.footer"} - - \ No newline at end of file diff --git a/tpl/picwall.html b/tpl/picwall.html deleted file mode 100644 index 230c948..0000000 --- a/tpl/picwall.html +++ /dev/null @@ -1,44 +0,0 @@ - - -{include="includes"} - - - - - -
    - {loop="$plugin_start_zone"} - {$value} - {/loop} -
    - -
    -
    - {loop="linksToDisplay"} -
    - {$value.thumbnail}{$value.title} - {loop="$value.picwall_plugin"} - {$value} - {/loop} -
    - {/loop} -
    -
    - -
    - -
    - {loop="$plugin_end_zone"} - {$value} - {/loop} -
    - -{include="page.footer"} - - - - diff --git a/tpl/pluginsadmin.html b/tpl/pluginsadmin.html deleted file mode 100644 index 966360e..0000000 --- a/tpl/pluginsadmin.html +++ /dev/null @@ -1,132 +0,0 @@ - - -{include="includes"} - - - - - -
    -
    -
    -

    Enabled Plugins

    - -
    - {if="count($enabledPlugins)==0"} -

    No plugin enabled.

    - {else} - - - - - - - - - - - {loop="$enabledPlugins"} - - - - - - - {/loop} - -
    DisableOrderNameDescription
    - - ▲ - - - ▼ - - -
    - {/if} -
    -
    - -
    -

    Disabled Plugins

    - -
    - {if="count($disabledPlugins)==0"} -

    No plugin disabled.

    - {else} - - - - - - - {loop="$disabledPlugins"} - - - - - - {/loop} -
    EnableNameDescription
    - {/if} -
    - -
    - -
    -
    -
    - -
    -
    -

    Enabled Plugin Parameters

    - -
    - {if="count($enabledPlugins)==0"} -

    No plugin enabled.

    - {else} - {loop="$enabledPlugins"} - {if="count($value.parameters) > 0"} -
    -

    {function="str_replace('_', ' ', $key)"}

    - {loop="$value.parameters"} -
    -
    - -
    -
    - -
    -
    - {/loop} -
    - {/if} - {/loop} - {/if} -
    - -
    -
    -
    -
    - -
    -{include="page.footer"} - - - - diff --git a/tpl/readme.txt b/tpl/readme.txt deleted file mode 100644 index b18deae..0000000 --- a/tpl/readme.txt +++ /dev/null @@ -1,42 +0,0 @@ -===== Shaarli template organisation ===== - -Any Shaarli page should conform to this RainTPL template: - ------------------------------------------------------ - -{include="includes"} - - - You body goes here... - {include="page.footer"} - - ------------------------------------------------------ - -If you want to also add something in the page header (in the dark area), do it here: - - - - -Example: "Add new link" form: ------------------------------------------------------ - -{include="includes"} - - -{include="page.footer"} - - ------------------------------------------------------ - - - - diff --git a/tpl/tagcloud.html b/tpl/tagcloud.html deleted file mode 100644 index e449f29..0000000 --- a/tpl/tagcloud.html +++ /dev/null @@ -1,31 +0,0 @@ - - -{include="includes"} - - -
    -
    - {loop="$plugin_start_zone"} - {$value} - {/loop} -
    - -
    - {loop="tags"} - {$value.count}{$key} - {loop="$value.tag_plugin"} - {$value} - {/loop} - {/loop} -
    - -
    - {loop="$plugin_end_zone"} - {$value} - {/loop} -
    -
    -{include="page.footer"} - - diff --git a/tpl/tools.html b/tpl/tools.html deleted file mode 100644 index 8e285f4..0000000 --- a/tpl/tools.html +++ /dev/null @@ -1,100 +0,0 @@ - - -{include="includes"} - - -{include="page.footer"} - -