[add] support of Wallabag V2 + option in config manager

This commit is contained in:
Knah Tsaeb 2016-08-25 14:11:43 +02:00
parent 72944a7234
commit 86894a7261
9 changed files with 198 additions and 137 deletions

View file

@ -45,7 +45,7 @@ http://sebsauvage.net/wiki/doku.php?id=php:shaarli
myShaarli Features : myShaarli Features :
* Markdown syntax * Markdown support (web+RSS+Atom)
* Define external thumbnailer * Define external thumbnailer
* Add favicon * Add favicon
* Better configuration page * Better configuration page
@ -54,7 +54,7 @@ myShaarli Features :
* New default theme * New default theme
* Add link to archive.org (qwertygc https://github.com/nodiscc/Shaarli/commit/b113dc8e6bba052883297ab575dd36fd3073805e) * Add link to archive.org (qwertygc https://github.com/nodiscc/Shaarli/commit/b113dc8e6bba052883297ab575dd36fd3073805e)
* myShaali can use Firefox social API (Marsup https://github.com/shaarli/Shaarli/commit/d33c5d4c3b9c70441391a08e8bcb2a8c639a4635) * myShaali can use Firefox social API (Marsup https://github.com/shaarli/Shaarli/commit/d33c5d4c3b9c70441391a08e8bcb2a8c639a4635)
* myShaali can post original article to wallabag (nodiscc https://github.com/nodiscc/Shaarli/tree/new-plugin-system/tpl/plugins/wallabag) * myShaali can post original article to Wallabag (v1/v2)(nodiscc https://github.com/nodiscc/Shaarli/tree/new-plugin-system/tpl/plugins/wallabag)
* Few small fix * Few small fix
* You can upgrade original Shaarli to myShaarli without lost your data * You can upgrade original Shaarli to myShaarli without lost your data
* You can define url origin of update * You can define url origin of update

View file

@ -40,6 +40,7 @@
// the last param must be a url // the last param must be a url
$GLOBALS['config']['ENABLE_MARKDOWN'] = TRUE; $GLOBALS['config']['ENABLE_MARKDOWN'] = TRUE;
$GLOBALS['config']['WALLABAG_URL'] = ''; $GLOBALS['config']['WALLABAG_URL'] = '';
$GLOBALS['config']['WALLABAG_VERSION'] = ''; // 1 for V1 or 2 for v2
$GLOBALS['config']['contactLink'] = ''; // Define link for contact Example : http://example.com/contact.php or mailo:contact@example.com $GLOBALS['config']['contactLink'] = ''; // Define link for contact Example : http://example.com/contact.php or mailo:contact@example.com
$GLOBALS['config']['THEME'] = 'myShaarli'; $GLOBALS['config']['THEME'] = 'myShaarli';
$GLOBALS['config']['DATE_FORMAT'] = '%A %d %B %Y %T'; // see http://php.net/manual/en/function.strftime.php for more example $GLOBALS['config']['DATE_FORMAT'] = '%A %d %B %Y %T'; // see http://php.net/manual/en/function.strftime.php for more example
@ -1506,6 +1507,9 @@ function renderPage()
$GLOBALS['config']['contactLink'] = $_POST['contactLink']; $GLOBALS['config']['contactLink'] = $_POST['contactLink'];
$_SESSION['LINKS_PER_PAGE'] = (int)$_POST['linkPerPage']; $_SESSION['LINKS_PER_PAGE'] = (int)$_POST['linkPerPage'];
$GLOBALS['config']['DATE_FORMAT'] = strip_tags($_POST['dateFormat']); $GLOBALS['config']['DATE_FORMAT'] = strip_tags($_POST['dateFormat']);
$GLOBALS['config']['WALLABAG_URL'] = $_POST['wallabagUrl'];
$GLOBALS['config']['WALLABAG_VERSION'] = (int)$_POST['wallabagVersion'];
writeConfig(); writeConfig();
echo '<script>alert("Configuration was saved.");document.location=\'?do=configure\';</script>'; echo '<script>alert("Configuration was saved.");document.location=\'?do=configure\';</script>';
exit; exit;
@ -2465,6 +2469,8 @@ function writeConfig()
$config .= '$GLOBALS[\'config\'][\'externalThumbshot\'] = '.var_export($GLOBALS['config']['externalThumbshot'], true).';'."\n"; $config .= '$GLOBALS[\'config\'][\'externalThumbshot\'] = '.var_export($GLOBALS['config']['externalThumbshot'], true).';'."\n";
$config .= '$GLOBALS[\'config\'][\'contactLink\'] = '.var_export($GLOBALS['config']['contactLink'], true).';'."\n"; $config .= '$GLOBALS[\'config\'][\'contactLink\'] = '.var_export($GLOBALS['config']['contactLink'], true).';'."\n";
$config .= '$GLOBALS[\'config\'][\'DATE_FORMAT\'] = '.var_export($GLOBALS['config']['DATE_FORMAT'], true).';'."\n"; $config .= '$GLOBALS[\'config\'][\'DATE_FORMAT\'] = '.var_export($GLOBALS['config']['DATE_FORMAT'], true).';'."\n";
$config .= '$GLOBALS[\'config\'][\'WALLABAG_URL\'] = '.var_export($GLOBALS['config']['WALLABAG_URL'], true).';'."\n";
$config .= '$GLOBALS[\'config\'][\'WALLABAG_VERSION\'] = '.var_export($GLOBALS['config']['WALLABAG_VERSION'], true).';'."\n";
if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0) if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0)
{ {
echo '<script>alert("Shaarli could not create the config file. Please make sure Shaarli has the right to write in the folder is it installed in.");document.location=\'?\';</script>'; echo '<script>alert("Shaarli could not create the config file. Please make sure Shaarli has the right to write in the folder is it installed in.");document.location=\'?\';</script>';

View file

@ -1,13 +1,14 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
{include="includes"} {include="includes"}
<link type="text/css" rel="stylesheet" href="myShaarli.css?version={$version|urlencode}" /> <link type="text/css" rel="stylesheet" href="myShaarli.css?version={$version|urlencode}" />
</head> </head>
<body> <body>
<div id="pageheader"> <div id="pageheader">
{include="page.header"} {include="page.header"} {$timezone_js}
{$timezone_js}
</div> </div>
<div> <div>
<form method="post" action="" name="configform" id="configform"> <form method="post" action="" name="configform" id="configform">
@ -26,7 +27,7 @@
</p> </p>
<p> <p>
<label for="contactLink">Contact link in footer: </label> <label for="contactLink">Contact link in footer: </label>
<input type="text" name="contactLink" id="contactLink" value="{$GLOBALS['config']['contactLink']}"/> <input type="text" name="contactLink" id="contactLink" value="{$GLOBALS['config']['contactLink']}" />
<span>Example : http://example.com/contact.php or mailo:contact@example.com</span> <span>Example : http://example.com/contact.php or mailo:contact@example.com</span>
</p> </p>
<p> <p>
@ -35,8 +36,7 @@
</p> </p>
<p> <p>
<label for="redirector">Redirector : </label> <label for="redirector">Redirector : </label>
<input type="text" name="redirector" id="redirector" value="{$redirector}"> <input type="text" name="redirector" id="redirector" value="{$redirector}"> (e.g. <i>http://anonym.to/?</i> will mask the HTTP_REFERER)
(e.g. <i>http://anonym.to/?</i> will mask the HTTP_REFERER)
</p> </p>
<p> <p>
<label for="enableCache">Enable local cache : </label> <label for="enableCache">Enable local cache : </label>
@ -46,7 +46,7 @@
</li> </li>
<li> <li>
<input type="radio" name="tabs" id="tab2"> <input type="radio" name="tabs" id="tab2">
<label class="tabsLabel" for="tab2" >&#9658; Security</label> <label class="tabsLabel" for="tab2">&#9658; Security</label>
<div id="tab-content2" class="tab-content"> <div id="tab-content2" class="tab-content">
<p> <p>
<label for="disablesessionprotection">Security :</label> <label for="disablesessionprotection">Security :</label>
@ -55,12 +55,11 @@
</p> </p>
<p> <p>
<label for="banAfter">Ban after : </label> <label for="banAfter">Ban after : </label>
<input type="text" name="banAfter" id="banAfter" value="{$GLOBALS['config']['BAN_AFTER']}"/> <input type="text" name="banAfter" id="banAfter" value="{$GLOBALS['config']['BAN_AFTER']}" />
</p> </p>
<p> <p>
<label for="banDuration">Ban time : </label> <label for="banDuration">Ban time : </label>
<input type="text" name="banDuration" id="banDuration" value="{$GLOBALS['config']['BAN_DURATION']}"/> <input type="text" name="banDuration" id="banDuration" value="{$GLOBALS['config']['BAN_DURATION']}" /> in second
in second
</p> </p>
<p> <p>
<label for="updateCheck">Update :</label> <label for="updateCheck">Update :</label>
@ -83,7 +82,7 @@
</p> </p>
<p> <p>
<label for="linkPerPage">Link per page : </label> <label for="linkPerPage">Link per page : </label>
<input type="text" name="linkPerPage" id="linkPerPage" value="{$GLOBALS['config']['LINKS_PER_PAGE']}"/> <input type="text" name="linkPerPage" id="linkPerPage" value="{$GLOBALS['config']['LINKS_PER_PAGE']}" />
</p> </p>
<p> <p>
<label for="hideTimestamps">Hide timestamps : </label> <label for="hideTimestamps">Hide timestamps : </label>
@ -91,7 +90,8 @@
</p> </p>
<p> <p>
<label for="dateFormat">Date Format : </label> <label for="dateFormat">Date Format : </label>
<input type="text" name="dateFormat" id="dateFormat" value="{$GLOBALS['config']['DATE_FORMAT']}"/><label>See <a href="http://php.net/manual/en/function.strftime.php">PHP documentation</a></label> <input type="text" name="dateFormat" id="dateFormat" value="{$GLOBALS['config']['DATE_FORMAT']}" />
<label>See <a href="http://php.net/manual/en/function.strftime.php">PHP documentation</a></label>
</p> </p>
</div> </div>
</li> </li>
@ -120,6 +120,17 @@
<label for="enableFavicon">Enable favicon : </label> <label for="enableFavicon">Enable favicon : </label>
<input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/> <input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/>
</p> </p>
<p>
<label for="wallabagUrl">Wallabag URL : </label>
<input type="text" name="wallabagUrl" id="wallabagUrl" value="{$GLOBALS['config']['WALLABAG_URL']}">
</p>
<p>
<label for="wallabagVersion">Wallabag version : </label>
<select name="wallabagVersion" id="wallabagVersion">
<option {if="$GLOBALS['config']['WALLABAG_VERSION']===1"}selected{/if} value="1">v1</option>
<option {if="$GLOBALS['config']['WALLABAG_VERSION']===2"}selected{/if} value="2">v2</option>
</select>
</p>
</div> </div>
</li> </li>
</ul> </ul>
@ -131,4 +142,5 @@
</div> </div>
{include="page.footer"} {include="page.footer"}
</body> </body>
</html> </html>

View file

@ -80,9 +80,12 @@ <h3 class="linktitle">{function="returnFavicon($value.url)"}<a href="{$redirecto
<span class="linkdate linkBottom" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span> <span class="linkdate linkBottom" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span>
{/if} {/if}
<span class="linkarchive linkBottom"><a href="https://web.archive.org/web/{$value.url|htmlspecialchars}">Archive.org</a> - </span> <span class="linkarchive linkBottom"><a href="https://web.archive.org/web/{$value.url|htmlspecialchars}">Archive.org</a> - </span>
{if="$GLOBALS['config']['WALLABAG_URL'] && isLoggedIn()"} {if="$GLOBALS['config']['WALLABAG_URL'] && isLoggedIn() && $GLOBALS['config']['WALLABAG_VERSION']===1"}
<span class="linkWallabag linkBottom"><a href="{$GLOBALS['config']['WALLABAG_URL']}/?plainurl={$value.url|htmlspecialchars}">Save to Wallabag</a> - </span> <span class="linkWallabag linkBottom"><a href="{$GLOBALS['config']['WALLABAG_URL']}/?plainurl={$value.url|htmlspecialchars}">Save to Wallabag</a> - </span>
{/if} {/if}
{if="$GLOBALS['config']['WALLABAG_URL'] && isLoggedIn() && $GLOBALS['config']['WALLABAG_VERSION']===2"}
<span class="linkWallabag linkBottom"><a href="{$GLOBALS['config']['WALLABAG_URL']}/bookmarklet?url={$value.url|htmlspecialchars}">Save to Wallabag</a> - </span>
{/if}
<span><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}" <span><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}"
onclick="showQrCode(this); return false;" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"><img src="images/qrcode.png#" title="QR-Code" alt="qrcode logo"></a></span> - <span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span> onclick="showQrCode(this); return false;" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"><img src="images/qrcode.png#" title="QR-Code" alt="qrcode logo"></a></span> - <span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span>
<br> <br>

View file

@ -113,6 +113,17 @@
<label for="enableFavicon">Enable favicon : </label> <label for="enableFavicon">Enable favicon : </label>
<input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/> <input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/>
</p> </p>
<p>
<label for="wallabagUrl">Wallabag URL : </label>
<input type="text" name="wallabagUrl" id="wallabagUrl" value="{$GLOBALS['config']['WALLABAG_URL']}">
</p>
<p>
<label for="wallabagVersion">Wallabag version : </label>
<select name="wallabagVersion" id="wallabagVersion">
<option {if="$GLOBALS['config']['WALLABAG_VERSION']===1"}selected{/if} value="1">v1</option>
<option {if="$GLOBALS['config']['WALLABAG_VERSION']===2"}selected{/if} value="2">v2</option>
</select>
</p>
</div> </div>
</li> </li>
</ul> </ul>

View file

@ -80,9 +80,12 @@ <h3 class="linktitle">{function="returnFavicon($value.url)"}<a href="{$redirecto
<span class="linkdate linkBottom" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span> <span class="linkdate linkBottom" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span>
{/if} {/if}
<span class="linkarchive linkBottom"><a href="https://web.archive.org/web/{$value.url|htmlspecialchars}">Archive.org</a> - </span> <span class="linkarchive linkBottom"><a href="https://web.archive.org/web/{$value.url|htmlspecialchars}">Archive.org</a> - </span>
{if="$GLOBALS['config']['WALLABAG_URL'] && isLoggedIn()"} {if="$GLOBALS['config']['WALLABAG_URL'] && isLoggedIn() && $GLOBALS['config']['WALLABAG_VERSION']===1"}
<span class="linkWallabag linkBottom"><a href="{$GLOBALS['config']['WALLABAG_URL']}/?plainurl={$value.url|htmlspecialchars}">Save to Wallabag</a> - </span> <span class="linkWallabag linkBottom"><a href="{$GLOBALS['config']['WALLABAG_URL']}/?plainurl={$value.url|htmlspecialchars}">Save to Wallabag</a> - </span>
{/if} {/if}
{if="$GLOBALS['config']['WALLABAG_URL'] && isLoggedIn() && $GLOBALS['config']['WALLABAG_VERSION']===2"}
<span class="linkWallabag linkBottom"><a href="{$GLOBALS['config']['WALLABAG_URL']}/bookmarklet?url={$value.url|htmlspecialchars}">Save to Wallabag</a> - </span>
{/if}
<span><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}" <span><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}"
onclick="showQrCode(this); return false;" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"><img src="images/qrcode.png#" title="QR-Code" alt="qrcode logo"></a></span> - <span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span> onclick="showQrCode(this); return false;" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"><img src="images/qrcode.png#" title="QR-Code" alt="qrcode logo"></a></span> - <span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span>
<br> <br>

View file

@ -113,6 +113,17 @@
<label for="enableFavicon">Enable favicon : </label> <label for="enableFavicon">Enable favicon : </label>
<input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/> <input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/>
</p> </p>
<p>
<label for="wallabagUrl">Wallabag URL : </label>
<input type="text" name="wallabagUrl" id="wallabagUrl" value="{$GLOBALS['config']['WALLABAG_URL']}">
</p>
<p>
<label for="wallabagVersion">Wallabag version : </label>
<select name="wallabagVersion" id="wallabagVersion">
<option {if="$GLOBALS['config']['WALLABAG_VERSION']===1"}selected{/if} value="1">v1</option>
<option {if="$GLOBALS['config']['WALLABAG_VERSION']===2"}selected{/if} value="2">v2</option>
</select>
</p>
</div> </div>
</li> </li>
</ul> </ul>

View file

@ -80,9 +80,12 @@ <h3 class="linktitle">{function="returnFavicon($value.url)"}<a href="{$redirecto
<span class="linkdate linkBottom" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span> <span class="linkdate linkBottom" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span>
{/if} {/if}
<span class="linkarchive linkBottom"><a href="https://web.archive.org/web/{$value.url|htmlspecialchars}">Archive.org</a> - </span> <span class="linkarchive linkBottom"><a href="https://web.archive.org/web/{$value.url|htmlspecialchars}">Archive.org</a> - </span>
{if="$GLOBALS['config']['WALLABAG_URL'] && isLoggedIn()"} {if="$GLOBALS['config']['WALLABAG_URL'] && isLoggedIn() && $GLOBALS['config']['WALLABAG_VERSION']===1"}
<span class="linkWallabag linkBottom"><a href="{$GLOBALS['config']['WALLABAG_URL']}/?plainurl={$value.url|htmlspecialchars}">Save to Wallabag</a> - </span> <span class="linkWallabag linkBottom"><a href="{$GLOBALS['config']['WALLABAG_URL']}/?plainurl={$value.url|htmlspecialchars}">Save to Wallabag</a> - </span>
{/if} {/if}
{if="$GLOBALS['config']['WALLABAG_URL'] && isLoggedIn() && $GLOBALS['config']['WALLABAG_VERSION']===2"}
<span class="linkWallabag linkBottom"><a href="{$GLOBALS['config']['WALLABAG_URL']}/bookmarklet?url={$value.url|htmlspecialchars}">Save to Wallabag</a> - </span>
{/if}
<span><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}" <span><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}"
onclick="showQrCode(this); return false;" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"><img src="images/qrcode.png#" title="QR-Code" alt="qrcode logo"></a></span> - <span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span> onclick="showQrCode(this); return false;" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"><img src="images/qrcode.png#" title="QR-Code" alt="qrcode logo"></a></span> - <span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span>
<br> <br>

View file

@ -232,7 +232,7 @@ cursor:pointer;
.linktitle { font-size:14pt; font-weight:bold; } .linktitle { font-size:14pt; font-weight:bold; }
.linktitle a { text-decoration: none; color:#80AD48; } .linktitle a { text-decoration: none; color:#80AD48; }
.linktitle a:hover { color:#F57900; } .linktitle a:hover { color:#F57900; }
.linkdate, .linkarchive { font-size:8pt; color:#888; } .linkdate, .linkarchive, .linkWallabag { font-size:8pt; color:#888; }
.linkdate a, .linkarchive a { color:#E28E3F;text-decoration: none;} .linkdate a, .linkarchive a { color:#E28E3F;text-decoration: none;}
.linkarchive a {background-image:url('../../images/logo_Archive.org.jpg');padding:2px 0 3px 20px;background-repeat:no-repeat;} .linkarchive a {background-image:url('../../images/logo_Archive.org.jpg');padding:2px 0 3px 20px;background-repeat:no-repeat;}
.linkdate a {background-image:url('../../images/calendar.png');padding:2px 0 3px 20px;background-repeat:no-repeat;} .linkdate a {background-image:url('../../images/calendar.png');padding:2px 0 3px 20px;background-repeat:no-repeat;}
@ -469,3 +469,15 @@ div.dailyEntryDescription { font-size:10pt; }
/* Highlight search results */ /* Highlight search results */
.highlight { background-color: #FFFF33; } .highlight { background-color: #FFFF33; }
.linkWallabag a {
background-image: url(../../images/logo_wallabag.png);
background-repeat: no-repeat;
}
.linkBottom a {
color: #E28E3F;
line-height: 1.6em;
padding: 2px 0 3px 20px;
text-decoration: none;
}