Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sommerregen committed Nov 17, 2015
2 parents 2e04b66 + 33edabe commit 9c882da
Show file tree
Hide file tree
Showing 9 changed files with 371 additions and 89 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
assets/logo.svg
*.xcf
.idea
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# v1.4.0
## 11/17/2015

1. [](#new)
* Added `External Links` options to page options tab
2. [](#improved)
* Improved `isExternalUrl` function to allow custom schemes and whether to evaluate links beginning with `.www` or not
* Added more blueprint options
* Improved code
* Updated docs
3. [](#bugfix)
* Fixed[#7](https://github.com/Sommerregen/grav-plugin-external-links/issues/7) (Possible issue with malformed URLs)
* Fixes `external_links` filter function

# v1.3.1
## 09/09/2015

Expand Down
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
* [Installation and Updates](#installation-and-updates)
* [Usage](#usage)
* [Example](#example)
* [CSS Stylesheet Override](#css-stylesheet-override)
* [Twig Filter](#twig-filter)
* [Contributing](#contributing)
* [Licencse](#license)
* [License](#license)

## About

`External Links` is a plugin for [GetGrav.org](http://getgrav.org) used to differentiate between internal and external links. It also includes the ability of adding "rel=nofollow" to links and determines how external links shall be opened via the "target" attribute. [Wikipedia](https://www.wikipedia.org/) is a well-known example.
`External Links` is a high-quality plugin for [GetGrav.org](http://getgrav.org) used to differentiate between internal and external links. It also includes the ability of adding `rel="nofollow"` to links and determines how external links shall be opened via the `target` attribute. [Wikipedia](https://www.wikipedia.org/) is a well-known example.

Furthermore it enables you to specify multiple domains, each of them on a new line to prevent them from being seen as external sites.

Expand Down Expand Up @@ -44,19 +46,37 @@ enabled: true # Set to false to disable this plugin completely
built_in_css: true # Use built-in CSS of the plugin
weight: 0 # Set the weight (order of execution)

# Default options for External Links configuration.
# Default options for External Links configuration

exclude:
classes: [exclude] # Exclude all links with this class
domains: # A list of domains to be excluded e.g
# - localhost/* # (any RegExp can be used)
# - img.domain.com/*

links:
www: true # Autom. link any hostname that starts with "www."

schemes: # Allowed schemes
- 'http'
- 'https'
- 'ftp'
- 'irc'
- 'mailto'
- 'news'
- 'nntp'
- 'rtsp'
- 'sftp'
- 'ssh'
- 'tel'
- 'telnet'
- 'webcal'

# Global and page specific configurations

process: true # Filter external links

title: true # Sets default title for external links
title: false # Sets default title for external links
no_follow: true # Add rel="nofollow" to all external links
target: "_blank" # Set target attribute of link

Expand Down Expand Up @@ -125,6 +145,22 @@ You can now edit, override and tweak it however you prefer. However, this plugin
- `image` -- Set if a link contains an image (with size > 32px).
- `images` -- Set if a link contains more than one image.

### Twig Filter

`External Links` provides a Twig filter to process external links inside contents. To do that, place the following line of code in the theme file you wish to add the `External Links` plugin for:

```
{{ page.content|external_links }}
```

You can pass arguments to the plugin filter, namely the same arguments as available in the [external_links.yaml](external_links.yaml) file. For example

```
{{ page.content|external_links({'mode': 'passive'}) }}
```
will change the mode of the `External Links` filter to parse links, but don't set CSS classes.
## Contributing
You can contribute at any time! Before opening any issue, please search for existing issues and review the [guidelines for contributing](docs/CONTRIBUTING.md).
Expand Down
64 changes: 48 additions & 16 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: External Links
version: 1.3.1
version: 1.4.0
description: "This plugin adds small icons to external and mailto links, informing users the link will take them to a new site or open their email client."
icon: external-link
author:
Expand Down Expand Up @@ -58,22 +58,53 @@ form:
underline: 1

fields:
exclude.classes:
type: selectize
size: large
label: PLUGINS.EXTERNAL_LINKS.EXCLUDE_CLASSES
help: PLUGINS.EXTERNAL_LINKS.EXCLUDE_CLASSES_HELP
validate:
type: commalist
links:
type: section
title: PLUGINS.EXTERNAL_LINKS.LINKS.SECTION
text: PLUGINS.EXTERNAL_LINKS.LINKS.SECTION_HELP

exclude.domains:
type: selectize
size: large
label: PLUGINS.EXTERNAL_LINKS.EXCLUDE_DOMAINS
help: PLUGINS.EXTERNAL_LINKS.EXCLUDE_DOMAINS_HELP
placeholder: "localhost/*, img.domain.com/*"
validate:
type: commalist
fields:
links.www:
type: toggle
label: PLUGINS.EXTERNAL_LINKS.LINKS.WWW
help: PLUGINS.EXTERNAL_LINKS.LINKS.WWW_HELP
default: 0
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool

links.schemes:
type: selectize
size: large
label: PLUGINS.EXTERNAL_LINKS.LINKS.SCHEMES
help: PLUGINS.EXTERNAL_LINKS.LINKS.SCHEMES_HELP
validate:
type: commalist

exclude:
type: section
title: PLUGINS.EXTERNAL_LINKS.EXCLUDE.SECTION
text: PLUGINS.EXTERNAL_LINKS.EXCLUDE.SECTION_HELP

fields:
exclude.classes:
type: selectize
size: large
label: PLUGINS.EXTERNAL_LINKS.EXCLUDE.CLASSES
help: PLUGINS.EXTERNAL_LINKS.EXCLUDE.CLASSES_HELP
validate:
type: commalist

exclude.domains:
type: selectize
size: large
label: PLUGINS.EXTERNAL_LINKS.EXCLUDE.DOMAINS
help: PLUGINS.EXTERNAL_LINKS.EXCLUDE.DOMAINS_HELP
placeholder: "localhost/*, img.domain.com/*"
validate:
type: commalist

specific:
type: section
Expand All @@ -84,6 +115,7 @@ form:
process:
type: toggle
label: PLUGINS.EXTERNAL_LINKS.PROCESS
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.YES
Expand Down
78 changes: 78 additions & 0 deletions blueprints/external_links.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
form:
validation: loose

fields:
tabs:
type: tabs
active: 1

fields:
options:
type: tab

fields:
external_links:
type: section
title: PLUGINS.EXTERNAL_LINKS.EXTERNAL_LINKS
underline: true

fields:
header.external_links.process:
type: toggle
label: PLUGINS.EXTERNAL_LINKS.PROCESS
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool

header.external_links.title:
type: toggle
label: PLUGINS.EXTERNAL_LINKS.TITLE
default: 0
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool

header.external_links.no_follow:
type: toggle
label: PLUGINS.EXTERNAL_LINKS.NO_FOLLOW
default: 1
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool

header.external_links.target:
type: select
size: large
label: PLUGINS.EXTERNAL_LINKS.TARGET
default: _blank
placeholder: _blank
selectize:
create: true
options:
_blank: PLUGINS.EXTERNAL_LINKS.TARGET_BLANK
_self: PLUGINS.EXTERNAL_LINKS.TARGET_SELF
_parent: PLUGINS.EXTERNAL_LINKS.TARGET_PARENT
_top: PLUGINS.EXTERNAL_LINKS.TARGET_TOP
validate:
type: string

header.external_links.mode:
type: select
size: large
classes: fancy
label: PLUGINS.EXTERNAL_LINKS.MODE
help: PLUGINS.EXTERNAL_LINKS.MODE_HELP
default: active
options:
active: PLUGINS.EXTERNAL_LINKS.MODE_ACTIVE
passive: PLUGINS.EXTERNAL_LINKS.MODE_PASSIVE
validate:
type: string
Loading

0 comments on commit 9c882da

Please sign in to comment.