[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 :
* Markdown syntax
* Markdown support (web+RSS+Atom)
* Define external thumbnailer
* Add favicon
* Better configuration page
@ -54,7 +54,7 @@ myShaarli Features :
* New default theme
* 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 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
* You can upgrade original Shaarli to myShaarli without lost your data
* You can define url origin of update

View File

@ -40,6 +40,7 @@ $GLOBALS['config']['externalThumbshot'] = ''; // Url for external thumbnailer
// the last param must be a url
$GLOBALS['config']['ENABLE_MARKDOWN'] = TRUE;
$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']['THEME'] = 'myShaarli';
$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'];
$_SESSION['LINKS_PER_PAGE'] = (int)$_POST['linkPerPage'];
$GLOBALS['config']['DATE_FORMAT'] = strip_tags($_POST['dateFormat']);
$GLOBALS['config']['WALLABAG_URL'] = $_POST['wallabagUrl'];
$GLOBALS['config']['WALLABAG_VERSION'] = (int)$_POST['wallabagVersion'];
writeConfig();
echo '<script>alert("Configuration was saved.");document.location=\'?do=configure\';</script>';
exit;
@ -2465,6 +2469,8 @@ function writeConfig()
$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\'][\'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)
{
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,134 +1,146 @@
<!DOCTYPE html>
<html>
<head>
{include="includes"}
<link type="text/css" rel="stylesheet" href="myShaarli.css?version={$version|urlencode}" />
</head>
<body>
<div id="pageheader">
{include="page.header"}
{$timezone_js}
</div>
<div>
<form method="post" action="" name="configform" id="configform">
<ul class="tabs">
<li>
<input type="radio" checked name="tabs" id="tab1">
<label class="tabsLabel" for="tab1">&#9658; General</label>
<div id="tab-content1" class="tab-content">
<p>
<label for="title">Page title :</label>
<input type="text" name="title" id="title" value="{$title}" autofocus>
</p>
<p>
<label for="titleLink">Title link :</label>
<input type="text" name="titleLink" id="titleLink" value="{$titleLink}">
</p>
<p>
<label for="contactLink">Contact link in footer: </label>
<input type="text" name="contactLink" id="contactLink" value="{$GLOBALS['config']['contactLink']}"/>
<span>Example : http://example.com/contact.php or mailo:contact@example.com</span>
</p>
<p>
<label>Timezone : </label>
{$timezone_form}
</p>
<p>
<label for="redirector">Redirector : </label>
<input type="text" name="redirector" id="redirector" value="{$redirector}">
(e.g. <i>http://anonym.to/?</i> will mask the HTTP_REFERER)
</p>
<p>
<label for="enableCache">Enable local cache : </label>
<input type="checkbox" name="enableCache" id="enableCache" {if="!empty($GLOBALS['config']['ENABLE_LOCALCACHE'])"}checked{/if}/>
</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab2">
<label class="tabsLabel" for="tab2" >&#9658; Security</label>
<div id="tab-content2" class="tab-content">
<p>
<label for="disablesessionprotection">Security :</label>
<input type="checkbox" name="disablesessionprotection" id="disablesessionprotection" {if="!empty($GLOBALS['disablesessionprotection'])"}checked{/if}>
<label for="disablesessionprotection">&nbsp;Disable session cookie hijacking protection (Check this if you get disconnected often or if your IP address changes often.)</label>
</p>
<p>
<label for="banAfter">Ban after : </label>
<input type="text" name="banAfter" id="banAfter" value="{$GLOBALS['config']['BAN_AFTER']}"/>
</p>
<p>
<label for="banDuration">Ban time : </label>
<input type="text" name="banDuration" id="banDuration" value="{$GLOBALS['config']['BAN_DURATION']}"/>
in second
</p>
<p>
<label for="updateCheck">Update :</label>
<input type="checkbox" name="updateCheck" id="updateCheck" {if="!empty($GLOBALS['config']['ENABLE_UPDATECHECK'])"}checked{/if}/>
<label for="updateCheck">&nbsp;Notify me when a new release is ready</label>
</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab3">
<label class="tabsLabel" for="tab3">&#9658; Display</label>
<div id="tab-content3" class="tab-content">
<p>
<label for="theme">Theme : </label>
<select name="theme" id="theme">
{loop="themes"}
<option {if="$GLOBALS['config']['THEME']==$value"}selected{/if} value="{$value}">{$value|ucfirst}</option>
{/loop}
</select>
</p>
<p>
<label for="linkPerPage">Link per page : </label>
<input type="text" name="linkPerPage" id="linkPerPage" value="{$GLOBALS['config']['LINKS_PER_PAGE']}"/>
</p>
<p>
<label for="hideTimestamps">Hide timestamps : </label>
<input type="checkbox" name="hideTimestamps" id="hideTimestamps" {if="!empty($GLOBALS['config']['HIDE_TIMESTAMPS'])"}checked{/if}/>
</p>
<p>
<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>
</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab4">
<label class="tabsLabel" for="tab4">&#9658; Extra</label>
<div id="tab-content4" class="tab-content">
<p>
<label for="privateLinkByDefault">New link:</label>
<input type="checkbox" name="privateLinkByDefault" id="privateLinkByDefault" {if="!empty($GLOBALS['privateLinkByDefault'])"}checked{/if}/>
<label for="privateLinkByDefault">&nbsp;All new link are private by default</label>
</p>
<p>
<label for="enableMarkdown">Enable Markdown : </label>
<input type="checkbox" name="enableMarkdown" id="enableMarkdown" {if="!empty($GLOBALS['config']['ENABLE_MARKDOWN'])"}checked{/if}/>
</p>
<p>
<label for="enableThumbnails">Enable thumbnail : </label>
<input type="checkbox" name="enableThumbnails" id="enableThumbnails" {if="!empty($GLOBALS['config']['ENABLE_THUMBNAILS'])"}checked{/if}/>
</p>
<p>
<label for="externalThumbshot">External thumbnailer : </label>
<input type="text" name="externalThumbshot" id="externalThumbshot" value="{$GLOBALS['config']['externalThumbshot']}">
</p>
<p>
<label for="enableFavicon">Enable favicon : </label>
<input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/>
</p>
</div>
</li>
</ul>
<p>
<input type="hidden" name="token" value="{$token}">
<input type="submit" name="Save" value="Save config" class="bigbutton">
</p>
</form>
</div>
{include="page.footer"}
</body>
<head>
{include="includes"}
<link type="text/css" rel="stylesheet" href="myShaarli.css?version={$version|urlencode}" />
</head>
<body>
<div id="pageheader">
{include="page.header"} {$timezone_js}
</div>
<div>
<form method="post" action="" name="configform" id="configform">
<ul class="tabs">
<li>
<input type="radio" checked name="tabs" id="tab1">
<label class="tabsLabel" for="tab1">&#9658; General</label>
<div id="tab-content1" class="tab-content">
<p>
<label for="title">Page title :</label>
<input type="text" name="title" id="title" value="{$title}" autofocus>
</p>
<p>
<label for="titleLink">Title link :</label>
<input type="text" name="titleLink" id="titleLink" value="{$titleLink}">
</p>
<p>
<label for="contactLink">Contact link in footer: </label>
<input type="text" name="contactLink" id="contactLink" value="{$GLOBALS['config']['contactLink']}" />
<span>Example : http://example.com/contact.php or mailo:contact@example.com</span>
</p>
<p>
<label>Timezone : </label>
{$timezone_form}
</p>
<p>
<label for="redirector">Redirector : </label>
<input type="text" name="redirector" id="redirector" value="{$redirector}"> (e.g. <i>http://anonym.to/?</i> will mask the HTTP_REFERER)
</p>
<p>
<label for="enableCache">Enable local cache : </label>
<input type="checkbox" name="enableCache" id="enableCache" {if="!empty($GLOBALS['config']['ENABLE_LOCALCACHE'])"}checked{/if}/>
</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab2">
<label class="tabsLabel" for="tab2">&#9658; Security</label>
<div id="tab-content2" class="tab-content">
<p>
<label for="disablesessionprotection">Security :</label>
<input type="checkbox" name="disablesessionprotection" id="disablesessionprotection" {if="!empty($GLOBALS['disablesessionprotection'])"}checked{/if}>
<label for="disablesessionprotection">&nbsp;Disable session cookie hijacking protection (Check this if you get disconnected often or if your IP address changes often.)</label>
</p>
<p>
<label for="banAfter">Ban after : </label>
<input type="text" name="banAfter" id="banAfter" value="{$GLOBALS['config']['BAN_AFTER']}" />
</p>
<p>
<label for="banDuration">Ban time : </label>
<input type="text" name="banDuration" id="banDuration" value="{$GLOBALS['config']['BAN_DURATION']}" /> in second
</p>
<p>
<label for="updateCheck">Update :</label>
<input type="checkbox" name="updateCheck" id="updateCheck" {if="!empty($GLOBALS['config']['ENABLE_UPDATECHECK'])"}checked{/if}/>
<label for="updateCheck">&nbsp;Notify me when a new release is ready</label>
</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab3">
<label class="tabsLabel" for="tab3">&#9658; Display</label>
<div id="tab-content3" class="tab-content">
<p>
<label for="theme">Theme : </label>
<select name="theme" id="theme">
{loop="themes"}
<option {if="$GLOBALS['config']['THEME']==$value"}selected{/if} value="{$value}">{$value|ucfirst}</option>
{/loop}
</select>
</p>
<p>
<label for="linkPerPage">Link per page : </label>
<input type="text" name="linkPerPage" id="linkPerPage" value="{$GLOBALS['config']['LINKS_PER_PAGE']}" />
</p>
<p>
<label for="hideTimestamps">Hide timestamps : </label>
<input type="checkbox" name="hideTimestamps" id="hideTimestamps" {if="!empty($GLOBALS['config']['HIDE_TIMESTAMPS'])"}checked{/if}/>
</p>
<p>
<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>
</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab4">
<label class="tabsLabel" for="tab4">&#9658; Extra</label>
<div id="tab-content4" class="tab-content">
<p>
<label for="privateLinkByDefault">New link:</label>
<input type="checkbox" name="privateLinkByDefault" id="privateLinkByDefault" {if="!empty($GLOBALS['privateLinkByDefault'])"}checked{/if}/>
<label for="privateLinkByDefault">&nbsp;All new link are private by default</label>
</p>
<p>
<label for="enableMarkdown">Enable Markdown : </label>
<input type="checkbox" name="enableMarkdown" id="enableMarkdown" {if="!empty($GLOBALS['config']['ENABLE_MARKDOWN'])"}checked{/if}/>
</p>
<p>
<label for="enableThumbnails">Enable thumbnail : </label>
<input type="checkbox" name="enableThumbnails" id="enableThumbnails" {if="!empty($GLOBALS['config']['ENABLE_THUMBNAILS'])"}checked{/if}/>
</p>
<p>
<label for="externalThumbshot">External thumbnailer : </label>
<input type="text" name="externalThumbshot" id="externalThumbshot" value="{$GLOBALS['config']['externalThumbshot']}">
</p>
<p>
<label for="enableFavicon">Enable favicon : </label>
<input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/>
</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>
</li>
</ul>
<p>
<input type="hidden" name="token" value="{$token}">
<input type="submit" name="Save" value="Save config" class="bigbutton">
</p>
</form>
</div>
{include="page.footer"}
</body>
</html>

View File

@ -80,9 +80,12 @@
<span class="linkdate linkBottom" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span>
{/if}
<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>
{/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}"
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>

View File

@ -113,6 +113,17 @@
<label for="enableFavicon">Enable favicon : </label>
<input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/>
</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>
</li>
</ul>

View File

@ -80,9 +80,12 @@
<span class="linkdate linkBottom" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span>
{/if}
<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>
{/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}"
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>

View File

@ -113,6 +113,17 @@
<label for="enableFavicon">Enable favicon : </label>
<input type="checkbox" name="enableFavicon" id="enableFavicon" {if="!empty($GLOBALS['config']['ENABLE_FAVICON'])"}checked{/if}/>
</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>
</li>
</ul>

View File

@ -80,9 +80,12 @@
<span class="linkdate linkBottom" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span>
{/if}
<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>
{/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}"
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>

View File

@ -232,7 +232,7 @@ cursor:pointer;
.linktitle { font-size:14pt; font-weight:bold; }
.linktitle a { text-decoration: none; color:#80AD48; }
.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;}
.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;}
@ -469,3 +469,15 @@ div.dailyEntryDescription { font-size:10pt; }
/* Highlight search results */
.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;
}