]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1025 from ArthurHoaro/hotfix/proxy-443
authorArthurHoaro <arthur@hoa.ro>
Sun, 3 Dec 2017 11:46:43 +0000 (12:46 +0100)
committerGitHub <noreply@github.com>
Sun, 3 Dec 2017 11:46:43 +0000 (12:46 +0100)
Force HTTPS if the original port is 443 behind a reverse proxy

Makefile
application/HttpUtils.php
application/SessionManager.php
doc/md/Download-and-Installation.md
doc/md/Unit-tests.md
tests/SessionManagerTest.php
tests/utils/FakeConfigManager.php [new file with mode: 0644]
tpl/default/img/apple-touch-icon.png [new file with mode: 0644]
tpl/default/includes.html

index c2d5594605943f87e16da7dee295acfff5e074ab..d659d908e45aad561638d8f7617b30b3ed51c35a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,6 @@
 # The personal, minimalist, super-fast, database free, bookmarking service.
 # Makefile for PHP code analysis & testing, documentation and release generation
 
-# Prerequisites:
-# - install Composer, either:
-#   - from your distro's package manager;
-#   - from the official website (https://getcomposer.org/download/);
-# - install/update test dependencies:
-#   $ composer install  # 1st setup
-#   $ composer update
-# - install Xdebug for PHPUnit code coverage reports:
-#   - see http://xdebug.org/docs/install
-#   - enable in php.ini
-
 BIN = vendor/bin
 PHP_SOURCE = index.php application tests plugins
 PHP_COMMA_SOURCE = index.php,application,tests,plugins
index c6181df44d3938842067f02d589b9253839b2f3e..c9371b55c5cc6ddacd9a888984889a466075b63a 100644 (file)
@@ -76,7 +76,7 @@ function get_http_response($url, $timeout = 30, $maxBytes = 4194304)
     curl_setopt($ch, CURLOPT_USERAGENT,         $userAgent);
 
     // Max download size management
