]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #417 from ArthurHoaro/wallabag-improve
authorVirtualTam <virtualtam@flibidi.net>
Sat, 2 Jan 2016 19:09:29 +0000 (20:09 +0100)
committerVirtualTam <virtualtam@flibidi.net>
Sat, 2 Jan 2016 19:09:29 +0000 (20:09 +0100)
Wallabag plugin improvement

23 files changed:
.gitattributes [new file with mode: 0644]
application/LinkDB.php
docker/.htaccess [new file with mode: 0644]
docker/development/Dockerfile [new file with mode: 0644]
docker/development/IMAGE.md [new file with mode: 0644]
docker/development/nginx.conf [new file with mode: 0644]
docker/development/supervised.conf [new file with mode: 0644]
docker/production/Dockerfile [new file with mode: 0644]
docker/production/IMAGE.md [new file with mode: 0644]
docker/production/nginx.conf [new file with mode: 0644]
docker/production/stable/Dockerfile [new file with mode: 0644]
docker/production/stable/IMAGE.md [new file with mode: 0644]
docker/production/stable/nginx.conf [new file with mode: 0644]
docker/production/stable/supervised.conf [new file with mode: 0644]
docker/production/supervised.conf [new file with mode: 0644]
inc/shaarli.css
index.php
plugins/qrcode/qrcode.css [new file with mode: 0755]
plugins/qrcode/qrcode.html
plugins/qrcode/qrcode.php
plugins/qrcode/shaarli-qrcode.js
shaarli_version.php
tests/plugins/PlugQrcodeTest.php

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..aaf6a39
--- /dev/null
@@ -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
index f771ac8bf7b1677c99c67ac468ea33009c69a6cc..51fa926df328b19646053c3741b836db1eb3727e 100644 (file)
  *  - 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 (file)
index 0000000..b584d98
--- /dev/null
@@ -0,0 +1,2 @@
+Allow from none
+Deny from all
diff --git a/docker/development/Dockerfile b/docker/development/Dockerfile
new file mode 100644 (file)
index 0000000..2ed59b8
--- /dev/null
@@ -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 "<?php phpinfo(); ?>" > /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 (file)
index 0000000..e2ff0f0
--- /dev/null
@@ -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 (file)
index 0000000..cda09b5
--- /dev/null
@@ -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 (file)
index 0000000..5acd979
--- /dev/null
@@ -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 (file)
index 0000000..3db4eb5
--- /dev/null
@@ -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 (file)
index 0000000..6f827b3
--- /dev/null
@@ -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 (file)
index 0000000..e23c458
--- /dev/null
@@ -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 (file)
index 0000000..2bb3948
--- /dev/null
@@ -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 (file)
index 0000000..d85b1d7
--- /dev/null
@@ -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 (file)
index 0000000..e23c458
--- /dev/null
@@ -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 (file)
index 0000000..5acd979
--- /dev/null
@@ -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 (file)
index 0000000..5acd979
--- /dev/null
@@ -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
index 451f0481bd041c5a0be359785e4fe2c82d727b32..d6bbdbc124a3130f09821d945fe4263a2467af3c 100644 (file)
@@ -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;
index d0876d957721bba0225bc4a7e72cb885698f6662..40a6fbe5a1a5c6e0c2f1d3b06782617df2da9c54 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,6 +1,6 @@
 <?php
 /**
- * Shaarli v0.6.1 - Shaare your links...
+ * Shaarli v0.6.2 - Shaare your links...
  *
  * The personal, minimalist, super-fast, no-database Delicious clone.
  *
@@ -119,7 +119,7 @@ $GLOBALS['config']['PUBSUBHUB_URL'] = '';
 /*
  * PHP configuration
  */
-define('shaarli_version', '0.6.1');
+define('shaarli_version', '0.6.2');
 
 // http://server.com/x/shaarli --> /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 (executable)
index 0000000..0d514a0
--- /dev/null
@@ -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;
+}
index 58ac50074a1aa4b34cd3bd0515feb589be625313..ffdaf3b82ed00e644add10d3eaf8eb9384e20d69 100644 (file)
@@ -1,3 +1,5 @@
-<a href="http://qrfree.kaywa.com/?l=1&amp;s=8&amp;d=%s" onclick="showQrCode(this); return false;" class="qrcode" data-permalink="%s">
-    <img src="%s/qrcode/qrcode.png" width="13" height="13" title="QR-Code">
-</a>
+<div class="linkqrcode">
+    <a href="http://qrfree.kaywa.com/?l=1&amp;s=8&amp;d=%s" onclick="showQrCode(this); return false;" class="qrcode" data-permalink="%s">
+        <img src="%s/qrcode/qrcode.png" width="13" height="13" title="QR-Code">
+    </a>
+</div>
index 5f6e76a2f8c42d035f0c7026158b463935d953b0..8bc610d1fad120ec34694c4d3c1a3c7501f14e64 100644 (file)
@@ -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;
+}
index 0a8de21de7f7a6c8b3b258e97041ae7e41a5cc60..615f54c72c3cfe42e3a8df6b8d3aa3bfc9a46c1b 100644 (file)
@@ -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 += "<br>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);
     }
index 11ad87d7c52814896a0ca255b2e33d9a5b2a3d08..fe5f3896dfd2cbcf6d87ed3f5998203b508d4615 100644 (file)
@@ -1 +1 @@
-<?php /* 0.6.1 */ ?>
+<?php /* 0.6.2 */ ?>
index c749fa86f6a49aa167bb4c8c7761a2ce32b38f8c..86dc7f293059a94830f0cbec3f0f7cc74229becc 100644 (file)
@@ -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']));