]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Fix all existing links and redirection to ?do=login
authorArthurHoaro <arthur@hoa.ro>
Thu, 23 Jan 2020 19:05:41 +0000 (20:05 +0100)
committerArthurHoaro <arthur@hoa.ro>
Sun, 26 Jan 2020 10:34:14 +0000 (11:34 +0100)
application/Utils.php
doc/md/Translations.md
index.php
tests/UtilsTest.php
tpl/default/page.header.html
tpl/vintage/page.header.html

index 56f5b9a20d8b33b9fa3c06fd6f819931100d4545..4b7fc5464916495ec9f9189270edbd7d43d2b53c 100644 (file)
@@ -159,7 +159,7 @@ function checkDateFormat($format, $string)
  */
 function generateLocation($referer, $host, $loopTerms = array())
 {
  */
 function generateLocation($referer, $host, $loopTerms = array())
 {
-    $finalReferer = '?';
+    $finalReferer = './?';
 
     // No referer if it contains any value in $loopCriteria.
     foreach (array_filter($loopTerms) as $value) {
 
     // No referer if it contains any value in $loopCriteria.
     foreach (array_filter($loopTerms) as $value) {
index c7d3385532451c031661f202e33f2f6aa2fdf61f..58b92da387732ef330a54e3ba030c6b0a81ee68d 100644 (file)
@@ -7,8 +7,8 @@ Note that only the `default` theme supports translations.
 
 ### Contributing
 
 
 ### Contributing
 
-We encourage the community to contribute to Shaarli's translation either by improving existing 
-translations or submitting a new language. 
+We encourage the community to contribute to Shaarli's translation either by improving existing
+translations or submitting a new language.
 
 Contributing to the translation does not require development skill.
 
 
 Contributing to the translation does not require development skill.
 
@@ -21,8 +21,8 @@ First, install [Poedit](https://poedit.net/) tool.
 
 Poedit will extract strings to translate from the PHP source code.
 
 
 Poedit will extract strings to translate from the PHP source code.
 
-**Important**: due to the usage of a template engine, it's important to generate PHP cache files to extract 
-every translatable string. 
+**Important**: due to the usage of a template engine, it's important to generate PHP cache files to extract
+every translatable string.
 
 You can either use [this script](https://gist.github.com/ArthurHoaro/5d0323f758ab2401ef444a53f54e9a07)  (recommended)
 or visit every template page in your browser to generate cache files, while logged in.
 
 You can either use [this script](https://gist.github.com/ArthurHoaro/5d0323f758ab2401ef444a53f54e9a07)  (recommended)
 or visit every template page in your browser to generate cache files, while logged in.
@@ -41,7 +41,7 @@ http://<replace_domain>/?do=daily
 http://<replace_domain>/?post
 http://<replace_domain>/?do=export
 http://<replace_domain>/?do=import
 http://<replace_domain>/?post
 http://<replace_domain>/?do=export
 http://<replace_domain>/?do=import
-http://<replace_domain>/?do=login
+http://<replace_domain>/login
 http://<replace_domain>/?do=picwall
 http://<replace_domain>/?do=pluginadmin
 http://<replace_domain>/?do=tagcloud
 http://<replace_domain>/?do=picwall
 http://<replace_domain>/?do=pluginadmin
 http://<replace_domain>/?do=tagcloud
@@ -50,8 +50,8 @@ http://<replace_domain>/?do=taglist
 
 #### Improve existing translation
 
 
 #### Improve existing translation
 
-In Poedit, click on "Edit a Translation", and from Shaarli's directory open 
-`inc/languages/<lang>/LC_MESSAGES/shaarli.po`. 
+In Poedit, click on "Edit a Translation", and from Shaarli's directory open
+`inc/languages/<lang>/LC_MESSAGES/shaarli.po`.
 
 The existing list of translatable strings should have been loaded, then click on the "Update" button.
 
 
 The existing list of translatable strings should have been loaded, then click on the "Update" button.
 
@@ -63,20 +63,20 @@ Save when you're done, then you can submit a pull request containing the updated
 
 #### Add a new language
 
 
 #### Add a new language
 
-Open Poedit and select "Create New Translation", then from Shaarli's directory open 
+Open Poedit and select "Create New Translation", then from Shaarli's directory open
 `inc/languages/<lang>/LC_MESSAGES/shaarli.po`.
 
 `inc/languages/<lang>/LC_MESSAGES/shaarli.po`.
 
-Then select the language you want to create. 
+Then select the language you want to create.
 
 
-Click on `File > Save as...`, and save your file in `<shaarli directory>/inc/language/<new language>/LC_MESSAGES/shaarli.po`.  
-`<new language>` here should be the language code respecting the [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-2) 
+Click on `File > Save as...`, and save your file in `<shaarli directory>/inc/language/<new language>/LC_MESSAGES/shaarli.po`.
+`<new language>` here should be the language code respecting the [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-2)
 format in lowercase (e.g. `de` for German).
 
 Then click on the "Update" button, and you can start to translate every available string.
 
 Save when you're done, then you can submit a pull request containing the new `shaarli.po`.
 
 format in lowercase (e.g. `de` for German).
 
 Then click on the "Update" button, and you can start to translate every available string.
 
 Save when you're done, then you can submit a pull request containing the new `shaarli.po`.
 
-### Theme translations 
+### Theme translations
 
 Theme translation extensions are loaded automatically if they're present.
 
 
 Theme translation extensions are loaded automatically if they're present.
 
@@ -85,7 +85,7 @@ As a theme developer, all you have to do is to add the `.po` and `.mo` compiled
     tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.po
     tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.mo
 
     tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.po
     tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.mo
 
-Where `<lang>` is the ISO 3166-1 alpha-2 language code. 
+Where `<lang>` is the ISO 3166-1 alpha-2 language code.
 Read the following section "Extend Shaarli's translation" to learn how to generate those files.
 
 ### Extend Shaarli's translation
 Read the following section "Extend Shaarli's translation" to learn how to generate those files.
 
 ### Extend Shaarli's translation
@@ -106,7 +106,7 @@ First, create your translation files tree directory:
 Your `.po` files must be named like your domain. E.g. if your translation domain is `my_theme`, then your file will be
 `my_theme.po`.
 
 Your `.po` files must be named like your domain. E.g. if your translation domain is `my_theme`, then your file will be
 `my_theme.po`.
 
-Users have to register your extension in their configuration with the parameter 
+Users have to register your extension in their configuration with the parameter
 `translation.extensions.<domain>: <translation files path>`.
 
 Example:
 `translation.extensions.<domain>: <translation files path>`.
 
 Example:
@@ -151,11 +151,11 @@ When you're done, open Poedit and load translation strings from sources:
   1. `File > New`
   2. Choose your language
   3. Save your `PO` file in `<your_module>/languages/<language code>/LC_MESSAGES/my_theme.po`.
   1. `File > New`
   2. Choose your language
   3. Save your `PO` file in `<your_module>/languages/<language code>/LC_MESSAGES/my_theme.po`.
-  4. Go to `Catalog > Properties...` 
+  4. Go to `Catalog > Properties...`
   5. Fill the `Translation Properties` tab
   6. Add your source path in the `Sources Paths` tab
   7. In the `Sources Keywords` tab uncheck "Also use default keywords" and add the following lines:
   5. Fill the `Translation Properties` tab
   6. Add your source path in the `Sources Paths` tab
   7. In the `Sources Keywords` tab uncheck "Also use default keywords" and add the following lines:
-  
+
 ```
 my_theme_t
 my_theme_t:1,2
 ```
 my_theme_t
 my_theme_t:1,2
index 7da8c22f3562e40446cc7d93468c8a95926f71c8..474d9af5d630439224e051b37ab29cc38457c378 100644 (file)
--- a/index.php
+++ b/index.php
@@ -252,7 +252,7 @@ if (isset($_POST['login'])) {
 
         // Optional redirect after login:
         if (isset($_GET['post'])) {
 
         // Optional redirect after login:
         if (isset($_GET['post'])) {
-            $uri = '?post='. urlencode($_GET['post']);
+            $uri = './?post='. urlencode($_GET['post']);
             foreach (array('description', 'source', 'title', 'tags') as $param) {
                 if (!empty($_GET[$param])) {
                     $uri .= '&'.$param.'='.urlencode($_GET[$param]);
             foreach (array('description', 'source', 'title', 'tags') as $param) {
                 if (!empty($_GET[$param])) {
                     $uri .= '&'.$param.'='.urlencode($_GET[$param]);
@@ -263,22 +263,22 @@ if (isset($_POST['login'])) {
         }
 
         if (isset($_GET['edit_link'])) {
         }
 
         if (isset($_GET['edit_link'])) {
-            header('Location: ?edit_link='. escape($_GET['edit_link']));
+            header('Location: ./?edit_link='. escape($_GET['edit_link']));
             exit;
         }
 
         if (isset($_POST['returnurl'])) {
             // Prevent loops over login screen.
             exit;
         }
 
         if (isset($_POST['returnurl'])) {
             // Prevent loops over login screen.
-            if (strpos($_POST['returnurl'], 'do=login') === false) {
+            if (strpos($_POST['returnurl'], '/login') === false) {
                 header('Location: '. generateLocation($_POST['returnurl'], $_SERVER['HTTP_HOST']));
                 exit;
             }
         }
                 header('Location: '. generateLocation($_POST['returnurl'], $_SERVER['HTTP_HOST']));
                 exit;
             }
         }
-        header('Location: ?');
+        header('Location: ./?');
         exit;
     } else {
         $loginManager->handleFailedLogin($_SERVER);
         exit;
     } else {
         $loginManager->handleFailedLogin($_SERVER);
-        $redir = '&username='. urlencode($_POST['login']);
+        $redir = '?username='. urlencode($_POST['login']);
         if (isset($_GET['post'])) {
             $redir .= '&post=' . urlencode($_GET['post']);
             foreach (array('description', 'source', 'title', 'tags') as $param) {
         if (isset($_GET['post'])) {
             $redir .= '&post=' . urlencode($_GET['post']);
             foreach (array('description', 'source', 'title', 'tags') as $param) {
@@ -288,7 +288,7 @@ if (isset($_POST['login'])) {
             }
         }
         // Redirect to login screen.
             }
         }
         // Redirect to login screen.
-        echo '<script>alert("'. t("Wrong login/password.") .'");document.location=\'?do=login'.$redir.'\';</script>';
+        echo '<script>alert("'. t("Wrong login/password.") .'");document.location=\'./login'.$redir.'\';</script>';
         exit;
     }
 }
         exit;
     }
 }
@@ -923,7 +923,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
         // Show login screen, then redirect to ?post=...
         if (isset($_GET['post'])) {
             header( // Redirect to login page, then back to post link.
         // Show login screen, then redirect to ?post=...
         if (isset($_GET['post'])) {
             header( // Redirect to login page, then back to post link.
-                'Location: ?do=login&post='.urlencode($_GET['post']).
+                'Location: /login?post='.urlencode($_GET['post']).
                 (!empty($_GET['title'])?'&title='.urlencode($_GET['title']):'').
                 (!empty($_GET['description'])?'&description='.urlencode($_GET['description']):'').
                 (!empty($_GET['tags'])?'&tags='.urlencode($_GET['tags']):'').
                 (!empty($_GET['title'])?'&title='.urlencode($_GET['title']):'').
                 (!empty($_GET['description'])?'&description='.urlencode($_GET['description']):'').
                 (!empty($_GET['tags'])?'&tags='.urlencode($_GET['tags']):'').
@@ -934,7 +934,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
 
         showLinkList($PAGE, $bookmarkService, $conf, $pluginManager, $loginManager);
         if (isset($_GET['edit_link'])) {
 
         showLinkList($PAGE, $bookmarkService, $conf, $pluginManager, $loginManager);
         if (isset($_GET['edit_link'])) {
-            header('Location: ?do=login&edit_link='. escape($_GET['edit_link']));
+            header('Location: /login?edit_link='. escape($_GET['edit_link']));
             exit;
         }
 
             exit;
         }
 
@@ -1890,7 +1890,7 @@ function install($conf, $sessionManager, $loginManager)
         echo '<script>alert('
             .'"Shaarli is now configured. '
             .'Please enter your login/password and start shaaring your bookmarks!"'
         echo '<script>alert('
             .'"Shaarli is now configured. '
             .'Please enter your login/password and start shaaring your bookmarks!"'
-            .');document.location=\'?do=login\';</script>';
+            .');document.location=\'./login\';</script>';
         exit;
     }
 
         exit;
     }
 
index 8225d95ae067d3c5db9fb4a352860bb341c8b961..26d2a6b823170d913be90f3372f220863d8827ca 100644 (file)
@@ -203,7 +203,7 @@ class UtilsTest extends PHPUnit\Framework\TestCase
     public function testGenerateLocationLoop()
     {
         $ref = 'http://localhost/?test';
     public function testGenerateLocationLoop()
     {
         $ref = 'http://localhost/?test';
-        $this->assertEquals('?', generateLocation($ref, 'localhost', array('test')));
+        $this->assertEquals('./?', generateLocation($ref, 'localhost', array('test')));
     }
 
     /**
     }
 
     /**
@@ -212,7 +212,7 @@ class UtilsTest extends PHPUnit\Framework\TestCase
     public function testGenerateLocationOut()
     {
         $ref = 'http://somewebsite.com/?test';
     public function testGenerateLocationOut()
     {
         $ref = 'http://somewebsite.com/?test';
-        $this->assertEquals('?', generateLocation($ref, 'localhost'));
+        $this->assertEquals('./?', generateLocation($ref, 'localhost'));
     }
 
 
     }
 
 
index 4f063dc303f9c182347b2c17ad4a0a7d33d10bbe..82f8ebf1fa164f947221ae36bdcd994c8443adc8 100644 (file)
@@ -60,7 +60,7 @@
           </li>
         {else}
           <li class="pure-menu-item pure-u-lg-0 shaarli-menu-mobile" id="shaarli-menu-mobile-login">
           </li>
         {else}
           <li class="pure-menu-item pure-u-lg-0 shaarli-menu-mobile" id="shaarli-menu-mobile-login">
-            <a href="?do=login" class="pure-menu-link">{'Login'|t}</a>
+            <a href="/login" class="pure-menu-link">{'Login'|t}</a>
           </li>
         {/if}
       </ul>
           </li>
         {/if}
       </ul>
@@ -80,7 +80,7 @@
           </li>
           {if="!$is_logged_in"}
             <li class="pure-menu-item" id="shaarli-menu-desktop-login">
           </li>
           {if="!$is_logged_in"}
             <li class="pure-menu-item" id="shaarli-menu-desktop-login">
-              <a href="?do=login" class="pure-menu-link"
+              <a href="/login" class="pure-menu-link"
                  data-open-id="header-login-form"
                  id="login-button" aria-label="{'Login'|t}" title="{'Login'|t}">
                 <i class="fa fa-user" aria-hidden="true"></i>
                  data-open-id="header-login-form"
                  id="login-button" aria-label="{'Login'|t}" title="{'Login'|t}">
                 <i class="fa fa-user" aria-hidden="true"></i>
index 40c53e5bdf9bec9c55f8e3799a8152dff7f0bdbd..a37926d2a183521398b5060b52abf67390af60b4 100644 (file)
@@ -25,7 +25,7 @@
     <li><a href="?do=tools">Tools</a></li>
     <li><a href="?do=addlink">Add link</a></li>
     {else}
     <li><a href="?do=tools">Tools</a></li>
     <li><a href="?do=addlink">Add link</a></li>
     {else}
-    <li><a href="?do=login">Login</a></li>
+    <li><a href="/login">Login</a></li>
     {/if}
     <li><a href="{$feedurl}?do=rss{$searchcrits}" class="nomobile">RSS Feed</a></li>
     {if="$showatom"}
     {/if}
     <li><a href="{$feedurl}?do=rss{$searchcrits}" class="nomobile">RSS Feed</a></li>
     {if="$showatom"}