From: VirtualTam Date: Sat, 2 Jan 2016 19:09:29 +0000 (+0100) Subject: Merge pull request #417 from ArthurHoaro/wallabag-improve X-Git-Tag: v0.6.3~15 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=defc8a3f033a44602c598c2028a9ee3ee2a86d1d;hp=938d9cce77ed5098dd69643795cb4014f3688b35;p=github%2Fshaarli%2FShaarli.git Merge pull request #417 from ArthurHoaro/wallabag-improve Wallabag plugin improvement --- diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..aaf6a39e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,31 @@ +# Set default behavior +* text=auto eol=lf + +# Ensure sources are processed +*.conf text +*.css text +*.html text diff=html +*.js text +*.md text +*.php text diff=php +Dockerfile text + +# Do not alter images nor minified scripts +*.ico binary +*.jpg binary +*.png binary +*.min.css binary +*.min.js binary + +# Exclude from Git archives +.gitattributes export-ignore +.gitignore export-ignore +.travis.yml export-ignore +composer.json export-ignore +doc/**/*.json export-ignore +doc/**/*.md export-ignore +docker/ export-ignore +Doxyfile export-ignore +Makefile export-ignore +phpunit.xml export-ignore +tests/ export-ignore diff --git a/application/LinkDB.php b/application/LinkDB.php index f771ac8b..51fa926d 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -17,8 +17,10 @@ * - private: Is this link private? 0=no, other value=yes * - tags: tags attached to this entry (separated by spaces) * - title Title of the link - * - url URL of the link. Can be absolute or relative. + * - url URL of the link. Used for displayable links (no redirector, relative, etc.). + * Can be absolute or relative. * Relative URLs are permalinks (e.g.'?m-ukcw') + * - real_url Absolute processed URL. * * Implements 3 interfaces: * - ArrayAccess: behaves like an associative array; diff --git a/docker/.htaccess b/docker/.htaccess new file mode 100644 index 00000000..b584d98c --- /dev/null +++ b/docker/.htaccess @@ -0,0 +1,2 @@ +Allow from none +Deny from all diff --git a/docker/development/Dockerfile b/docker/development/Dockerfile new file mode 100644 index 00000000..2ed59b89 --- /dev/null +++ b/docker/development/Dockerfile @@ -0,0 +1,28 @@ +FROM debian:jessie +MAINTAINER Shaarli Community + +RUN apt-get update \ + && apt-get install -y \ + nginx-light php5-fpm php5-gd supervisor \ + git nano + +ADD https://getcomposer.org/composer.phar /usr/local/bin/composer +RUN chmod 755 /usr/local/bin/composer + +COPY nginx.conf /etc/nginx/nginx.conf +COPY supervised.conf /etc/supervisor/conf.d/supervised.conf +RUN echo "" > /var/www/index.php + +WORKDIR /var/www +RUN rm -rf html \ + && git clone https://github.com/shaarli/Shaarli.git shaarli \ + && chown -R www-data:www-data . + +WORKDIR /var/www/shaarli +RUN composer install + +VOLUME /var/www/shaarli/data + +EXPOSE 80 + +CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"] diff --git a/docker/development/IMAGE.md b/docker/development/IMAGE.md new file mode 100644 index 00000000..e2ff0f0e --- /dev/null +++ b/docker/development/IMAGE.md @@ -0,0 +1,10 @@ +## shaarli:dev +- [Debian 8 Jessie](https://hub.docker.com/_/debian/) +- [PHP5-FPM](http://php-fpm.org/) +- [Nginx](http://nginx.org/) +- [Shaarli](https://github.com/shaarli/Shaarli) + +### Development tools +- [composer](https://getcomposer.org/) +- [git](http://git-scm.com/) +- [nano](http://www.nano-editor.org/) diff --git a/docker/development/nginx.conf b/docker/development/nginx.conf new file mode 100644 index 00000000..cda09b56 --- /dev/null +++ b/docker/development/nginx.conf @@ -0,0 +1,64 @@ +user www-data www-data; +daemon off; +worker_processes 4; + +events { + worker_connections 768; +} + +http { + include mime.types; + default_type application/octet-stream; + keepalive_timeout 20; + + index index.html index.php; + + server { + listen 80; + root /var/www/shaarli; + + access_log /var/log/nginx/shaarli.access.log; + error_log /var/log/nginx/shaarli.error.log; + + location /phpinfo/ { + # add a PHP info page for convenience + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME /var/www/index.php; + include fastcgi_params; + } + + location ~ /\. { + # deny access to dotfiles + access_log off; + log_not_found off; + deny all; + } + + location ~ ~$ { + # deny access to temp editor files, e.g. "script.php~" + access_log off; + log_not_found off; + deny all; + } + + location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { + # cache static assets + expires max; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + + location ~ (index)\.php$ { + # filter and proxy PHP requests to PHP-FPM + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + include fastcgi.conf; + } + + location ~ \.php$ { + # deny access to all other PHP scripts + deny all; + } + } +} diff --git a/docker/development/supervised.conf b/docker/development/supervised.conf new file mode 100644 index 00000000..5acd9795 --- /dev/null +++ b/docker/development/supervised.conf @@ -0,0 +1,13 @@ +[program:php5-fpm] +command=/usr/sbin/php5-fpm -F +priority=5 +autostart=true +autorestart=true + +[program:nginx] +command=/usr/sbin/nginx +priority=10 +autostart=true +autorestart=true +stdout_events_enabled=true +stderr_events_enabled=true diff --git a/docker/production/Dockerfile b/docker/production/Dockerfile new file mode 100644 index 00000000..3db4eb56 --- /dev/null +++ b/docker/production/Dockerfile @@ -0,0 +1,20 @@ +FROM debian:jessie +MAINTAINER Shaarli Community + +RUN apt-get update \ + && apt-get install -y curl nginx-light php5-fpm php5-gd supervisor + +COPY nginx.conf /etc/nginx/nginx.conf +COPY supervised.conf /etc/supervisor/conf.d/supervised.conf + +WORKDIR /var/www +RUN rm -rf html \ + && curl -L https://github.com/shaarli/Shaarli/archive/master.tar.gz | tar xvzf - \ + && mv Shaarli-master shaarli \ + && chown -R www-data:www-data shaarli + +VOLUME /var/www/shaarli/data + +EXPOSE 80 + +CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"] diff --git a/docker/production/IMAGE.md b/docker/production/IMAGE.md new file mode 100644 index 00000000..6f827b35 --- /dev/null +++ b/docker/production/IMAGE.md @@ -0,0 +1,5 @@ +## shaarli:latest +- [Debian 8 Jessie](https://hub.docker.com/_/debian/) +- [PHP5-FPM](http://php-fpm.org/) +- [Nginx](http://nginx.org/) +- [Shaarli](https://github.com/shaarli/Shaarli) diff --git a/docker/production/nginx.conf b/docker/production/nginx.conf new file mode 100644 index 00000000..e23c4587 --- /dev/null +++ b/docker/production/nginx.conf @@ -0,0 +1,56 @@ +user www-data www-data; +daemon off; +worker_processes 4; + +events { + worker_connections 768; +} + +http { + include mime.types; + default_type application/octet-stream; + keepalive_timeout 20; + + index index.html index.php; + + server { + listen 80; + root /var/www/shaarli; + + access_log /var/log/nginx/shaarli.access.log; + error_log /var/log/nginx/shaarli.error.log; + + location ~ /\. { + # deny access to dotfiles + access_log off; + log_not_found off; + deny all; + } + + location ~ ~$ { + # deny access to temp editor files, e.g. "script.php~" + access_log off; + log_not_found off; + deny all; + } + + location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { + # cache static assets + expires max; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + + location ~ (index)\.php$ { + # filter and proxy PHP requests to PHP-FPM + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + include fastcgi.conf; + } + + location ~ \.php$ { + # deny access to all other PHP scripts + deny all; + } + } +} diff --git a/docker/production/stable/Dockerfile b/docker/production/stable/Dockerfile new file mode 100644 index 00000000..2bb3948c --- /dev/null +++ b/docker/production/stable/Dockerfile @@ -0,0 +1,20 @@ +FROM debian:jessie +MAINTAINER Shaarli Community + +RUN apt-get update \ + && apt-get install -y curl nginx-light php5-fpm php5-gd supervisor + +COPY nginx.conf /etc/nginx/nginx.conf +COPY supervised.conf /etc/supervisor/conf.d/supervised.conf + +WORKDIR /var/www +RUN rm -rf html \ + && curl -L https://github.com/shaarli/Shaarli/archive/stable.tar.gz | tar xvzf - \ + && mv Shaarli-stable shaarli \ + && chown -R www-data:www-data shaarli + +VOLUME /var/www/shaarli/data + +EXPOSE 80 + +CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"] diff --git a/docker/production/stable/IMAGE.md b/docker/production/stable/IMAGE.md new file mode 100644 index 00000000..d85b1d7a --- /dev/null +++ b/docker/production/stable/IMAGE.md @@ -0,0 +1,5 @@ +## shaarli:stable +- [Debian 8 Jessie](https://hub.docker.com/_/debian/) +- [PHP5-FPM](http://php-fpm.org/) +- [Nginx](http://nginx.org/) +- [Shaarli (stable)](https://github.com/shaarli/Shaarli/tree/stable) diff --git a/docker/production/stable/nginx.conf b/docker/production/stable/nginx.conf new file mode 100644 index 00000000..e23c4587 --- /dev/null +++ b/docker/production/stable/nginx.conf @@ -0,0 +1,56 @@ +user www-data www-data; +daemon off; +worker_processes 4; + +events { + worker_connections 768; +} + +http { + include mime.types; + default_type application/octet-stream; + keepalive_timeout 20; + + index index.html index.php; + + server { + listen 80; + root /var/www/shaarli; + + access_log /var/log/nginx/shaarli.access.log; + error_log /var/log/nginx/shaarli.error.log; + + location ~ /\. { + # deny access to dotfiles + access_log off; + log_not_found off; + deny all; + } + + location ~ ~$ { + # deny access to temp editor files, e.g. "script.php~" + access_log off; + log_not_found off; + deny all; + } + + location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { + # cache static assets + expires max; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + + location ~ (index)\.php$ { + # filter and proxy PHP requests to PHP-FPM + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + include fastcgi.conf; + } + + location ~ \.php$ { + # deny access to all other PHP scripts + deny all; + } + } +} diff --git a/docker/production/stable/supervised.conf b/docker/production/stable/supervised.conf new file mode 100644 index 00000000..5acd9795 --- /dev/null +++ b/docker/production/stable/supervised.conf @@ -0,0 +1,13 @@ +[program:php5-fpm] +command=/usr/sbin/php5-fpm -F +priority=5 +autostart=true +autorestart=true + +[program:nginx] +command=/usr/sbin/nginx +priority=10 +autostart=true +autorestart=true +stdout_events_enabled=true +stderr_events_enabled=true diff --git a/docker/production/supervised.conf b/docker/production/supervised.conf new file mode 100644 index 00000000..5acd9795 --- /dev/null +++ b/docker/production/supervised.conf @@ -0,0 +1,13 @@ +[program:php5-fpm] +command=/usr/sbin/php5-fpm -F +priority=5 +autostart=true +autorestart=true + +[program:nginx] +command=/usr/sbin/nginx +priority=10 +autostart=true +autorestart=true +stdout_events_enabled=true +stderr_events_enabled=true diff --git a/inc/shaarli.css b/inc/shaarli.css index 451f0481..d6bbdbc1 100644 --- a/inc/shaarli.css +++ b/inc/shaarli.css @@ -739,25 +739,6 @@ h1 { background: #ffffff; } -div#permalinkQrcode { - padding: 20px; - width: 220px; - height: 220px; - background-color: #ffffff; - border: 1px solid black; - position: absolute; - top: -100px; - left: -100px; - text-align: center; - font-size: 8pt; - z-index: 50; - -webkit-box-shadow: 2px 2px 20px 2px #333333; - -moz-box-shadow: 2px 2px 20px 2px #333333; - -o-box-shadow: 2px 2px 20px 2px #333333; - -ms-box-shadow: 2px 2px 20px 2px #333333; - box-shadow: 2px 2px 20px 2px #333333; -} - div.daily { font-family: Georgia, 'DejaVu Serif', Norasi, serif; background-color: #E6D6BE; diff --git a/index.php b/index.php index d0876d95..40a6fbe5 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@ /shaarli/ define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUEST_URI"], '/', 0))); diff --git a/plugins/qrcode/qrcode.css b/plugins/qrcode/qrcode.css new file mode 100755 index 00000000..0d514a0e --- /dev/null +++ b/plugins/qrcode/qrcode.css @@ -0,0 +1,23 @@ +.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 index 58ac5007..ffdaf3b8 100644 --- a/plugins/qrcode/qrcode.html +++ b/plugins/qrcode/qrcode.html @@ -1,3 +1,5 @@ - - - +
+ + + +
diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php index 5f6e76a2..8bc610d1 100644 --- a/plugins/qrcode/qrcode.php +++ b/plugins/qrcode/qrcode.php @@ -17,7 +17,11 @@ function hook_qrcode_render_linklist($data) $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); foreach ($data['links'] as &$value) { - $qrcode = sprintf($qrcode_html, $value['real_url'], $value['real_url'], PluginManager::$PLUGINS_PATH); + $qrcode = sprintf($qrcode_html, + urlencode($value['url']), + $value['url'], + PluginManager::$PLUGINS_PATH + ); $value['link_plugin'][] = $qrcode; } @@ -39,3 +43,19 @@ function hook_qrcode_render_footer($data) return $data; } + +/** + * When linklist is displayed, include qrcode CSS file. + * + * @param array $data - header data. + * + * @return mixed - header data with qrcode CSS file added. + */ +function hook_qrcode_render_includes($data) +{ + if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { + $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.css'; + } + + return $data; +} diff --git a/plugins/qrcode/shaarli-qrcode.js b/plugins/qrcode/shaarli-qrcode.js index 0a8de21d..615f54c7 100644 --- a/plugins/qrcode/shaarli-qrcode.js +++ b/plugins/qrcode/shaarli-qrcode.js @@ -19,7 +19,7 @@ function showQrCode(caller,loading) // Build the div which contains the QR-Code: var element = document.createElement('div'); - element.id="permalinkQrcode"; + element.id = 'permalinkQrcode'; // Make QR-Code div commit sepuku when clicked: if ( element.attachEvent ){ @@ -37,6 +37,12 @@ function showQrCode(caller,loading) element.appendChild(image); element.innerHTML += "
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 { @@ -48,7 +54,7 @@ function showQrCode(caller,loading) // Remove any displayed QR-Code function removeQrcode() { - var elem = document.getElementById("permalinkQrcode"); + var elem = document.getElementById('permalinkQrcode'); if (elem) { elem.parentNode.removeChild(elem); } diff --git a/shaarli_version.php b/shaarli_version.php index 11ad87d7..fe5f3896 100644 --- a/shaarli_version.php +++ b/shaarli_version.php @@ -1 +1 @@ - + diff --git a/tests/plugins/PlugQrcodeTest.php b/tests/plugins/PlugQrcodeTest.php index c749fa86..86dc7f29 100644 --- a/tests/plugins/PlugQrcodeTest.php +++ b/tests/plugins/PlugQrcodeTest.php @@ -30,7 +30,7 @@ class PlugQrcodeTest extends PHPUnit_Framework_TestCase 'title' => $str, 'links' => array( array( - 'real_url' => $str, + 'url' => $str, ) ) ); @@ -39,7 +39,7 @@ class PlugQrcodeTest extends PHPUnit_Framework_TestCase $link = $data['links'][0]; // data shouldn't be altered $this->assertEquals($str, $data['title']); - $this->assertEquals($str, $link['real_url']); + $this->assertEquals($str, $link['url']); // plugin data $this->assertEquals(1, count($link['link_plugin']));