Commit graph

189 commits

Author SHA1 Message Date
ArthurHoaro
266e3fe5c8 Markdown: fixes feed rendering with nomarkdown tag
* make sure we match exactly `nomarkdown` tag
 * pass the whole link data to stripNoMarkdownTag() to:
   * strip the noMD tag in taglist (array)
   * strip the tag in tags (string)

Fixes #689

tmp
2016-11-22 10:26:03 +01:00
ArthurHoaro
5ebc1d504b .htaccess files: support Apache 2.4+ syntax
If `mod_version` is enabled, the previous syntax will apply for Apache <2.4.
If not, the new syntax is used by default.

Fixes #676

`mod_version` identifier is `version_module` across all Apache versions. See:

  * https://httpd.apache.org/docs/current/mod/mod_version.html
  * https://httpd.apache.org/docs/2.2/mod/mod_version.html
  * https://serverfault.com/questions/733910/how-do-i-load-mod-version-only-if-it-isnt-built-in-to-apache

Note that version_module comes built-in with Debian (and derivatives) Apache2 packages, see https://wiki.debian.org/Apache/PackagingFor24
2016-11-08 11:38:14 +01:00
ArthurHoaro
c5941f316a Fix an issue with links not being reversed in code blocks
Fixes #672

+ Markdown to HTML unit test
2016-10-22 11:13:48 +02:00
VirtualTam
3d5e0aede3 Merge pull request #673 from virtualtam/cleanup/linkdb
LinkDB: code cleanup
2016-10-21 11:04:52 +02:00
VirtualTam
954dc2446c Merge pull request #665 from ArthurHoaro/fix/feed-hashtags
Fix hashtag links in Feeds
2016-10-20 21:37:28 +02:00
VirtualTam
735ed4a94e LinkDB: explicit method visibility
Relates to https://github.com/shaarli/Shaarli/issues/95

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-10-20 21:33:42 +02:00
VirtualTam
f21abf3292 LinkDB: update datastore method names
Relates to https://github.com/shaarli/Shaarli/issues/95

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-10-20 21:33:40 +02:00
VirtualTam
628b97cbdf LinkDB: do not prefix privates with an underscore
Relates to #95

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-10-20 21:10:56 +02:00
ArthurHoaro
fbc28ff1c8 Fix hashtags links in Feeds
Make the hashtag link absolute in feeds to work properly in RSS syndication tools.
2016-10-20 11:42:01 +02:00
ArthurHoaro
7af9a41881 Minor code cleanup: PHPDoc, spelling, unused variables, etc. 2016-10-20 11:36:11 +02:00
Arthur
c1c2102850 Merge pull request #651 from ArthurHoaro/plugin-isso2
Isso comments plugin
2016-10-18 08:14:09 +02:00
VirtualTam
8406a4b670 Merge pull request #662 from virtualtam/fix/feed/self-link
Fix: return the proper value for the "self" feed attribute
2016-10-17 17:58:39 +02:00
ArthurHoaro
bf26e7ebcb Isso comments plugin
Use Isso client to let visitors comments on permalinks
2016-10-17 09:23:14 +02:00
VirtualTam
44a718090d Fix: return the proper value for the "self" feed attribute
Fixes https://github.com/shaarli/Shaarli/issues/629
Closes https://github.com/shaarli/Shaarli/pull/630

Note: you might need to empty the "pagecache" directory for the
fix to be taken into account

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-10-16 20:58:15 +02:00
ArthurHoaro
7fde6de121 New init function for plugins, supports errors reporting
All plugins can optionally add an init function named `pluginname_init()` which is called when the plugin is loaded.

This function is aware of the config, and can return initialization errors, which are displayed in the header template.

Note that the previous error system hack no longer work.
2016-10-14 13:22:58 +02:00
VirtualTam
f63632a6fb Merge pull request #654 from teromene/archive-org-no-internal
Archive.org plugin: do not propose archival of private notes

