From ba04c608494d6acdce2128dc27c3674178c84167 Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Fri, 9 Feb 2018 15:56:22 +0100 Subject: [PATCH] Fix markdown editor with myShaarli plugin --- application/FeedBuilder.php | 3 +- index.php | 22 +++++++++++++-- plugins/myShaarli/myShaarli.php | 5 ++-- plugins/origin/origin.php | 36 ++++++++++++++++++++++-- plugins/origin/render.html | 2 +- tpl/myShaarli/css/myShaarli.css | 50 +++++++++++++++++++++++---------- tpl/myShaarli/daily.html | 11 +++++--- tpl/myShaarli/feed.atom.html | 2 +- tpl/myShaarli/linklist.html | 11 ++++---- tpl/myShaarli/page.header.html | 2 +- tpl/myShaarli/picwall.html | 7 ++--- 11 files changed, 110 insertions(+), 41 deletions(-) diff --git a/application/FeedBuilder.php b/application/FeedBuilder.php index ebae18b..c68f5ae 100644 --- a/application/FeedBuilder.php +++ b/application/FeedBuilder.php @@ -153,8 +153,7 @@ class FeedBuilder $permalink = ''. t('Permalink') .''; } $link['description'] = format_description($link['description'], '', false, $pageaddr); - $link['description'] .= PHP_EOL .'
— '. $permalink; - + $link['permalink'] = PHP_EOL .'
— '. $permalink; $pubDate = $link['created']; $link['pub_iso_date'] = $this->getIsoDate($pubDate); diff --git a/index.php b/index.php index 9d5f25e..2ce375d 100644 --- a/index.php +++ b/index.php @@ -607,7 +607,21 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager) $conf->get('redirector.url'), $conf->get('redirector.encode_url') ); - $linksToDisplay[$key]['thumbnail'] = thumbnail($conf, $link['url']); + + + $thumb=lazyThumbnail($conf, $link['url'],$link['url']); + if ($thumb!='') // Only output links which have a thumbnail. + { + $linksToDisplay[$key]['thumbnail']=$thumb; // Thumbnail HTML code. + } + $thumUrl = $conf->get('plugins.ExternalThumbshot_URL'); + if(empty($linksToDisplay[$key]['thumbnail'])){ + $linksToDisplay[$key]['thumbnail'] = 'Thumbnail'; + } + + + + //$linksToDisplay[$key]['thumbnail'] = thumbnail($conf, $link['url']); $linksToDisplay[$key]['timestamp'] = $link['created']->getTimestamp(); } @@ -780,8 +794,12 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager) if ($thumb!='') // Only output links which have a thumbnail. { $link['thumbnail']=$thumb; // Thumbnail HTML code. - $linksToDisplay[]=$link; // Add to array. } + $thumUrl = $conf->get('plugins.ExternalThumbshot_URL'); + if(empty($link['thumbnail'])){ + $link['thumbnail'] = 'Thumbnail'; + } + $linksToDisplay[]=$link; // Add to array. } $data = array( diff --git a/plugins/myShaarli/myShaarli.php b/plugins/myShaarli/myShaarli.php index 831576a..23c8d83 100644 --- a/plugins/myShaarli/myShaarli.php +++ b/plugins/myShaarli/myShaarli.php @@ -44,9 +44,10 @@ function hook_myShaarli_render_linklist($data,$conf) foreach ($data['links'] as &$value) { $thumb = computeThumbnail($conf, $value['url']); if(empty($thumb)){ - $value['thumbnail'] = 'Thumbnail'; + //$value['thumbnail'] = 'Thumbnail'; + $value['thumbnail'] = 'Thumbnail'; } else { - $value['thumbnail'] = ''; + $value['thumbnail'] = 'Thumbnail'; } } return $data; diff --git a/plugins/origin/origin.php b/plugins/origin/origin.php index e19bf63..bedea54 100644 --- a/plugins/origin/origin.php +++ b/plugins/origin/origin.php @@ -77,8 +77,38 @@ } // Try to get just domain for @via - function getJustDomain($url) - { + function getJustDomain($url) { $parts = parse_url($url); - return trim($parts['host']); + if(!empty($parts['host'])){ + return trim($parts['host']); + } else { + return false; + } + } + + + /** + * Execute render_feed hook. + * Called with ATOM and RSS feed. + * + * Special data keys: + * - _PAGE_: current page + * - _LOGGEDIN_: true/false + * + * @param array $data data passed to plugin + * + * @return array altered $data. + */ + function hook_origin_render_feed($data) + { + $origin_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/origin/render.html'); + + foreach ($data['links'] as &$value) { + if(!empty($value['via'])){ + $host = getJustDomain($value['via']); + $origin = sprintf($origin_html, $value['via'], $host); + $value['description'] = $value['description'].$origin; + } + } + return $data; } diff --git a/plugins/origin/render.html b/plugins/origin/render.html index bce996e..4a57414 100644 --- a/plugins/origin/render.html +++ b/plugins/origin/render.html @@ -1,3 +1,3 @@
- Origin -> %s + Origin %s
diff --git a/tpl/myShaarli/css/myShaarli.css b/tpl/myShaarli/css/myShaarli.css index fa012cb..1ad0927 100644 --- a/tpl/myShaarli/css/myShaarli.css +++ b/tpl/myShaarli/css/myShaarli.css @@ -23,18 +23,27 @@ body { .label { display: inline-block; - padding: .25em .4em; + padding: .3em; font-size: 75%; font-weight: 700; line-height: 1; text-align: center; white-space: nowrap; vertical-align: baseline; - border-radius: .25rem; +} + +.linklist-item-infos .label a{ + border-radius: .3rem; + background-color: #ddd; + border: 1px solid #fff; + padding: .3em .6em; } .linklist-item-infos .label a:hover { color: #1b926c; + background-color: #fff; + border: 1px solid #333; + transition: color .2s linear, border .2s linear; } pre { @@ -117,10 +126,7 @@ body, .pure-g [class*="pure-u"] { * MENU **/ .shaarli-menu { - position: fixed; - top: 0; width: 100%; - --height: 60px; background: linear-gradient(#333333,#111111); background-color: #333333; box-shadow: 0 1px 2px rgba(0,0,0,0.5); @@ -413,7 +419,6 @@ body, .pure-g [class*="pure-u"] { #content { position: relative; z-index: 2; - margin-top: 45px; } /** @@ -671,6 +676,10 @@ body, .pure-g [class*="pure-u"] { color: #14553f; } +.origin { + margin: .3em .3em .3em 0; +} + .linklist-item-thumbnail { position: relative; padding: .6em; @@ -721,6 +730,7 @@ body, .pure-g [class*="pure-u"] { .linklist-item-infos .linklist-item-tags { font-size: 0.8em; + margin-bottom: .6em; } .linklist-item-infos .label-tag { @@ -1199,25 +1209,32 @@ form[name="linkform"].page-form { /** * Picture wall CSS */ +.myShaarli_picwall { + background-color: #000; +} + +.myShaarli_picwall .pure-u-lg-4-5 { + margin:auto; + background-color: #000; + box-shadow: none; +} + #picwall_container { margin: 0 10px 10px 10px; color: #252525; - background-color: #f5f5f5; + background-color: #000; clear: both; + text-align: center; } .picwall_pictureframe { margin: 2px; - background-color: #f5f5f5; + background-color: #000; z-index: 5; position: relative; - display: table-cell; - vertical-align: middle; - width: 90px; - height: 90px; + display: inline-flex; overflow: hidden; text-align: center; - float: left; } .b-lazy { @@ -1235,6 +1252,7 @@ form[name="linkform"].page-form { max-width: 100%; height: auto; color: transparent; + border-radius:.3em; } /* Adapt the width of the image */ .picwall_pictureframe a { @@ -1252,13 +1270,14 @@ form[name="linkform"].page-form { position: absolute; top: 0; left: 0; - width: 90px; - height: 90px; + width: 100%; + height: 100%; font-weight: bold; font-size: 9pt; color: #f5f5f5; text-align: left; background-color: rgba(0, 0, 0, 0.8); + overflow-wrap: break-word; } /** @@ -1289,6 +1308,7 @@ form[name="linkform"].page-form { .daily-entry { padding: 0 10px; + clear: both; } .daily-entry .daily-entry-title:after { diff --git a/tpl/myShaarli/daily.html b/tpl/myShaarli/daily.html index 29d845d..73e1c79 100644 --- a/tpl/myShaarli/daily.html +++ b/tpl/myShaarli/daily.html @@ -69,9 +69,9 @@ {$link.title} - {$thumb=thumbnail($value.url)} - {if="$thumb!=false"} -
{$thumb}
+ + {if="$link.thumbnail!=false"} +
{$link.thumbnail}
{/if}
{$link.formatedDescription}
{if="$link.tags"} @@ -108,6 +108,9 @@ {include="page.footer"} + + - diff --git a/tpl/myShaarli/feed.atom.html b/tpl/myShaarli/feed.atom.html index 2918750..55ab4b1 100644 --- a/tpl/myShaarli/feed.atom.html +++ b/tpl/myShaarli/feed.atom.html @@ -28,7 +28,7 @@ {$value.pub_iso_date} {$value.up_iso_date} {/if} - + {loop="$value.taglist"} {/loop} diff --git a/tpl/myShaarli/linklist.html b/tpl/myShaarli/linklist.html index 3ccd15d..5507019 100644 --- a/tpl/myShaarli/linklist.html +++ b/tpl/myShaarli/linklist.html @@ -120,12 +120,9 @@ {loop="links"}