-    curl_setopt($ch, CURLOPT_BUFFERSIZE,        1024);
+    curl_setopt($ch, CURLOPT_BUFFERSIZE,        1024*16);
     curl_setopt($ch, CURLOPT_NOPROGRESS,        false);
     curl_setopt($ch, CURLOPT_PROGRESSFUNCTION,
         function($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes)
index 3aa4ddfc7be9f80866538f0f73f4512beaf52af8..71f0b38dc227e38e2a9022a5c6c7a417060db935 100644 (file)
@@ -12,12 +12,12 @@ class SessionManager
      * Constructor
      *
      * @param array         $session The $_SESSION array (reference)
-     * @param ConfigManager $conf    ConfigManager instance (reference)
+     * @param ConfigManager $conf    ConfigManager instance
      */
-    public function __construct(& $session, $conf)
+    public function __construct(& $session, $conf)
     {
         $this->session = &$session;
-        $this->conf = &$conf;
+        $this->conf = $conf;
     }
 
     /**
index be848c97e9ab44f8629b5ffbeb2ad69d82c67b31..e64d1a43e25b55c4d53e64579e625335eb02b2b4 100644 (file)
@@ -17,40 +17,44 @@ Using one of the following methods:
 - by cloning the Git repository
 - using Docker: [see the documentation](docker/shaarli-images)
 
----
+--------------------------------------------------------------------------------
 
 ## Latest release (recommended)
+
 ### Download as an archive
-Get the latest released version from the [releases](https://github.com/shaarli/Shaarli/releases) page.
 
-**Download our *shaarli-full* archive** to include dependencies.
+In most cases, you should download the latest Shaarli release from the [releases](https://github.com/shaarli/Shaarli/releases) page. **Download our *shaarli-full* archive** to include dependencies.
 
 The current latest released version is `v0.9.1`
 
-Or in command lines:
-
 ```bash
 $ wget https://github.com/shaarli/Shaarli/releases/download/v0.9.1/shaarli-v0.9.1-full.zip
 $ unzip shaarli-v0.9.1-full.zip
 $ mv Shaarli /path/to/shaarli/
 ```
 
-In most cases, download Shaarli from the [releases](https://github.com/shaarli/Shaarli/releases) page. 
-Cloning using `git` or downloading Github branches as zip files requires additional steps (see below).
-
 ### Using git
 
+Cloning using `git` or downloading Github branches as zip files requires additional steps:
+
+ * Install [Composer](Unit-tests.md#install_composer) to manage Shaarli dependencies.
+ * Install [python3-virtualenv](https://pypi.python.org/pypi/virtualenv) to build the local HTML documentation.
+
 ```
 $ mkdir -p /path/to/shaarli && cd /path/to/shaarli/
 $ git clone -b latest https://github.com/shaarli/Shaarli.git .
 $ composer install --no-dev --prefer-dist
 $ make translate
+$ make htmldoc
 ```
 
+--------------------------------------------------------------------------------
+
 ## Stable version
 
 The stable version has been experienced by Shaarli users, and will receive security updates.
 
+
 ### Download as an archive
 
 As a .zip archive:
@@ -69,9 +73,9 @@ $ tar xvf stable.tar.gz
 $ mv Shaarli-stable /path/to/shaarli/
 ```
 
-### Clone with Git 
+### Using git
 
-[Composer](https://getcomposer.org/) is required to build a functional Shaarli installation when pulling from git.
+Install [Composer](Unit-tests.md#install_composer) to manage Shaarli dependencies.
 
 ```bash
 $ git clone https://github.com/shaarli/Shaarli.git -b stable /path/to/shaarli/
@@ -80,10 +84,15 @@ $ cd /path/to/shaarli/
 $ composer install --no-dev --prefer-dist
 ```
 
+
+--------------------------------------------------------------------------------
+
 ## Development version (mainline)
 
 _Use at your own risk!_
 
+Install [Composer](Unit-tests.md#install_composer) to manage Shaarli dependencies.
+
 To get the latest changes from the `master` branch:
 
 ```bash
@@ -93,8 +102,11 @@ $ git clone https://github.com/shaarli/Shaarli.git -b master /path/to/shaarli/
 $ cd /path/to/shaarli
 $ composer install --no-dev --prefer-dist
 $ make translate
+$ make htmldoc
 ```
 
+-------------------------------------------------------------------------------
+
 ## Finish Installation
 
 Once Shaarli is downloaded and files have been placed at the correct location, open it this location your favorite browser.
index d200634f6ea6513ff5094abc7971e0752cd2b543..f6030d5c2f6134848b58ed8987f1458c8dd4df23 100644 (file)
@@ -2,12 +2,12 @@
 
 The framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool.
 
-Regarding Composer, you can either use:
+### Install composer
 
-- a system-wide version, e.g. installed through your distro's package manager
-- a local version, downloadable [here](https://getcomposer.org/download/)
+You can either use:
 
-#### Sample usage
+- a system-wide version, e.g. installed through your distro's package manager
+- a local version, downloadable [here](https://getcomposer.org/download/).
 
 ```bash
 # system-wide version
@@ -29,6 +29,8 @@ $ composer update
 
 #### Install and enable Xdebug to generate PHPUnit coverage reports
 
+See http://xdebug.org/docs/install
+
 For Debian-based distros:
 ```bash
 $ aptitude install php5-xdebug
index a92c3cccc131c309882c2bda689a3baa507aa148..aa75962a4994929155c8da5ee2e48e85bb07fc18 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+require_once 'tests/utils/FakeConfigManager.php';
+
 // Initialize reference data _before_ PHPUnit starts a session
 require_once 'tests/utils/ReferenceSessionIdHashes.php';
 ReferenceSessionIdHashes::genAllHashes();
@@ -7,18 +9,6 @@ use \Shaarli\SessionManager;
 use \PHPUnit\Framework\TestCase;
 
 
-/**
- * Fake ConfigManager
- */
-class FakeConfigManager
-{
-    public static function get($key)
-    {
-        return $key;
-    }
-}
-
-
 /**
  * Test coverage for SessionManager
  */
@@ -27,12 +17,16 @@ class SessionManagerTest extends TestCase
     // Session ID hashes
     protected static $sidHashes = null;
 
+    // Fake ConfigManager
+    protected static $conf = null;
+
     /**
      * Assign reference data
      */
     public static function setUpBeforeClass()
     {
         self::$sidHashes = ReferenceSessionIdHashes::getHashes();
+        self::$conf = new FakeConfigManager();
     }
 
     /**
@@ -41,8 +35,7 @@ class SessionManagerTest extends TestCase
     public function testGenerateToken()
     {
         $session = [];
-        $conf = new FakeConfigManager();
-        $sessionManager = new SessionManager($session, $conf);
+        $sessionManager = new SessionManager($session, self::$conf);
 
         $token = $sessionManager->generateToken();
 
@@ -61,9 +54,7 @@ class SessionManagerTest extends TestCase
                 $token => 1,
             ],
         ];
-        $conf = new FakeConfigManager();
-        $sessionManager = new SessionManager($session, $conf);
-
+        $sessionManager = new SessionManager($session, self::$conf);
 
         // check and destroy the token
         $this->assertTrue($sessionManager->checkToken($token));
@@ -79,8 +70,7 @@ class SessionManagerTest extends TestCase
     public function testGenerateAndCheckToken()
     {
         $session = [];
-        $conf = new FakeConfigManager();
-        $sessionManager = new SessionManager($session, $conf);
+        $sessionManager = new SessionManager($session, self::$conf);
 
         $token = $sessionManager->generateToken();
 
@@ -102,8 +92,7 @@ class SessionManagerTest extends TestCase
     public function testCheckInvalidToken()
     {
         $session = [];
-        $conf = new FakeConfigManager();
-        $sessionManager = new SessionManager($session, $conf);
+        $sessionManager = new SessionManager($session, self::$conf);
 
         $this->assertFalse($sessionManager->checkToken('4dccc3a45ad9d03e5542b90c37d8db6d10f2b38b'));
     }
diff --git a/tests/utils/FakeConfigManager.php b/tests/utils/FakeConfigManager.php
new file mode 100644 (file)
index 0000000..f29760c
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * Fake ConfigManager
+ */
+class FakeConfigManager
+{
+    public static function get($key)
+    {
+        return $key;
+    }
+}
diff --git a/tpl/default/img/apple-touch-icon.png b/tpl/default/img/apple-touch-icon.png
new file mode 100644 (file)
index 0000000..f29210c
Binary files /dev/null and b/tpl/default/img/apple-touch-icon.png differ
index 80c083331d10a31dced6a4188cfa3f858fbf5397..b2bfec30918281104cacf6c50cae5441fcc26903 100644 (file)
@@ -5,6 +5,7 @@
 <link rel="alternate" type="application/atom+xml" href="{$feedurl}?do=atom{$searchcrits}#" title="ATOM Feed" />
 <link rel="alternate" type="application/rss+xml" href="{$feedurl}?do=rss{$searchcrits}#" title="RSS Feed" />
 <link href="img/favicon.png" rel="shortcut icon" type="image/png" />
+<link href="img/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180" />
 <link type="text/css" rel="stylesheet" href="css/pure.min.css?v={$version_hash}" />
 <link type="text/css" rel="stylesheet" href="css/grids-responsive.min.css?v={$version_hash}">
 <link type="text/css" rel="stylesheet" href="css/pure-extras.css?v={$version_hash}">
@@ -17,4 +18,4 @@
 {loop="$plugins_includes.css_files"}
   <link type="text/css" rel="stylesheet" href="{$value}?v={$version_hash}#"/>
 {/loop}
-<link rel="search" type="application/opensearchdescription+xml" href="?do=opensearch#" title="Shaarli search - {$shaarlititle}"/>
\ No newline at end of file
+<link rel="search" type="application/opensearchdescription+xml" href="?do=opensearch#" title="Shaarli search - {$shaarlititle}"/>