Fixes #637
2016-10-13 18:12:55 +02:00
Teromene
5e148f8a52 Archive.org plugin: do not propose archival of private notes
Fixes #637
2016-10-13 16:37:43 +01:00
Arthur
0354257266 Merge pull request #622 from ArthurHoaro/update-date
Save link update dates and render it in templates and feeds
2016-10-12 14:51:37 +02:00
Arthur
adcdac1dec Merge pull request #623 from ArthurHoaro/security/reverse-proxy-ban
Add trusted IPs in config and try to ban forwarded IP on failed login
2016-10-12 14:48:57 +02:00
VirtualTam
8758bb0ac8 Merge pull request #619 from ArthurHoaro/plugins/param-desc
Add a description to plugin parameters
2016-08-13 14:48:51 +02:00
VirtualTam
db6dec0de1 Fix: add missing final newlines, untabify text
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-08-13 14:22:22 +02:00
VirtualTam
f4ad7bde56 Fix: ensure Internet Explorer bookmark dumps can be imported
Relates to https://github.com/shaarli/Shaarli/issues/607

Modifications:
- [application][tests] NetscapeBookmarkUtils: more permissive doctype detection

The IE bookmark exports contain extra escape sequences, which can be observed
by binary comparison of the reference input data used in tests:

   $ cmp -b -l -n 8 netscape_basic.htm internet_explorer_encoding.htm

   1  74 <    357 M-o
   2  41 !    273 M-;
   3 104 D    277 M-?
   4 117 O     74 <
   5 103 C     41 !
   6 124 T    104 D
   7 131 Y    117 O
   8 120 P    103 C

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-08-12 23:22:15 +02:00
VirtualTam
a973afeac7 Refactor bookmark import using a generic Netscape parser
Relates to #607
Relates to #608
Relates to #493 (abandoned)

Additions:
- use Composer's autoload to load 3rd-party dependencies under vendor/

Modifications:
- [import] replace the current parser with a generic, stable parser
  - move code to application/NetscapeBookmarkUtils
  - improve status report after parsing
- [router] use the same endpoint for both bookmark upload and import dialog
- [template] update bookmark import options
  - allow adding tags to all imported links
  - allow selecting the visibility (privacy) of imported links
- [tests] ensure bookmarks are properly parsed and imported in the LinkDB
  - reuse reference input from the parser's test data

See:
- https://github.com/shaarli/netscape-bookmark-parser
- https://getcomposer.org/doc/01-basic-usage.md#autoloading

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-08-10 01:42:44 +02:00
ArthurHoaro
edf3ff5a53 Initialize a translation function
It matches the API of ngettext().
2016-08-07 11:54:39 +02:00
ArthurHoaro
50d1791838 Add trusted IPs in config and try to ban forwarded IP on failed login
* Add a new settings (which needs to be manually set): `security.trusted_proxies`
  * On login failure, if the `REMOTE_ADDR` is in the trusted proxies, try to retrieve the forwarded IP in headers.
  * If found, the client address is added in ipbans, else we do nothing.

Fixes #409
2016-08-03 10:36:47 +02:00
ArthurHoaro
c6d876bb2a Set updated date for items in feeds
RSS doesn't support updated date for items, so we use the ATOM extension.
Updated dates also bump the global update
2016-08-03 09:54:57 +02:00
VirtualTam
c7a42ab1d9 Merge pull request #621 from ArthurHoaro/hotfix/update-escape-config
Fix update method escapeUnescapedConfig
2016-08-02 19:46:47 +02:00
ArthurHoaro
b9f8b83790 Fix update method escapeUnescapedConfig
* Actually run it
  * unit tests

Fixes #611
2016-08-02 12:54:55 +02:00
ArthurHoaro
15170b5164 Parse plugin parameters description with the PluginManager
Plugin parameter can contain a description in their meta file under the key:

    parameter.<param_name>="<description>"
2016-08-02 11:12:01 +02:00
ArthurHoaro
9866b40814 Better whitespace handling in tags
Correct PR #573 to work properly with hidden tags, and add ReferenceLinkDB UT.

