aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-01-23 20:05:41 +0100
committerArthurHoaro <arthur@hoa.ro>2020-01-26 11:34:14 +0100
commit9e4cc28e2957e1f7df713d52a03e350d728dc58e (patch)
treec659f36c3f483de0cfae30cada7441c9d3e48226
parentdd51f653d07dba226fa1088f56ca258ef9b4ae87 (diff)
downloadShaarli-9e4cc28e2957e1f7df713d52a03e350d728dc58e.tar.gz
Shaarli-9e4cc28e2957e1f7df713d52a03e350d728dc58e.tar.zst
Shaarli-9e4cc28e2957e1f7df713d52a03e350d728dc58e.zip
Fix all existing links and redirection to ?do=login
-rw-r--r--application/Utils.php2
-rw-r--r--doc/md/Translations.md32
-rw-r--r--index.php18
-rw-r--r--tests/UtilsTest.php4
-rw-r--r--tpl/default/page.header.html4
-rw-r--r--tpl/vintage/page.header.html2
6 files changed, 31 insertions, 31 deletions
diff --git a/application/Utils.php b/application/Utils.php
index 56f5b9a2..4b7fc546 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -159,7 +159,7 @@ function checkDateFormat($format, $string)
159 */ 159 */
160function generateLocation($referer, $host, $loopTerms = array()) 160function generateLocation($referer, $host, $loopTerms = array())
161{ 161{
162 $finalReferer = '?'; 162 $finalReferer = './?';
163 163
164 // No referer if it contains any value in $loopCriteria. 164 // No referer if it contains any value in $loopCriteria.
165 foreach (array_filter($loopTerms) as $value) { 165 foreach (array_filter($loopTerms) as $value) {
diff --git a/doc/md/Translations.md b/doc/md/Translations.md
index c7d33855..58b92da3 100644
--- a/doc/md/Translations.md
+++ b/doc/md/Translations.md
@@ -7,8 +7,8 @@ Note that only the `default` theme supports translations.
7 7
8### Contributing 8### Contributing
9 9
10We encourage the community to contribute to Shaarli's translation either by improving existing 10We encourage the community to contribute to Shaarli's translation either by improving existing
11translations or submitting a new language. 11translations or submitting a new language.
12 12
13Contributing to the translation does not require development skill. 13Contributing to the translation does not require development skill.
14 14
@@ -21,8 +21,8 @@ First, install [Poedit](https://poedit.net/) tool.
21 21
22Poedit will extract strings to translate from the PHP source code. 22Poedit will extract strings to translate from the PHP source code.
23 23
24**Important**: due to the usage of a template engine, it's important to generate PHP cache files to extract 24**Important**: due to the usage of a template engine, it's important to generate PHP cache files to extract
25every translatable string. 25every translatable string.
26 26
27You can either use [this script](https://gist.github.com/ArthurHoaro/5d0323f758ab2401ef444a53f54e9a07) (recommended) 27You can either use [this script](https://gist.github.com/ArthurHoaro/5d0323f758ab2401ef444a53f54e9a07) (recommended)
28or visit every template page in your browser to generate cache files, while logged in. 28or visit every template page in your browser to generate cache files, while logged in.
@@ -41,7 +41,7 @@ http://<replace_domain>/?do=daily
41http://<replace_domain>/?post 41http://<replace_domain>/?post
42http://<replace_domain>/?do=export 42http://<replace_domain>/?do=export
43http://<replace_domain>/?do=import 43http://<replace_domain>/?do=import
44http://<replace_domain>/?do=login 44http://<replace_domain>/login
45http://<replace_domain>/?do=picwall 45http://<replace_domain>/?do=picwall
46http://<replace_domain>/?do=pluginadmin 46http://<replace_domain>/?do=pluginadmin
47http://<replace_domain>/?do=tagcloud 47http://<replace_domain>/?do=tagcloud
@@ -50,8 +50,8 @@ http://<replace_domain>/?do=taglist
50 50
51#### Improve existing translation 51#### Improve existing translation
52 52
53In Poedit, click on "Edit a Translation", and from Shaarli's directory open 53In Poedit, click on "Edit a Translation", and from Shaarli's directory open
54`inc/languages/<lang>/LC_MESSAGES/shaarli.po`. 54`inc/languages/<lang>/LC_MESSAGES/shaarli.po`.
55 55
56The existing list of translatable strings should have been loaded, then click on the "Update" button. 56The existing list of translatable strings should have been loaded, then click on the "Update" button.
57 57
@@ -63,20 +63,20 @@ Save when you're done, then you can submit a pull request containing the updated
63 63
64#### Add a new language 64#### Add a new language
65 65
66Open Poedit and select "Create New Translation", then from Shaarli's directory open 66Open Poedit and select "Create New Translation", then from Shaarli's directory open
67`inc/languages/<lang>/LC_MESSAGES/shaarli.po`. 67`inc/languages/<lang>/LC_MESSAGES/shaarli.po`.
68 68
69Then select the language you want to create. 69Then select the language you want to create.
70 70
71Click on `File > Save as...`, and save your file in `<shaarli directory>/inc/language/<new language>/LC_MESSAGES/shaarli.po`. 71Click on `File > Save as...`, and save your file in `<shaarli directory>/inc/language/<new language>/LC_MESSAGES/shaarli.po`.
72`<new language>` here should be the language code respecting the [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-2) 72`<new language>` here should be the language code respecting the [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-2)
73format in lowercase (e.g. `de` for German). 73format in lowercase (e.g. `de` for German).
74 74
75Then click on the "Update" button, and you can start to translate every available string. 75Then click on the "Update" button, and you can start to translate every available string.
76 76
77Save when you're done, then you can submit a pull request containing the new `shaarli.po`. 77Save when you're done, then you can submit a pull request containing the new `shaarli.po`.
78 78
79### Theme translations 79### Theme translations
80 80
81Theme translation extensions are loaded automatically if they're present. 81Theme translation extensions are loaded automatically if they're present.
82 82
@@ -85,7 +85,7 @@ As a theme developer, all you have to do is to add the `.po` and `.mo` compiled
85 tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.po 85 tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.po
86 tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.mo 86 tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.mo
87 87
88Where `<lang>` is the ISO 3166-1 alpha-2 language code. 88Where `<lang>` is the ISO 3166-1 alpha-2 language code.
89Read the following section "Extend Shaarli's translation" to learn how to generate those files. 89Read the following section "Extend Shaarli's translation" to learn how to generate those files.
90 90
91### Extend Shaarli's translation 91### Extend Shaarli's translation
@@ -106,7 +106,7 @@ First, create your translation files tree directory:
106Your `.po` files must be named like your domain. E.g. if your translation domain is `my_theme`, then your file will be 106Your `.po` files must be named like your domain. E.g. if your translation domain is `my_theme`, then your file will be
107`my_theme.po`. 107`my_theme.po`.
108 108
109Users have to register your extension in their configuration with the parameter 109Users have to register your extension in their configuration with the parameter
110`translation.extensions.<domain>: <translation files path>`. 110`translation.extensions.<domain>: <translation files path>`.
111 111
112Example: 112Example:
@@ -151,11 +151,11 @@ When you're done, open Poedit and load translation strings from sources:
151 1. `File > New` 151 1. `File > New`
152 2. Choose your language 152 2. Choose your language
153 3. Save your `PO` file in `<your_module>/languages/<language code>/LC_MESSAGES/my_theme.po`. 153 3. Save your `PO` file in `<your_module>/languages/<language code>/LC_MESSAGES/my_theme.po`.
154 4. Go to `Catalog > Properties...` 154 4. Go to `Catalog > Properties...`
155 5. Fill the `Translation Properties` tab 155 5. Fill the `Translation Properties` tab
156 6. Add your source path in the `Sources Paths` tab 156 6. Add your source path in the `Sources Paths` tab
157 7. In the `Sources Keywords` tab uncheck "Also use default keywords" and add the following lines: 157 7. In the `Sources Keywords` tab uncheck "Also use default keywords" and add the following lines:
158 158
159``` 159```
160my_theme_t 160my_theme_t
161my_theme_t:1,2 161my_theme_t:1,2
diff --git a/index.php b/index.php
index 7da8c22f..474d9af5 100644
--- a/index.php
+++ b/index.php
@@ -252,7 +252,7 @@ if (isset($_POST['login'])) {
252 252
253 // Optional redirect after login: 253 // Optional redirect after login:
254 if (isset($_GET['post'])) { 254 if (isset($_GET['post'])) {
255 $uri = '?post='. urlencode($_GET['post']); 255 $uri = './?post='. urlencode($_GET['post']);
256 foreach (array('description', 'source', 'title', 'tags') as $param) { 256 foreach (array('description', 'source', 'title', 'tags') as $param) {
257 if (!empty($_GET[$param])) { 257 if (!empty($_GET[$param])) {
258 $uri .= '&'.$param.'='.urlencode($_GET[$param]); 258 $uri .= '&'.$param.'='.urlencode($_GET[$param]);
@@ -263,22 +263,22 @@ if (isset($_POST['login'])) {
263 } 263 }
264 264
265 if (isset($_GET['edit_link'])) { 265 if (isset($_GET['edit_link'])) {
266 header('Location: ?edit_link='. escape($_GET['edit_link'])); 266 header('Location: ./?edit_link='. escape($_GET['edit_link']));
267 exit; 267 exit;
268 } 268 }
269 269
270 if (isset($_POST['returnurl'])) { 270 if (isset($_POST['returnurl'])) {
271 // Prevent loops over login screen. 271 // Prevent loops over login screen.
272 if (strpos($_POST['returnurl'], 'do=login') === false) { 272 if (strpos($_POST['returnurl'], '/login') === false) {
273 header('Location: '. generateLocation($_POST['returnurl'], $_SERVER['HTTP_HOST'])); 273 header('Location: '. generateLocation($_POST['returnurl'], $_SERVER['HTTP_HOST']));
274 exit; 274 exit;
275 } 275 }
276 } 276 }
277 header('Location: ?'); 277 header('Location: ./?');
278 exit; 278 exit;
279 } else { 279 } else {
280 $loginManager->handleFailedLogin($_SERVER); 280 $loginManager->handleFailedLogin($_SERVER);
281 $redir = '&username='. urlencode($_POST['login']); 281 $redir = '?username='. urlencode($_POST['login']);
282 if (isset($_GET['post'])) { 282 if (isset($_GET['post'])) {
283 $redir .= '&post=' . urlencode($_GET['post']); 283 $redir .= '&post=' . urlencode($_GET['post']);
284 foreach (array('description', 'source', 'title', 'tags') as $param) { 284 foreach (array('description', 'source', 'title', 'tags') as $param) {
@@ -288,7 +288,7 @@ if (isset($_POST['login'])) {
288 } 288 }
289 } 289 }
290 // Redirect to login screen. 290 // Redirect to login screen.
291 echo '<script>alert("'. t("Wrong login/password.") .'");document.location=\'?do=login'.$redir.'\';</script>'; 291 echo '<script>alert("'. t("Wrong login/password.") .'");document.location=\'./login'.$redir.'\';</script>';
292 exit; 292 exit;
293 } 293 }
294} 294}
@@ -923,7 +923,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
923 // Show login screen, then redirect to ?post=... 923 // Show login screen, then redirect to ?post=...
924 if (isset($_GET['post'])) { 924 if (isset($_GET['post'])) {
925 header( // Redirect to login page, then back to post link. 925 header( // Redirect to login page, then back to post link.
926 'Location: ?do=login&post='.urlencode($_GET['post']). 926 'Location: /login?post='.urlencode($_GET['post']).
927 (!empty($_GET['title'])?'&title='.urlencode($_GET['title']):''). 927 (!empty($_GET['title'])?'&title='.urlencode($_GET['title']):'').
928 (!empty($_GET['description'])?'&description='.urlencode($_GET['description']):''). 928 (!empty($_GET['description'])?'&description='.urlencode($_GET['description']):'').
929 (!empty($_GET['tags'])?'&tags='.urlencode($_GET['tags']):''). 929 (!empty($_GET['tags'])?'&tags='.urlencode($_GET['tags']):'').
@@ -934,7 +934,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
934 934
935 showLinkList($PAGE, $bookmarkService, $conf, $pluginManager, $loginManager); 935 showLinkList($PAGE, $bookmarkService, $conf, $pluginManager, $loginManager);
936 if (isset($_GET['edit_link'])) { 936 if (isset($_GET['edit_link'])) {
937 header('Location: ?do=login&edit_link='. escape($_GET['edit_link'])); 937 header('Location: /login?edit_link='. escape($_GET['edit_link']));
938 exit; 938 exit;
939 } 939 }
940 940
@@ -1890,7 +1890,7 @@ function install($conf, $sessionManager, $loginManager)
1890 echo '<script>alert(' 1890 echo '<script>alert('
1891 .'"Shaarli is now configured. ' 1891 .'"Shaarli is now configured. '
1892 .'Please enter your login/password and start shaaring your bookmarks!"' 1892 .'Please enter your login/password and start shaaring your bookmarks!"'
1893 .');document.location=\'?do=login\';</script>'; 1893 .');document.location=\'./login\';</script>';
1894 exit; 1894 exit;
1895 } 1895 }
1896 1896
diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php
index 8225d95a..26d2a6b8 100644
--- a/tests/UtilsTest.php
+++ b/tests/UtilsTest.php
@@ -203,7 +203,7 @@ class UtilsTest extends PHPUnit\Framework\TestCase
203 public function testGenerateLocationLoop() 203 public function testGenerateLocationLoop()
204 { 204 {
205 $ref = 'http://localhost/?test'; 205 $ref = 'http://localhost/?test';
206 $this->assertEquals('?', generateLocation($ref, 'localhost', array('test'))); 206 $this->assertEquals('./?', generateLocation($ref, 'localhost', array('test')));
207 } 207 }
208 208
209 /** 209 /**
@@ -212,7 +212,7 @@ class UtilsTest extends PHPUnit\Framework\TestCase
212 public function testGenerateLocationOut() 212 public function testGenerateLocationOut()
213 { 213 {
214 $ref = 'http://somewebsite.com/?test'; 214 $ref = 'http://somewebsite.com/?test';
215 $this->assertEquals('?', generateLocation($ref, 'localhost')); 215 $this->assertEquals('./?', generateLocation($ref, 'localhost'));
216 } 216 }
217 217
218 218
diff --git a/tpl/default/page.header.html b/tpl/default/page.header.html
index 4f063dc3..82f8ebf1 100644
--- a/tpl/default/page.header.html
+++ b/tpl/default/page.header.html
@@ -60,7 +60,7 @@
60 </li> 60 </li>
61 {else} 61 {else}
62 <li class="pure-menu-item pure-u-lg-0 shaarli-menu-mobile" id="shaarli-menu-mobile-login"> 62 <li class="pure-menu-item pure-u-lg-0 shaarli-menu-mobile" id="shaarli-menu-mobile-login">
63 <a href="?do=login" class="pure-menu-link">{'Login'|t}</a> 63 <a href="/login" class="pure-menu-link">{'Login'|t}</a>
64 </li> 64 </li>
65 {/if} 65 {/if}
66 </ul> 66 </ul>
@@ -80,7 +80,7 @@
80 </li> 80 </li>
81 {if="!$is_logged_in"} 81 {if="!$is_logged_in"}
82 <li class="pure-menu-item" id="shaarli-menu-desktop-login"> 82 <li class="pure-menu-item" id="shaarli-menu-desktop-login">
83 <a href="?do=login" class="pure-menu-link" 83 <a href="/login" class="pure-menu-link"
84 data-open-id="header-login-form" 84 data-open-id="header-login-form"
85 id="login-button" aria-label="{'Login'|t}" title="{'Login'|t}"> 85 id="login-button" aria-label="{'Login'|t}" title="{'Login'|t}">
86 <i class="fa fa-user" aria-hidden="true"></i> 86 <i class="fa fa-user" aria-hidden="true"></i>
diff --git a/tpl/vintage/page.header.html b/tpl/vintage/page.header.html
index 40c53e5b..a37926d2 100644
--- a/tpl/vintage/page.header.html
+++ b/tpl/vintage/page.header.html
@@ -25,7 +25,7 @@
25 <li><a href="?do=tools">Tools</a></li> 25 <li><a href="?do=tools">Tools</a></li>
26 <li><a href="?do=addlink">Add link</a></li> 26 <li><a href="?do=addlink">Add link</a></li>
27 {else} 27 {else}
28 <li><a href="?do=login">Login</a></li> 28 <li><a href="/login">Login</a></li>
29 {/if} 29 {/if}
30 <li><a href="{$feedurl}?do=rss{$searchcrits}" class="nomobile">RSS Feed</a></li> 30 <li><a href="{$feedurl}?do=rss{$searchcrits}" class="nomobile">RSS Feed</a></li>
31 {if="$showatom"} 31 {if="$showatom"}