diff options
author | yude <yudesleepy@gmail.com> | 2021-01-04 18:51:10 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 18:51:10 +0900 |
commit | e6754f2154a79abd8e5e64bd923f6984aa9ad44b (patch) | |
tree | f074119530bb59ef155938ea367f719f1e4b70f1 /doc | |
parent | 5256b4287021342a9f8868967b2a77e481314331 (diff) | |
parent | ed4ee8f0297941ac83300389b7de6a293312d20e (diff) | |
download | Shaarli-e6754f2154a79abd8e5e64bd923f6984aa9ad44b.tar.gz Shaarli-e6754f2154a79abd8e5e64bd923f6984aa9ad44b.tar.zst Shaarli-e6754f2154a79abd8e5e64bd923f6984aa9ad44b.zip |
Merge pull request #2 from shaarli/master
Merge fork source
Diffstat (limited to 'doc')
-rw-r--r-- | doc/md/Docker.md | 7 | ||||
-rw-r--r-- | doc/md/REST-API.md | 2 | ||||
-rw-r--r-- | doc/md/Server-configuration.md | 41 | ||||
-rw-r--r-- | doc/md/Shaarli-configuration.md | 19 | ||||
-rw-r--r-- | doc/md/dev/Development.md | 12 | ||||
-rw-r--r-- | doc/md/dev/Plugin-system.md | 25 | ||||
-rw-r--r-- | doc/md/dev/Release-Shaarli.md | 8 |
7 files changed, 82 insertions, 32 deletions
diff --git a/doc/md/Docker.md b/doc/md/Docker.md index c152fe92..fc406c00 100644 --- a/doc/md/Docker.md +++ b/doc/md/Docker.md | |||
@@ -1,3 +1,4 @@ | |||
1 | |||
1 | # Docker | 2 | # Docker |
2 | 3 | ||
3 | [Docker](https://docs.docker.com/get-started/overview/) is an open platform for developing, shipping, and running applications | 4 | [Docker](https://docs.docker.com/get-started/overview/) is an open platform for developing, shipping, and running applications |
@@ -113,9 +114,11 @@ $ mkdir shaarli && cd shaarli | |||
113 | # Download the latest version of Shaarli's docker-compose.yml | 114 | # Download the latest version of Shaarli's docker-compose.yml |
114 | $ curl -L https://raw.githubusercontent.com/shaarli/Shaarli/latest/docker-compose.yml -o docker-compose.yml | 115 | $ curl -L https://raw.githubusercontent.com/shaarli/Shaarli/latest/docker-compose.yml -o docker-compose.yml |
115 | # Create the .env file and fill in your VPS and domain information | 116 | # Create the .env file and fill in your VPS and domain information |
116 | # (replace <MY_SHAARLI_DOMAIN> and <MY_CONTACT_EMAIL> with your actual information) | 117 | # (replace <shaarli.mydomain.org>, <admin@mydomain.org> and <latest> with your actual information) |
117 | $ echo 'SHAARLI_VIRTUAL_HOST=shaarli.mydomain.org' > .env | 118 | $ echo 'SHAARLI_VIRTUAL_HOST=shaarli.mydomain.org' > .env |
118 | $ echo 'SHAARLI_LETSENCRYPT_EMAIL=admin@mydomain.org' >> .env | 119 | $ echo 'SHAARLI_LETSENCRYPT_EMAIL=admin@mydomain.org' >> .env |
120 | # Available Docker tags can be found at https://hub.docker.com/r/shaarli/shaarli/tags | ||
121 | $ echo 'SHAARLI_DOCKER_TAG=latest' >> .env | ||
119 | # Pull the Docker images | 122 | # Pull the Docker images |
120 | $ docker-compose pull | 123 | $ docker-compose pull |
121 | # Run! | 124 | # Run! |
@@ -224,4 +227,4 @@ $ docker system prune | |||
224 | - [docker pull](https://docs.docker.com/engine/reference/commandline/pull/) | 227 | - [docker pull](https://docs.docker.com/engine/reference/commandline/pull/) |
225 | - [docker run](https://docs.docker.com/engine/reference/commandline/run/) | 228 | - [docker run](https://docs.docker.com/engine/reference/commandline/run/) |
226 | - [docker-compose logs](https://docs.docker.com/compose/reference/logs/) | 229 | - [docker-compose logs](https://docs.docker.com/compose/reference/logs/) |
227 | - Træfik: [Getting Started](https://docs.traefik.io/), [Docker backend](https://docs.traefik.io/configuration/backends/docker/), [Let's Encrypt](https://docs.traefik.io/user-guide/docker-and-lets-encrypt/), [Docker image](https://hub.docker.com/_/traefik/) \ No newline at end of file | 230 | - Træfik: [Getting Started](https://docs.traefik.io/), [Docker backend](https://docs.traefik.io/configuration/backends/docker/), [Let's Encrypt](https://docs.traefik.io/user-guide/docker-and-lets-encrypt/), [Docker image](https://hub.docker.com/_/traefik/) |
diff --git a/doc/md/REST-API.md b/doc/md/REST-API.md index 01071d8e..2a36ea29 100644 --- a/doc/md/REST-API.md +++ b/doc/md/REST-API.md | |||
@@ -73,7 +73,7 @@ var_dump(getInfo($baseUrl, $secret)); | |||
73 | ### Authentication | 73 | ### Authentication |
74 | 74 | ||
75 | - All requests to Shaarli's API must include a **JWT token** to verify their authenticity. | 75 | - All requests to Shaarli's API must include a **JWT token** to verify their authenticity. |
76 | - This token must be included as an HTTP header called `Authentication: Bearer <jwt token>`. | 76 | - This token must be included as an HTTP header called `Authorization: Bearer <jwt token>`. |
77 | - JWT tokens are composed by three parts, separated by a dot `.` and encoded in base64: | 77 | - JWT tokens are composed by three parts, separated by a dot `.` and encoded in base64: |
78 | 78 | ||
79 | ``` | 79 | ``` |
diff --git a/doc/md/Server-configuration.md b/doc/md/Server-configuration.md index 8cb39934..a49b6033 100644 --- a/doc/md/Server-configuration.md +++ b/doc/md/Server-configuration.md | |||
@@ -193,19 +193,24 @@ sudo nano /etc/apache2/sites-available/shaarli.mydomain.org.conf | |||
193 | Require all granted | 193 | Require all granted |
194 | </Directory> | 194 | </Directory> |
195 | 195 | ||
196 | <LocationMatch "/\."> | 196 | # BE CAREFUL: directives order matter! |
197 | # Prevent accessing dotfiles | ||
198 | RedirectMatch 404 ".*" | ||
199 | </LocationMatch> | ||
200 | 197 | ||
201 | <LocationMatch "\.(?:ico|css|js|gif|jpe?g|png)$"> | 198 | <FilesMatch ".*\.(?!(ico|css|js|gif|jpe?g|png|ttf|oet|woff2?)$)[^\.]*$"> |
199 | Require all denied | ||
200 | </FilesMatch> | ||
201 | |||
202 | <Files "index.php"> | ||
203 | Require all granted | ||
204 | </Files> | ||
205 | |||
206 | <FilesMatch "\.(?:ico|css|js|gif|jpe?g|png|ttf|oet|woff2)$"> | ||
202 | # allow client-side caching of static files | 207 | # allow client-side caching of static files |
203 | Header set Cache-Control "max-age=2628000, public, must-revalidate, proxy-revalidate" | 208 | Header set Cache-Control "max-age=2628000, public, must-revalidate, proxy-revalidate" |
204 | </LocationMatch> | 209 | </FilesMatch> |
210 | |||
205 | 211 | ||
206 | # serve the Shaarli favicon from its custom location | 212 | # serve the Shaarli favicon from its custom location |
207 | Alias favicon.ico /var/www/shaarli.mydomain.org/images/favicon.ico | 213 | Alias favicon.ico /var/www/shaarli.mydomain.org/images/favicon.ico |
208 | |||
209 | </VirtualHost> | 214 | </VirtualHost> |
210 | ``` | 215 | ``` |
211 | 216 | ||
@@ -296,7 +301,7 @@ server { | |||
296 | location / { | 301 | location / { |
297 | # default index file when no file URI is requested | 302 | # default index file when no file URI is requested |
298 | index index.php; | 303 | index index.php; |
299 | try_files $uri /index.php$is_args$args; | 304 | try_files _ /index.php$is_args$args; |
300 | } | 305 | } |
301 | 306 | ||
302 | location ~ (index)\.php$ { | 307 | location ~ (index)\.php$ { |
@@ -309,20 +314,9 @@ server { | |||
309 | include fastcgi.conf; | 314 | include fastcgi.conf; |
310 | } | 315 | } |
311 | 316 | ||
312 | location ~ \.php$ { | 317 | location ~ /doc/html/ { |
313 | # deny access to all other PHP scripts | 318 | default_type "text/html"; |
314 | # disable this if you host other PHP applications on the same virtualhost | 319 | try_files $uri $uri/ $uri.html =404; |
315 | deny all; | ||
316 | } | ||
317 | |||
318 | location ~ /\. { | ||
319 | # deny access to dotfiles | ||
320 | deny all; | ||
321 | } | ||
322 | |||
323 | location ~ ~$ { | ||
324 | # deny access to temp editor files, e.g. "script.php~" | ||
325 | deny all; | ||
326 | } | 320 | } |
327 | 321 | ||
328 | location = /favicon.ico { | 322 | location = /favicon.ico { |
@@ -331,13 +325,12 @@ server { | |||
331 | } | 325 | } |
332 | 326 | ||
333 | # allow client-side caching of static files | 327 | # allow client-side caching of static files |
334 | location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { | 328 | location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|oet|woff2?)$ { |
335 | expires max; | 329 | expires max; |
336 | add_header Cache-Control "public, must-revalidate, proxy-revalidate"; | 330 | add_header Cache-Control "public, must-revalidate, proxy-revalidate"; |
337 | # HTTP 1.0 compatibility | 331 | # HTTP 1.0 compatibility |
338 | add_header Pragma public; | 332 | add_header Pragma public; |
339 | } | 333 | } |
340 | |||
341 | } | 334 | } |
342 | ``` | 335 | ``` |
343 | 336 | ||
diff --git a/doc/md/Shaarli-configuration.md b/doc/md/Shaarli-configuration.md index 263fb761..b1326cce 100644 --- a/doc/md/Shaarli-configuration.md +++ b/doc/md/Shaarli-configuration.md | |||
@@ -74,6 +74,7 @@ Some settings can be configured directly from a web browser by accesing the `Too | |||
74 | "timezone": "Europe\/Paris", | 74 | "timezone": "Europe\/Paris", |
75 | "title": "My Shaarli", | 75 | "title": "My Shaarli", |
76 | "header_link": "?" | 76 | "header_link": "?" |
77 | "tags_separator": " " | ||
77 | }, | 78 | }, |
78 | "dev": { | 79 | "dev": { |
79 | "debug": false, | 80 | "debug": false, |
@@ -150,8 +151,10 @@ _These settings should not be edited_ | |||
150 | - **timezone**: See [the list of supported timezones](http://php.net/manual/en/timezones.php). | 151 | - **timezone**: See [the list of supported timezones](http://php.net/manual/en/timezones.php). |
151 | - **enabled_plugins**: List of enabled plugins. | 152 | - **enabled_plugins**: List of enabled plugins. |
152 | - **default_note_title**: Default title of a new note. | 153 | - **default_note_title**: Default title of a new note. |
154 | - **enable_async_metadata** (boolean): Retrieve external bookmark metadata asynchronously to prevent bookmark creation slowdown. | ||
153 | - **retrieve_description** (boolean): If set to true, for every new Shaare Shaarli will try to retrieve the description and keywords from the HTML meta tags. | 155 | - **retrieve_description** (boolean): If set to true, for every new Shaare Shaarli will try to retrieve the description and keywords from the HTML meta tags. |
154 | - **root_url**: Overrides automatic discovery of Shaarli instance's URL (e.g.) `https://sub.domain.tld/shaarli-folder/`. | 156 | - **root_url**: Overrides automatic discovery of Shaarli instance's URL (e.g.) `https://sub.domain.tld/shaarli-folder/`. |
157 | - **tags_separator**: Defines your tags separator (default: whitespace). | ||
155 | 158 | ||
156 | ### Security | 159 | ### Security |
157 | 160 | ||
@@ -163,6 +166,22 @@ _These settings should not be edited_ | |||
163 | - **trusted_proxies**: List of trusted IP which won't be banned after failed login attemps. Useful if Shaarli is behind a reverse proxy. | 166 | - **trusted_proxies**: List of trusted IP which won't be banned after failed login attemps. Useful if Shaarli is behind a reverse proxy. |
164 | - **allowed_protocols**: List of allowed protocols in shaare URLs or markdown-rendered descriptions. Useful if you want to store `javascript:` links (bookmarklets) in Shaarli (default: `["ftp", "ftps", "magnet"]`). | 167 | - **allowed_protocols**: List of allowed protocols in shaare URLs or markdown-rendered descriptions. Useful if you want to store `javascript:` links (bookmarklets) in Shaarli (default: `["ftp", "ftps", "magnet"]`). |
165 | 168 | ||
169 | ### Formatter | ||
170 | |||
171 | Single string value. Default available: | ||
172 | |||
173 | - `default`: supports line breaks, URL and hashtag auto-links. | ||
174 | - `markdown`: supports [Markdown](https://daringfireball.net/projects/markdown/syntax). | ||
175 | - `markdownExtra`: adds [extra](https://michelf.ca/projects/php-markdown/extra/) flavor to Markdown. | ||
176 | |||
177 | ### Formatter Settings | ||
178 | |||
179 | Additional settings applied to formatters. | ||
180 | |||
181 | #### default | ||
182 | |||
183 | - **autolink**: boolean to enable or disable automatic linkification of URL and hashtags. | ||
184 | |||
166 | ### Resources | 185 | ### Resources |
167 | 186 | ||
168 | - **data_dir**: Data directory. | 187 | - **data_dir**: Data directory. |
diff --git a/doc/md/dev/Development.md b/doc/md/dev/Development.md index 5c085e03..c42e8ffe 100644 --- a/doc/md/dev/Development.md +++ b/doc/md/dev/Development.md | |||
@@ -6,7 +6,7 @@ Please read [Contributing to Shaarli](https://github.com/shaarli/Shaarli/tree/ma | |||
6 | 6 | ||
7 | 7 | ||
8 | - [Unit tests](Unit-tests) | 8 | - [Unit tests](Unit-tests) |
9 | - Javascript linting - Shaarli uses [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript). | 9 | - Javascript linting - Shaarli uses [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript). |
10 | Run `make eslint` to check JS style. | 10 | Run `make eslint` to check JS style. |
11 | - [GnuPG signature](GnuPG-signature) for tags/releases | 11 | - [GnuPG signature](GnuPG-signature) for tags/releases |
12 | 12 | ||
@@ -51,12 +51,12 @@ PHP (managed through [`composer.json`](https://github.com/shaarli/Shaarli/blob/m | |||
51 | 51 | ||
52 | ## Link structure | 52 | ## Link structure |
53 | 53 | ||
54 | Every link available through the `LinkDB` object is represented as an array | 54 | Every link available through the `LinkDB` object is represented as an array |
55 | containing the following fields: | 55 | containing the following fields: |
56 | 56 | ||
57 | * `id` (integer): Unique identifier. | 57 | * `id` (integer): Unique identifier. |
58 | * `title` (string): Title of the link. | 58 | * `title` (string): Title of the link. |
59 | * `url` (string): URL of the link. Used for displayable links (without redirector, url encoding, etc.). | 59 | * `url` (string): URL of the link. Used for displayable links (without redirector, url encoding, etc.). |
60 | Can be absolute or relative for Notes. | 60 | Can be absolute or relative for Notes. |
61 | * `real_url` (string): Real destination URL, can be redirected, encoded, etc. | 61 | * `real_url` (string): Real destination URL, can be redirected, encoded, etc. |
62 | * `shorturl` (string): Permalink small hash. | 62 | * `shorturl` (string): Permalink small hash. |
@@ -66,7 +66,7 @@ containing the following fields: | |||
66 | * `thumbnail` (string|boolean): relative path of the thumbnail cache file, or false if there isn't any. | 66 | * `thumbnail` (string|boolean): relative path of the thumbnail cache file, or false if there isn't any. |
67 | * `created` (DateTime): link creation date time. | 67 | * `created` (DateTime): link creation date time. |
68 | * `updated` (DateTime): last modification date time. | 68 | * `updated` (DateTime): last modification date time. |
69 | 69 | ||
70 | Small hashes are used to make a link to an entry in Shaarli. They are unique: the date of the item (eg. `20110923_150523`) is hashed with CRC32, then converted to base64 and some characters are replaced. They are always 6 characters longs and use only `A-Z a-z 0-9 - _` and `@`. | 70 | Small hashes are used to make a link to an entry in Shaarli. They are unique: the date of the item (eg. `20110923_150523`) is hashed with CRC32, then converted to base64 and some characters are replaced. They are always 6 characters longs and use only `A-Z a-z 0-9 - _` and `@`. |
71 | 71 | ||
72 | 72 | ||
@@ -163,11 +163,13 @@ See [`.travis.yml`](https://github.com/shaarli/Shaarli/blob/master/.travis.yml). | |||
163 | 163 | ||
164 | ## Static analysis | 164 | ## Static analysis |
165 | 165 | ||
166 | Patches should try to stick to the [PHP Standard Recommendations](http://www.php-fig.org/psr/) (PSR), especially: | 166 | Patches should try to stick to the [PHP Standard Recommendations](http://www.php-fig.org/psr/) (PSR), and must follow: |
167 | 167 | ||
168 | - [PSR-1](http://www.php-fig.org/psr/psr-1/) - Basic Coding Standard | 168 | - [PSR-1](http://www.php-fig.org/psr/psr-1/) - Basic Coding Standard |
169 | - [PSR-2](http://www.php-fig.org/psr/psr-2/) - Coding Style Guide | 169 | - [PSR-2](http://www.php-fig.org/psr/psr-2/) - Coding Style Guide |
170 | - [PSR-12](http://www.php-fig.org/psr/psr-12/) - Extended Coding Style Guide | ||
170 | 171 | ||
172 | These are enforced on pull requests using our Continuous Integration tools. | ||
171 | 173 | ||
172 | **Work in progress:** Static analysis is currently being discussed here: in [#95 - Fix coding style (static analysis)](https://github.com/shaarli/Shaarli/issues/95), [#130 - Continuous Integration tools & features](https://github.com/shaarli/Shaarli/issues/130) | 174 | **Work in progress:** Static analysis is currently being discussed here: in [#95 - Fix coding style (static analysis)](https://github.com/shaarli/Shaarli/issues/95), [#130 - Continuous Integration tools & features](https://github.com/shaarli/Shaarli/issues/130) |
173 | 175 | ||
diff --git a/doc/md/dev/Plugin-system.md b/doc/md/dev/Plugin-system.md index f09fadc2..79654011 100644 --- a/doc/md/dev/Plugin-system.md +++ b/doc/md/dev/Plugin-system.md | |||
@@ -139,6 +139,31 @@ Each file contain two keys: | |||
139 | 139 | ||
140 | > Note: In PHP, `parse_ini_file()` seems to want strings to be between by quotes `"` in the ini file. | 140 | > Note: In PHP, `parse_ini_file()` seems to want strings to be between by quotes `"` in the ini file. |
141 | 141 | ||
142 | ### Register plugin's routes | ||
143 | |||
144 | Shaarli lets you register custom Slim routes for your plugin. | ||
145 | |||
146 | To register a route, the plugin must include a function called `function <plugin_name>_register_routes(): array`. | ||
147 | |||
148 | This method must return an array of routes, each entry must contain the following keys: | ||
149 | |||
150 | - `method`: HTTP method, `GET/POST/PUT/PATCH/DELETE` | ||
151 | - `route` (path): without prefix, e.g. `/up/{variable}` | ||
152 | It will be later prefixed by `/plugin/<plugin name>/`. | ||
153 | - `callable` string, function name or FQN class's method to execute, e.g. `demo_plugin_custom_controller`. | ||
154 | |||
155 | Callable functions or methods must have `Slim\Http\Request` and `Slim\Http\Response` parameters | ||
156 | and return a `Slim\Http\Response`. We recommend creating a dedicated class and extend either | ||
157 | `ShaarliVisitorController` or `ShaarliAdminController` to use helper functions they provide. | ||
158 | |||
159 | A dedicated plugin template is available for rendering content: `pluginscontent.html` using `content` placeholder. | ||
160 | |||
161 | > **Warning**: plugins are not able to use RainTPL template engine for their content due to technical restrictions. | ||
162 | > RainTPL does not allow to register multiple template folders, so all HTML rendering must be done within plugin | ||
163 | > custom controller. | ||
164 | |||
165 | Check out the `demo_plugin` for a live example: `GET <shaarli_url>/plugin/demo_plugin/custom`. | ||
166 | |||
142 | ### Understanding relative paths | 167 | ### Understanding relative paths |
143 | 168 | ||
144 | Because Shaarli is a self-hosted tool, an instance can either be installed at the root directory, or under a subfolder. | 169 | Because Shaarli is a self-hosted tool, an instance can either be installed at the root directory, or under a subfolder. |
diff --git a/doc/md/dev/Release-Shaarli.md b/doc/md/dev/Release-Shaarli.md index 2c772406..d79be9ce 100644 --- a/doc/md/dev/Release-Shaarli.md +++ b/doc/md/dev/Release-Shaarli.md | |||
@@ -64,6 +64,14 @@ git pull upstream master | |||
64 | 64 | ||
65 | # If releasing a new minor version, create a release branch | 65 | # If releasing a new minor version, create a release branch |
66 | $ git checkout -b v0.x | 66 | $ git checkout -b v0.x |
67 | # Otherwise just use the existing one | ||
68 | $ git checkout v0.x | ||
69 | |||
70 | # Get the latest changes | ||
71 | $ git merge master | ||
72 | |||
73 | # Check that everything went fine: | ||
74 | $ make test | ||
67 | 75 | ||
68 | # Bump shaarli_version.php from dev to 0.x.0, **without the v** | 76 | # Bump shaarli_version.php from dev to 0.x.0, **without the v** |
69 | $ vim shaarli_version.php | 77 | $ vim shaarli_version.php |