Fixes #571 - Closes #573
2016-08-02 10:34:21 +02:00
Chris Kuethe
32d51093e3 add unit test 2016-08-02 10:22:18 +02:00
Arthur
2795cf5e1c Merge pull request #605 from ArthurHoaro/clean-phpunit
Hide expected 'error_log' while running TU (clean PHPUnit log)
2016-07-23 14:20:23 +02:00
ArthurHoaro
87f9f4f9b7 Hide expected 'error_log' while running TU (clean PHPUnit log) 2016-07-23 14:16:07 +02:00
julienCXX
1336a7326b Fix typo in test method name 2016-07-21 19:42:26 +02:00
Arthur
0c4c7ae818 Merge pull request #558 from ArthurHoaro/hashtag4
Hashtag system
2016-07-09 07:36:23 +02:00
Arthur
649af5b501 Merge pull request #570 from ArthurHoaro/config-manager
Introduce a configuration manager
2016-07-09 07:19:48 +02:00
ArthurHoaro
5ff23f02b8 Add closing PHP tags to JSON config files 2016-06-20 18:30:37 +02:00
ArthurHoaro
894a3c4bf3 Rename configuration key for better sections 2016-06-11 09:30:56 +02:00
ArthurHoaro
51def0d849 PluginManager no longer uses singleton pattern 2016-06-11 09:30:56 +02:00
ArthurHoaro
278d9ee283 ConfigManager no longer uses singleton pattern 2016-06-11 09:30:56 +02:00
ArthurHoaro
da10377b3c Rename configuration keys and fix GLOBALS in templates 2016-06-11 09:30:56 +02:00
ArthurHoaro
eeea1c3daa Use the configuration manager for wallabag and readityourself plugin 2016-06-11 09:30:56 +02:00
ArthurHoaro
b74b96bfbd Adds ConfigJson which handle the configuration in JSON format.
Also use the Updater to make the transition
2016-06-11 09:30:56 +02:00
ArthurHoaro
684e662a58 Replace $GLOBALS configuration with the configuration manager in the whole code base 2016-06-11 09:30:56 +02:00
ArthurHoaro
59404d7909 Introduce a configuration manager (not plugged yet) 2016-06-11 09:30:56 +02:00
ArthurHoaro
9ccca40189 Hashtag system
* Hashtag are auto-linked with a filter search
  * Supports unicode
  * Compatible with markdown (excluded in code blocks)
2016-06-06 21:04:43 +02:00
Arthur
bb9ca54838 Merge pull request #582 from ArthurHoaro/hotfix/nomarkdown
The "nomarkdown" tag is no longer private
2016-06-06 19:52:32 +02:00
Arthur
92a381f517 Merge pull request #583 from ArthurHoaro/enhance/tag-case
Fixes #497: ignore case difference between tags
2016-06-03 18:30:19 +02:00
ArthurHoaro
b1eb5d1d31 Fixes #497: ignore case difference between tags
While retrieving all tags, case differences will be ignored.
This affects:

  * tag cloud
  * tag autocompletion
2016-05-31 09:09:32 +02:00
ArthurHoaro
8c4e60186d The tag is no longer private
A private tag is never loaded for visitor, making this feature useless.
2016-05-30 18:51:00 +02:00
nodiscc
725ca094f8 Url.php: remove unwanted ?PHPSESSID= URL parameters,
update test case
2016-05-20 12:23:03 +02:00
ArthurHoaro
141a86c503 Add private link counter 2016-05-13 08:48:23 +02:00
VirtualTam
bb4a23aa86 Export: allow prepending notes with the Shaarli instance's URL
Relates to #102

Additions:
- application:
  - export: allow prepending note permalinks with the instance's URL
  - test coverage

