-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e72bb3a
Showing
17 changed files
with
5,866 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Build & test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14.x | ||
- run: npm ci | ||
- run: npm test | ||
- run: npm run compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Bump & release | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: | ||
- master | ||
push: # Ensure a new release is created for each new tag | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
bump-version-and-release: | ||
if: > # Push => Ensure only changes from master. PR => to not trigger when closing PR without merging | ||
(github.event_name == 'push' && github.event.base_ref == 'refs/heads/master') | ||
|| github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
uses: undergroundwires/bump-everywhere@master | ||
with: | ||
user: undergroundwires-bot | ||
release-token: ${{secrets.BUMP_GITHUB_PAT}} # Does not trigger release pipeline if we use default token: https://git.luolix.topmunity/t5/GitHub-Actions/Github-Action-trigger-on-release-not-working-if-releases-was/td-p/34559 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: [created] # will be triggered when a NON-draft release is created and published. | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14.x | ||
- run: npm ci | ||
- run: npm test | ||
- run: npm run compile | ||
- run: | | ||
mkdir "../artifact" | ||
cp -r . "../artifact" | ||
rm -rf "../artifact/.git" | ||
rm -rf "../artifact/.github" | ||
rm -rf "../artifact/node_modules" | ||
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: package | ||
path: ../artifact | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14.x | ||
registry-url: https://registry.npmjs.org/ | ||
- uses: actions/download-artifact@v1 | ||
with: | ||
name: package | ||
- run: cd package && npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Quality checks | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14.x | ||
- | ||
name: Install dependencies | ||
run: npm install --only=dev | ||
- | ||
name: Validate js | ||
run: npm run lint-js | ||
- | ||
name: 'Validate md: Relative URLs' | ||
run: npm run lint-md-urls-relative | ||
- | ||
name: 'Validate md: Enforce standards' | ||
run: npm run lint-md | ||
- | ||
name: 'Validate md: Ensure consistency' | ||
run: npm run lint-md-consistency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"default": true, | ||
"MD045": false, | ||
"MD013": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 undergroundwires - git@erkinekici.com | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# safe-email | ||
|
||
> 🛡️📧 Protect e-mails against spam and scraping bots | ||
[![](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/undergroundwires/safe-email/issues) | ||
[![](https://github.com/undergroundwires/safe-email/workflows/Publish/badge.svg)](./.github/workflows/publish.yaml) | ||
[![](https://github.com/undergroundwires/safe-email/workflows/Build%20&%20test/badge.svg)](./.github/workflows/build-and-test.yaml) | ||
[![](https://github.com/undergroundwires/safe-email/workflows/Bump%20&%20release/badge.svg)](./.github/workflows/bump-and-release.yaml) | ||
[![](https://github.com/undergroundwires/safe-email/workflows/Quality%20checks/badge.svg)](./.github/workflows/quality-checks.yaml) | ||
[![](https://img.shields.io/npm/v/safe-email)](https://www.npmjs.com/package/safe-email) | ||
[![Auto-versioned by bump-everywhere](https://github.com/undergroundwires/bump-everywhere/blob/master/badge.svg?raw=true)](https://github.com/undergroundwires/bump-everywhere) | ||
<!-- [![](https://img.shields.io/npm/dm/safe-email)](https://www.npmjs.com/package/safe-email) | ||
[![](https://data.jsdelivr.com/v1/package/npm/safe-email/badge?style=rounded)](https://www.jsdelivr.com/package/npm/safe-email) --> | ||
|
||
Easy way to obfuscate e-mails to have spam protection against scraping bots. | ||
|
||
- Vanilla JavaScript only ✔️ | ||
- Very lightweight with no dependencies ✔️ | ||
- Easy to configure by using HTML attributes ✔️ | ||
|
||
## How it works 🛡️ | ||
|
||
- Base64 encoding of e-mail | ||
- CSS tricks to show the right text only to humans | ||
- Obfuscating HTML text of the e-mail | ||
|
||
## Import | ||
|
||
### Option A: Use CDN | ||
|
||
It's the simplest way. Just add it to your page: | ||
|
||
```html | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/safe-email@1.1.0/dist/safe-email.min.js"></script> | ||
``` | ||
|
||
### Option B: Install | ||
|
||
- Using NPM (recommended): `npm install safe-email --save` | ||
- Using bower: `bower install undergroundwires/safe-email` | ||
- As a git submodule: | ||
- Go to the folder you wish to have the repository | ||
- Run `git submodule add https://github.com/undergroundwires/safe-email` | ||
- ❗ Only CDN and NPM solutions will have minified files with polyfills (`dist/` folder) | ||
|
||
```html | ||
<script type="text/javascript" src="/node_modules/safe-email/dist/safe-email.min.js"></script> | ||
``` | ||
|
||
*[top↑](#safe-email)* | ||
|
||
## Usage | ||
|
||
### Examples | ||
|
||
#### Simplest | ||
|
||
```html | ||
<a title="Email" href="#" data-email_b64="dW5kZXJncm91bmR3aXJlc0BnaXRodWIuY29t"></a> | ||
``` | ||
|
||
[See it live on CodePen](https://codepen.io/undergroundwires/pen/XWbLMOL) | ||
|
||
#### With all properties | ||
|
||
```html | ||
<a title="Email" href="#" data-email_b64="dW5kZXJncm91bmR3aXJlc0BnaXRodWIuY29t" | ||
data-body="Hello!" data-subject="About website"></a> | ||
``` | ||
|
||
[See it live on CodePen](https://codepen.io/undergroundwires/pen/MWwMpRL) | ||
|
||
#### With icon | ||
|
||
```html | ||
<a title="Email" href="#" data-email_b64="dW5kZXJncm91bmR3aXJlc0BnaXRodWIuY29t"> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg> | ||
</a> | ||
``` | ||
|
||
[See it live on CodePen](https://codepen.io/undergroundwires/pen/GRJbWaE) | ||
|
||
As icon is an inner HTML of the parent `<a>` your e-mail will not be rendered. | ||
|
||
### Properties | ||
|
||
| Property | Explanation | Required / Default | | ||
| -------- | ----------- | -------- | | ||
| **`data-email_b64`** | Base64 encoded text of your e-mail. You can encode your e-mail [here](https://www.base64encode.org/). | Required | | ||
| **`data-body`** | Body of the e-mail | Optional, Defaults to `Hi!` | | ||
| **`data-subject`** | Subject of the e-mail | Optional, Defaults to root domain name + path, e.g. `abc.com/path` | | ||
|
||
Any element that has **`data-email_b64`** property defined will have obfuscated `mailto:` pointing to the given e-mail address. If owner element of this property has no inner HTML, then the e-mail (in obfuscated form) will be rendered. | ||
|
||
*[top↑](#safe-email)* | ||
|
||
## GitOps | ||
|
||
CI/CD is fully automated for this repo using different GIT events & GitHub actions. | ||
|
||
### On pull request | ||
|
||
![safe-email actions on PR](./img/on-pr.png) | ||
|
||
### On master | ||
|
||
![safe-email actions on master](./img/on-master.png) | ||
|
||
### On release | ||
|
||
![safe-email actions on release](./img/on-release.png) | ||
|
||
The deployed packages includes a `dist/` folder that adds polyfills to the files and distributes them as: | ||
|
||
- minified (`.min.js`) files for production usage | ||
- non-minified (`.js`) files for debugging | ||
|
||
*[top↑](#safe-email)* |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.