From 799c92d786da3226840fc3cf502cb9a229a1ee16 Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Wed, 1 Jul 2015 12:20:41 +0200 Subject: [PATCH] [add] new configuration page [fix] disable thumbnails keep left space in myShaarli theme --- inc/styles/myShaarli.css | 85 ++++++++++++++++++--- index.php | 49 ++++++++++-- tpl/configure.html | 158 ++++++++++++++++++++++++++++++--------- tpl/includes.html | 2 +- tpl/linklist.html | 6 +- 5 files changed, 249 insertions(+), 51 deletions(-) diff --git a/inc/styles/myShaarli.css b/inc/styles/myShaarli.css index 46bb58c..45c4f56 100644 --- a/inc/styles/myShaarli.css +++ b/inc/styles/myShaarli.css @@ -311,7 +311,7 @@ a, .linkdescription a { #toolsdiv a span { color: #ffffff; - font-weight :normal; + font-weight: normal; } .linksperpage, .tagfilter, .searchform, .addform { @@ -695,12 +695,6 @@ a, .linkdescription a { padding: 10px 5px; } -#configform td { - color: #ccc; - font-size: 10pt; - padding: 10px 5px; -} - .thumbnail { float: left; margin: 0; @@ -714,9 +708,8 @@ a, .linkdescription a { border-radius: .3em; } -.linkcontainer { +.linkcontainerThumb { margin-left: 130px; - position: static; } .favicon { @@ -934,6 +927,15 @@ a:hover, .linkdescription a:hover, .linktitle a:hover, .linkWallabag a:hover, .l padding: 10px 5px; } +#configform { + margin: 0 auto; + width: 70%; +} + +#configform label { + font-weight: bold; +} + .picwall_pictureframe span.info, .lazyimage { display: none; } @@ -944,6 +946,71 @@ a:hover, .linkdescription a:hover, .linktitle a:hover, .linkWallabag a:hover, .l width: 33%; } +/* + * Creating Content Tabs with Pure CSS + * http://www.onextrapixel.com/2013/07/31/creating-content-tabs-with-pure-css/ + */ + +.tabs input[type=radio] { + position: absolute; + top: -9999px; + left: -9999px; +} + +.tabs { + float: none; + list-style: none; + position: relative; + padding: 0; +} + +.tabs li { + display: block; +} + +.tabsLabel { + background: #333333 linear-gradient(#333333,#000000) repeat scroll 0 0; + border-radius: 5px; + box-shadow: 0 1px 2px rgba(0,0,0,0.5); + color: #a2dd42; + display: block; + font-size: 1.1em; + cursor: pointer; + position: relative; + top: 3px; + transition: all .2s ease-in-out; + padding: .3em .6em; +} + +.tabsLabel:hover { + color: #ffffc9; +} + +[id^=tab]:checked + .tabsLabel { + color: #ffffc9; +} + +[id^=tab]:checked ~ +[id^=tab-content] { + display: block; +} + +.tab-content { + z-index: 2; + display: none; + text-align: left; + width: 100%; + left: 0; + box-sizing: border-box; + -webkit-animation-duration: .5s; + -o-animation-duration: .5s; + -moz-animation-duration: .5s; + animation-duration: .5s; + border: 1px solid #ccc; + border-radius: .3em; + padding: 15px; +} + @media print { html { background: #fff !important; diff --git a/index.php b/index.php index 8d3bbfc..88ea14e 100644 --- a/index.php +++ b/index.php @@ -40,10 +40,13 @@ $GLOBALS['config']['externalThumbshot'] = ''; // Url for external thumbnailer $GLOBALS['config']['ENABLE_MARKDOWN'] = TRUE; $GLOBALS['config']['WALLABAG_URL'] = ''; $GLOBALS['config']['contactLink'] = ''; // Define link for contact Example : http://example.com/contact.php or mailo:contact@example.com +$GLOBALS['config']['THEME'] = 'myShaarli'; // ----------------------------------------------------------------------------------------------- // You should not touch below (or at your own risks !) // Optionnal config file. -if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php'); +if (is_file($GLOBALS['config']['DATADIR'].'/options.php')){ + require($GLOBALS['config']['DATADIR'].'/options.php'); +} define('myShaarli_version','1.0.0 alpha'); define('PHPPREFIX','tpl = new RainTPL; + $this->tpl->assign('theme',$GLOBALS['config']['THEME']); $this->tpl->assign('newversion',checkUpdate()); $this->tpl->assign('feedurl',htmlspecialchars(indexUrl())); $searchcrits=''; // Search criteria @@ -1460,14 +1467,26 @@ function renderPage() if (isTZvalid($_POST['continent'],$_POST['city'])) $tz = $_POST['continent'].'/'.$_POST['city']; $GLOBALS['timezone'] = $tz; - $GLOBALS['title']=$_POST['title']; - $GLOBALS['titleLink']=$_POST['titleLink']; + $GLOBALS['title']=htmlentities(strip_tags($_POST['title'])); + $GLOBALS['titleLink']=htmlentities(strip_tags($_POST['titleLink'])); $GLOBALS['redirector']=$_POST['redirector']; $GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']); $GLOBALS['disablejquery']=!empty($_POST['disablejquery']); $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']); $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']); $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']); + $GLOBALS['config']['ENABLE_MARKDOWN'] = !empty($_POST['enableMarkdown']); + $GLOBALS['config']['HIDE_TIMESTAMPS'] = !empty($_POST['hideTimestamps']); + $GLOBALS['config']['BAN_AFTER'] = (int)$_POST['banAfter']; + $GLOBALS['config']['BAN_DURATION'] = (int)$_POST['banDuration']; + $GLOBALS['config']['THEME'] = htmlentities(strip_tags($_POST['theme'])); + $GLOBALS['config']['LINKS_PER_PAGE'] = (int)$_POST['linkPerPage']; + $GLOBALS['config']['ENABLE_THUMBNAILS'] = !empty($_POST['enableThumbnails']); + $GLOBALS['config']['ENABLE_FAVICON'] = !empty($_POST['enableFavicon']); + $GLOBALS['config']['ENABLE_LOCALCACHE'] = !empty($_POST['enableCache']); + $GLOBALS['config']['externalThumbshot'] = $_POST['externalThumbshot']; + $GLOBALS['config']['contactLink'] = $_POST['contactLink']; + $_SESSION['LINKS_PER_PAGE'] = (int)$_POST['linkPerPage']; writeConfig(); echo ''; exit; @@ -1475,6 +1494,7 @@ function renderPage() else // Show the configuration form. { $PAGE = new pageBuilder; + $PAGE->assign('themes',getAllTheme()); $PAGE->assign('linkcount',count($LINKSDB)); $PAGE->assign('token',getToken()); $PAGE->assign('title',htmlspecialchars( empty($GLOBALS['title']) ? '' : $GLOBALS['title'] , ENT_QUOTES)); @@ -2378,6 +2398,14 @@ function processWS() } } +function getAllTheme(){ + $allTheme = glob('inc/styles/*.css'); + foreach ($allTheme as $value) { + $themes[] = basename($value, '.css'); + } + return $themes; +} + // Re-write configuration file according to globals. // Requires some $GLOBALS to be set (login,hash,salt,title). // If the config file cannot be saved, an error message is dislayed and the user is redirected to "Tools" menu. @@ -2394,6 +2422,17 @@ function writeConfig() $config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; '; $config .= '$GLOBALS[\'config\'][\'ENABLE_RSS_PERMALINKS\']='.var_export($GLOBALS['config']['ENABLE_RSS_PERMALINKS'], true).'; '; $config .= '$GLOBALS[\'config\'][\'ENABLE_UPDATECHECK\']='.var_export($GLOBALS['config']['ENABLE_UPDATECHECK'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'ENABLE_MARKDOWN\']='.var_export($GLOBALS['config']['ENABLE_MARKDOWN'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'BAN_AFTER\']='.var_export($GLOBALS['config']['BAN_AFTER'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'BAN_DURATION\']='.var_export($GLOBALS['config']['BAN_DURATION'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'THEME\']='.var_export($GLOBALS['config']['THEME'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'LINKS_PER_PAGE\']='.var_export($GLOBALS['config']['LINKS_PER_PAGE'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'HIDE_TIMESTAMPS\']='.var_export($GLOBALS['config']['HIDE_TIMESTAMPS'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'ENABLE_THUMBNAILS\']='.var_export($GLOBALS['config']['ENABLE_THUMBNAILS'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'ENABLE_FAVICON\']='.var_export($GLOBALS['config']['ENABLE_FAVICON'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'ENABLE_LOCALCACHE\']='.var_export($GLOBALS['config']['ENABLE_LOCALCACHE'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'externalThumbshot\']='.var_export($GLOBALS['config']['externalThumbshot'], true).'; '; + $config .= '$GLOBALS[\'config\'][\'contactLink\']='.var_export($GLOBALS['config']['contactLink'], true).'; '; $config .= ' ?>'; if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0) { diff --git a/tpl/configure.html b/tpl/configure.html index 75c6395..7bc27ce 100644 --- a/tpl/configure.html +++ b/tpl/configure.html @@ -1,38 +1,128 @@ -{include="includes"} - - -{include="page.footer"} - + + +
  • + + +
    +

    + + +

    +

    + + +

    +

    + + +

    +
    +
  • +
  • + + +
    +

    + + + +

    +

    + + +

    +

    + + +

    +

    + + +

    +

    + + +

    +
    +
  • + +

    + + +

    + + + {include="page.footer"} + diff --git a/tpl/includes.html b/tpl/includes.html index 18375af..860a900 100644 --- a/tpl/includes.html +++ b/tpl/includes.html @@ -5,5 +5,5 @@ - + {if condition="is_file('inc/user.css')"}{/if} diff --git a/tpl/linklist.html b/tpl/linklist.html index 9e35fee..c38d734 100644 --- a/tpl/linklist.html +++ b/tpl/linklist.html @@ -42,8 +42,10 @@ {loop="links"} -
    {$value.url|thumbnail}
    -