Modifications:
- export template: switch to an HTML form
  - link selection (all/private/public)
  - prepend note permalinks with the instance's URL

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-05-06 16:12:46 +02:00
ArthurHoaro
caa69b5853 typo 2016-05-05 13:28:43 +02:00
Arthur
86deafe0ff Merge pull request #551 from ArthurHoaro/hotfix/timezone
Use correct 'UTC' timezone
2016-05-05 13:21:36 +02:00
ArthurHoaro
12ff86c961 Use correct 'UTC' timezone 2016-05-03 20:09:24 +02:00
Arthur
47be060983 Merge pull request #532 from ArthurHoaro/hotfix/title-retrieve-the-return
Fixes #531 - Title retrieving is failing with multiple use case
2016-05-03 19:53:57 +02:00
ArthurHoaro
ce7b0b6480 Fixes #531 - Title retrieving is failing with multiple use case
see https://github.com/shaarli/Shaarli/issues/531 for details
2016-05-03 19:51:29 +02:00
VirtualTam
cd5327bee8 Refactor Netscape bookmark exporting
Relates to https://github.com/shaarli/netscape-bookmark-parser/issues/5

Fixes:
- respect the Netscape bookmark format "specification"

Modifications:
- [application] introduce the NetscapeBookmarkUtils class
- [template] export           - improve formatting, rename export selection parameter
- [template] export.bookmarks - template for Netscape exports
- [tests] bookmark filtering, additional field generation

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-04-10 21:28:04 +02:00
ArthurHoaro
043eae70c4 Fixes #480: add an option to urlencode redirector URL
* New config: `$GLOBALS['config']['REDIRECTOR_URLENCODE']` (default `true`).
  * Parameter added to LinkDB constructor.
  * Fixes a bug with urlencode and escaped url.
  * In `index.php`, LinkDB is now instanciate once for `importFile()` and `showDaily()`.
  * TU
2016-04-09 16:52:32 +02:00
VirtualTam
11609d9fd8 Merge pull request #522 from ArthurHoaro/hotfix/readershaare
Refactor and rebase #380: Firefox reader view links
2016-03-30 19:31:19 +02:00
Arthur
1a84bf1e2b Merge pull request #520 from ArthurHoaro/plugins/nomarkdown
Markdown: Add the 'meta-tag' `.nomarkdown` which prevent a shaare fro…
2016-03-26 16:46:04 +01:00
ArthurHoaro
c9da01e749 Refactor and rebase #380: Firefox reader view links
Fixes #366
Closes #380
2016-03-26 16:26:23 +01:00
Arthur
f66a1990e5 Merge pull request #515 from ArthurHoaro/template-feeds
Refactor RSS feeds generation, and do it through templates
2016-03-25 19:20:55 +01:00
ArthurHoaro
528a6f8a23 Refactor filter in LinkDB
* search type now carried by LinkDB in order to factorize code between different search sources.
  * LinkDB->filter split in 3 method: filterSearch, filterHash, filterDay (we know what type of filter is needed).
  * filterHash now throw a LinkNotFoundException if it doesn't exist: internal implementation choice, still displays a 404.
  * Smallhash regex has been rewritten.
  * Unit tests update
2016-03-25 19:17:59 +01:00
ArthurHoaro
89baf23ddf FeedBuilder unit tests 2016-03-25 19:17:59 +01:00
ArthurHoaro
3ce20d9e84 Markdown: Add the 'meta-tag' .nomarkdown which prevent a shaare from being parsed with markdown
Also add the tag in tag list in edit_link, so it will appear on autocompletion.
2016-03-21 18:46:34 +01:00
ArthurHoaro
68ea1d2b30 Fixes #512: retrieving title didn't match the first closing tag 2016-03-08 10:00:53 +01:00
ArthurHoaro
85244fa0d0 Fixes #477: support multi reverse proxy with comma syntax
Going through multiple reverse proxy will store multiple scheme and port in HTTP header separated by a comma. Shaarli will use the first one to generate server_url.
2016-02-28 16:24:18 +01:00
Arthur
c6744a9e89 Merge pull request #496 from ArthurHoaro/cross-search
Allow crossed search between terms and tags
2016-02-28 14:26:46 +01:00
ArthurHoaro
c51fae92dc Allow crossed search between terms and tags
* Partial fix of #449
  * Current use case: search term + click on tag.
  * LinkFilter now returns all links if no filter is given.
  * Unit tests.
