From 3c9678eb2ae25104238b60d296f9ef01b07dbbb2 Mon Sep 17 00:00:00 2001 From: Tomer S Date: Sun, 30 Jun 2019 17:20:13 +0300 Subject: [PATCH] Added option for `new_tab` parameter, as per tschlienger --- README.md | 6 +++++- config.sample.json | 9 ++++++--- index.php | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4efbb7c..743f971 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,11 @@ Copy the config.sample.json file and rename to config.json. Be sure to update th - 'hover_color' => The CSS color for menu items when hovered over - 'time_to_refresh_bg' => Time, in milliseconds, until it will fetch the next background image - 'idle_timer' => Set a number of milliseconds here if you'd like to automatically hide the menu after a certain time of inactivity. Leave this attribute out entirely if you don't want an idle timer. -- 'items' => The menu will be in a grid of 3 icons per row on desktop. Insert any link you'd like, or {{cur}} for the current URL of the page. Choose icons from [Font Awesome](http://fontawesome.io/icons/) +- 'items' => Array of objects for links to be displayed. The menu will be in a grid of 3 icons per row on desktop. Object shape: + - 'link' => Insert any link you'd like, or {{cur}} for the current URL of the page, i.e. `{{cur}}:32400/web/`. + - 'icon' => Icon to be displayed, choose icons from [Font Awesome](http://fontawesome.io/icons/). + - 'alt' => Value for `title` of anchor tag. + - 'new_tab' => Optional boolean value for whether link should open in new tab or current tab. __NOTE__: PHP cURL is required for fetching external images. diff --git a/config.sample.json b/config.sample.json index dda43c7..1338601 100644 --- a/config.sample.json +++ b/config.sample.json @@ -9,17 +9,20 @@ { "alt" : "Facebook", "icon" : "facebook", - "link" : "http://facebook.com" + "link" : "http://facebook.com", + "new_tab" : true }, { "alt" : "Twitter", "icon" : "twitter", - "link" : "http://twitter.com" + "link" : "http://twitter.com", + "new_tab" : true }, { "alt" : "Trello", "icon" : "trello", - "link" : "http://trello.com" + "link" : "http://trello.com", + "new_tab" : true }, { "alt" : "TTRSS", diff --git a/index.php b/index.php index 2f90363..da8021f 100755 --- a/index.php +++ b/index.php @@ -49,8 +49,9 @@ function get_current_url() { foreach ($config['items'] as $i => $item) { $icon = $item['icon']; $link = str_replace("{{cur}}", get_current_url(), $item['link']); + $target = $item['new_tab'] ? ' target="_blank" rel="noopener noreferrer"' : ''; - echo ''; + echo ''; } ?>