Issue #20: Add option to open site links in new tab

This commit is contained in:
Dale Davies
2022-03-22 22:40:50 +00:00
parent 680055504f
commit f7cbeceec1
5 changed files with 20 additions and 9 deletions

View File

@@ -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.

View File

@@ -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;
}

View File

@@ -30,7 +30,8 @@ class Sites {
$this->cache = $cache;
$this->default = [
'icon' => null,
'nofollow' => false
'nofollow' => false,
'newtab' => false,
];
$this->tags = [];

View File

@@ -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",

View File

@@ -1,7 +1,7 @@
{{# hassites}}
<ul class="sites">
{{# sites}}
<li><a {{# nofollow}}rel="nofollow"{{/ nofollow}} title="{{name}}" href="{{url}}">
<li><a {{# newtab}}target="_blank"{{/ newtab}} rel="{{# nofollow}}nofollow {{/ nofollow}}{{# newtab}}noopener{{/ newtab}}" title="{{name}}" href="{{url}}">
<span class="icon">
<img src="/api/icon.php?siteurl={{#urlencode}}{{url}}{{/urlencode}}">
</span>