2016-02-28 14:17:40 +01:00
ArthurHoaro
2925687e1e Markdown: don't escape content + sanitize sensible tags
Instead of trying to fix broken content for Markdown parsing, parse it unescaped, then sanatize sensible tags such as scripts, etc.
2016-02-19 19:37:13 +01:00
ArthurHoaro
522b278b03 Support text search across link fields. 2016-02-15 21:38:45 +01:00
ArthurHoaro
bedd176a54 Improved search: combine AND, exact terms and exclude search. 2016-02-15 21:38:40 +01:00
ArthurHoaro
195acf9f09 Private/Hidden tags
Tags starting with a dot '.' are now private.
They can only be seen and searched when logged in.

Fixes #315
2016-02-15 21:18:43 +01:00
ArthurHoaro
21979ff11c Add exclusion in tag search
* Searching '-mytag' will now exlude all shaares with 'mytag' tag.
  * All tags starting with a '-' are renamed without it (through the Updater).
  * Unit tests.

Minor code changes:

 * LinkDB->filter() can now take no parameters (get all link depending on logged status).
 * tagsStrToArray() is now static and filters blank tags.
2016-02-15 20:40:39 +01:00
ArthurHoaro
510377d2cb Introduce the Updater class which
* contains methods designed to be run once.
  * is able to upgrade the datastore or the configuration.
  * is based on methods names, stored in a text file with ';' separator (updates.txt).
  * begins with existing function 'mergeDeprecatedConfigFile()' (options.php).
2016-02-15 20:30:24 +01:00
Arthur
268a2e5265 Merge pull request #453 from ArthurHoaro/pr450
Implemented a little more sophisticated searching (squashed)
2016-02-01 19:21:47 +01:00
Florian Voigt
ebd8075a89 Implemented searching for a phrase in double-quotes or all words in no particular order.
+ unit tests
2016-02-01 19:18:27 +01:00
Arthur
53603f5823 Merge pull request #388 from ArthurHoaro/pluginadmin
Fixes #378 - Plugin administration UI.
2016-01-31 19:00:13 +01:00
Arthur
893338f0d4 Merge pull request #379 from ArthurHoaro/plugin-markdown
PLUGIN Markdown
2016-01-31 18:57:29 +01:00
ArthurHoaro
dea0ba28f9 Fixes #378 - Plugin administration UI. 2016-01-31 18:54:48 +01:00
VirtualTam
aa7f7b3ea6 fix: use PHP_EOL for carriage returns in file logs
Relates to #436

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-01-18 00:24:36 +01:00
VirtualTam
478ce8afb4 Logging: improve formatting to enable fail2ban parsing
Fixes #436

Modifications:
- remove calls to strval() on safe data
- update the date format: 'Y/m/d_H:i:s' => 'Y/m/d H:i:s'

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-01-16 16:19:44 +01:00
VirtualTam
1abe655597 Logging: move logm() from index.php to application/Utils.php
Relates to #436

Modifications:
- inject dependencies to global variables ($_SERVER, $GLOBALS)
- apply coding conventions
- add test coverage

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2016-01-16 16:07:16 +01:00
ArthurHoaro
1557cefbd7 Fixes #410 - Retrieve title fails in multiple cases
* `get_http_url()` renamed to `get_http_response()`.
  * Use the same HTTP context to retrieve response headers and content.
  * Follow HTTP 301 and 302 redirections to retrieve the title (default max 3 redirections).
  * Add `LinkUtils` to extract titles and charset.
  * Try to retrieve charset from HTTP headers first (new), then HTML content.
  * Use mb_string to re-encode title if necessary.
