From f7cbeceec18e775a66a9d9ea70b00bfd45bdf387 Mon Sep 17 00:00:00 2001 From: Dale Davies Date: Tue, 22 Mar 2022 22:40:50 +0000 Subject: [PATCH] Issue #20: Add option to open site links in new tab --- README.md | 16 +++++++++++----- jumpapp/classes/Site.php | 1 + jumpapp/classes/Sites.php | 3 ++- jumpapp/sites/sites.json | 7 +++++-- jumpapp/templates/sites.mustache | 2 +- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1ffb2b0..4cc676e 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ Make sure you have created a cache directory and given the web user permission t ### Open Weather Map -You can configure Jump to get local time and weather updates by adding an Open Weather Map API key to `config.php` or passing the `OWPAPIKEY ` environment variable to the docker container (as described above). +You can configure Jump to get local time and weather updates by adding an Open Weather Map API key to `config.php` or passing the `OWMAPIKEY ` environment variable to the docker container (as described above). You will also need to provide a default `LATLONG` string (e.g. "51.509865,-0.118092"), Jump will use this until you press the location button and allow permission to get your location from the web browser. @@ -91,13 +91,15 @@ Edit the `/sites/sites.json` file to include your own sites on the startpage... { "default": { "nofollow": true, - "icon": "my-default-icon.png" + "icon": "my-default-icon.png", + "newtab": true }, "sites": [ { "name": "Github", "url" : "https://github.com/daledavies/jump", - "nofollow": false + "nofollow": false, + "newtab": false }, { "name": "Bitwarden", @@ -133,7 +135,7 @@ Edit the `/sites/sites.json` file to include your own sites on the startpage... ``` * `name` and `url` are mandatory. -* `tags`, `nofollow` and `icon` are optional. +* `tags`, `nofollow`, `newtab` and `icon` are optional. #### Tags @@ -145,7 +147,7 @@ The tag selector button will only appear in the top right of the page if you hav Jump has a built-in default icon for sites that do not specify their own although you can override this and specify your own as shown above in the `default` section. -You can also override `nofollow` to be `true` for all sites. +You can also override `nofollow` and `newtab` to be `true` for all sites. #### Icons @@ -155,6 +157,10 @@ You can provide custom icons for your sites by placing them in the `/sites/icons On a per-site basis use `"nofollow": true` to include `rel="nofollow"` on specific site links, if this is set as a global default then `"nofollow": false` can be used to remove `rel="nofollow"` for individual sites. +#### newtab + +On a per-site basis use `"newtab": true` to open specific site links in a new browser tab. + ### Background Images To use your own background images just copy them to the `/backgrounds/` directory, Jump will pick up on them automatically. diff --git a/jumpapp/classes/Site.php b/jumpapp/classes/Site.php index 111fbef..8112f9e 100644 --- a/jumpapp/classes/Site.php +++ b/jumpapp/classes/Site.php @@ -34,6 +34,7 @@ class Site { $this->name = $sitearray['name']; $this->url = $sitearray['url']; $this->nofollow = isset($sitearray['nofollow']) ? $sitearray['nofollow'] : (isset($this->defaults['nofollow']) ? $this->defaults['nofollow'] : false); + $this->newtab = isset($sitearray['newtab']) ? $sitearray['newtab'] : (isset($this->defaults['newtab']) ? $this->defaults['newtab'] : false); $this->iconname = $sitearray['icon'] ?? null; $this->tags = $sitearray['tags'] ?? $this->tags; } diff --git a/jumpapp/classes/Sites.php b/jumpapp/classes/Sites.php index a427a22..261ee20 100644 --- a/jumpapp/classes/Sites.php +++ b/jumpapp/classes/Sites.php @@ -30,7 +30,8 @@ class Sites { $this->cache = $cache; $this->default = [ 'icon' => null, - 'nofollow' => false + 'nofollow' => false, + 'newtab' => false, ]; $this->tags = []; diff --git a/jumpapp/sites/sites.json b/jumpapp/sites/sites.json index 12cbfa2..4bcae04 100644 --- a/jumpapp/sites/sites.json +++ b/jumpapp/sites/sites.json @@ -1,12 +1,15 @@ { "default": { "nofollow": true, - "icon": "my-default-icon.png" + "icon": "my-default-icon.png", + "newtab": true }, "sites": [ { "name": "Github", - "url" : "https://github.com/daledavies/jump" + "url" : "https://github.com/daledavies/jump", + "nofollow": false, + "newtab": true }, { "name": "Docker Hub", diff --git a/jumpapp/templates/sites.mustache b/jumpapp/templates/sites.mustache index ee93a10..59d20e0 100644 --- a/jumpapp/templates/sites.mustache +++ b/jumpapp/templates/sites.mustache @@ -1,7 +1,7 @@ {{# hassites}}