2016-01-11 21:19:31 +01:00
Arthur
88c15abb2a Merge pull request #424 from ArthurHoaro/search
Link filter refactoring
2016-01-06 19:57:42 +01:00
ArthurHoaro
822bffced8 Link filter refactoring
* introduce class LinkFilter to handle link filter operation (and lighten LinkDB).
  * handle 'private only' in filtering.
  * update template to prefill search fields with current search terms.
  * coding style.
  * unit test (mostly move from LinkDB to LinkFilter).

PS: preparation for #358 #315 and 'AND' search.
2016-01-06 19:53:04 +01:00
ArthurHoaro
1be4afacf9 PLUGIN Markdown
Parse link description in Markdown (HTML) before rendering.

      * hard remove of Shaarli's HTML before parsing.
      * Using Parsedown <https://github.com/erusev/parsedown> PHP lib.
      * Includes basic markdown CSS.
      * Style: removed 400px height max limit for shaares.
      * Unit tests.
2016-01-03 17:36:10 +01:00
VirtualTam
defc8a3f03 Merge pull request #417 from ArthurHoaro/wallabag-improve
Wallabag plugin improvement
2016-01-02 20:09:29 +01:00
ArthurHoaro
938d9cce77 Wallabag plugin improvement
* Fixes a bug where URL weren't properly encoded.
  * Adds Wallabag V2 support.
  * Adds a URL function to handle trailing slash.
  * UT.
  * README updated.
2015-12-27 15:30:34 +01:00
ArthurHoaro
49e62f22ad QRCode plugin: use url instead of real_url
Fixes #414 and avoid usage of redirector in QRCode.

Also fixed a bug with URL encoding.
2015-12-22 10:59:41 +01:00
ArthurHoaro
b6a54537b8 Remove dummycache folder on tear down. 2015-12-03 19:27:34 +01:00
VirtualTam
4407b45fd3 application: default to the "stable" branch for update checks
Relates to #372
Relates to #390

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2015-11-27 00:10:43 +01:00
VirtualTam
4bf35ba56b application: refactor version checks, move to ApplicationUtils
Relates to #372

Modifications:
 - move checkUpdate() to ApplicationUtils
 - reduce file I/O operations during version checks
 - apply coding conventions
 - add test coverage

Tools:
 - create a sandbox directory for tests

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2015-11-26 23:19:37 +01:00
ArthurHoaro
90e5bd65c9 URL encode links when a redirector is set.
Fixes #328 - URL encode links when a redirector is set

  * WARNING - template edit - new variable available : "real_url"
  Contains the final real url (redirected or any other change on original URL)

  * Don't redirect shaares link in RSS/Atom.
  * Affects links shaared in description.
  * Move text2clickable and keepMultipleSpaces to Utils.php + unit test

UPDATE:

* keepMultipleSpaces renamed to space2nbsp
* space2nbsp improved to handle single space at line beginning
* links in text description aren't 'nofollow' anymore
2015-11-26 20:14:38 +01:00
VirtualTam
c9cf2715f0 application: move checkPHPVersion from Utils to ApplicationUtils
Relates to #372

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2015-11-24 01:40:44 +01:00
VirtualTam
2e28269bae install: check file/directory permissions for Shaarli resources
Relates to #40
Relates to #372

Additions:
 - FileUtils: IOException
 - ApplicationUtils:
   - check if Shaarli resources are accessible with sufficient permissions
   - basic test coverage
 - index.php:
   - check access permissions and redirect to an error page if needed:
     - before running the first installation

Modifications:
 - LinkDB:
   - factorize datastore write code
   - check if the datastore
     (exists AND is writeable) OR (doesn't exist AND its parent dir is writable)
   - raise an IOException if needed

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2015-11-24 01:12:35 +01:00
VirtualTam
a7921b2445 cleanup: remove the executable bit from source scripts
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
2015-11-11 19:19:24 +01:00
Arthur
fd006c630b Merge pull request #275 from shaarli/plugin-proposition
Plugin proposition
2015-11-08 13:29:32 +01:00