share-to-fediverse-jekyll-theme 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_config.yml +1 -0
- data/_data/forms/fediverse.yml +11 -0
- data/_includes/boolean.html +3 -3
- data/assets/css/styles.scss +1 -0
- data/assets/js/script.js +49 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d8cb5d855f0cdea583192060b84f4f2c7fa5e6b51bc08feee2b5eeda92aed7d
|
4
|
+
data.tar.gz: 853688ddfc62c42859aa5f8f1383e6d69ecbde96975cdf78dc3abc87f9d15592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8386178a4cde7d29adaa781a17c59736ce003eeec7e708c045b6b7bb0b5e86725a4afe47e043a110f3083e9a6a44bcd3929bf9695d1f61e5f841ea549662ddf1
|
7
|
+
data.tar.gz: dbd1065edb4f5281cca6d3260691cff1217ffb5419887ffe4db6f677827c5451c895a81c6d7ee0520cad304462a0a7c3cf819842834a8a76368aa5900f429bc4
|
data/_config.yml
CHANGED
data/_data/forms/fediverse.yml
CHANGED
@@ -11,6 +11,17 @@ instance:
|
|
11
11
|
help:
|
12
12
|
es: 'Tu servidor de Mastodon, incluyendo https://'
|
13
13
|
en: 'Your Mastodon server, including https://'
|
14
|
+
remember:
|
15
|
+
type: 'boolean'
|
16
|
+
autocomplete: 'on'
|
17
|
+
label:
|
18
|
+
es: 'Recordar la instancia'
|
19
|
+
en: 'Remember instance'
|
20
|
+
help:
|
21
|
+
es: 'Continuar automáticamente'
|
22
|
+
en: 'Auto-forward from now on'
|
23
|
+
separator:
|
24
|
+
type: 'separator'
|
14
25
|
submit:
|
15
26
|
type: 'submit'
|
16
27
|
label:
|
data/_includes/boolean.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
{%- assign help = include.field[1].help[site.locale] -%}
|
5
5
|
{%- assign autocomplete = include.field[1].autocomplete -%}
|
6
6
|
|
7
|
-
<div class="
|
7
|
+
<div class="custom-control custom-switch">
|
8
8
|
<input
|
9
9
|
{% if help %}
|
10
10
|
aria-describedby="help-{{ id }}"
|
@@ -18,9 +18,9 @@
|
|
18
18
|
{% if autocomplete %}
|
19
19
|
autocomplete="{{ autocomplete }}"
|
20
20
|
{% endif %}
|
21
|
-
class="
|
21
|
+
class="custom-control-input" />
|
22
22
|
|
23
|
-
<label class="
|
23
|
+
<label class="custom-control-label" for="{{ id }}">{{ label }}</label>
|
24
24
|
|
25
25
|
{%- if help -%}
|
26
26
|
<small id="help-{{ id }}" class="form-text">
|
data/assets/css/styles.scss
CHANGED
data/assets/js/script.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
---
|
2
2
|
---
|
3
3
|
|
4
|
-
//
|
4
|
+
// Convert query arguments to object
|
5
|
+
// @see {https://stackoverflow.com/a/7090123}
|
6
|
+
// @return [Object]
|
5
7
|
const searchToObject = () => {
|
6
8
|
var pairs = window.location.search.substring(1).split("&"),
|
7
9
|
obj = {},
|
@@ -18,21 +20,64 @@ const searchToObject = () => {
|
|
18
20
|
return obj;
|
19
21
|
}
|
20
22
|
|
23
|
+
// Compatible with Turbolinks
|
24
|
+
const loadEvent = () => window.Turbolinks ? 'turbolinks:load' : 'DOMContentLoaded';
|
21
25
|
|
22
|
-
document.addEventListener(
|
26
|
+
document.addEventListener(loadEvent(), () => {
|
23
27
|
const urlShared = searchToObject();
|
24
28
|
|
29
|
+
// Add the query args to the locale selector
|
25
30
|
document.querySelectorAll('a[lang]').forEach(a => a.href += window.location.search);
|
26
31
|
|
32
|
+
// Recover data from URL only if it's set
|
27
33
|
['t','d','u'].forEach(field => {
|
28
34
|
if (urlShared[field] === undefined) return;
|
29
35
|
|
30
36
|
document.querySelector(`#${field}`).innerText = urlShared[field];
|
31
37
|
});
|
32
38
|
|
39
|
+
// Send this field
|
33
40
|
document.querySelector('#text').value = Object.values(urlShared).join("\n\n");
|
34
41
|
|
35
|
-
|
36
|
-
|
42
|
+
// Helpers for data storage
|
43
|
+
const isCheckbox = input => input.type == 'checkbox';
|
44
|
+
const itemId = (form, input) => form.id + ':' + input.id;
|
45
|
+
|
46
|
+
const form = document.querySelector('form')
|
47
|
+
const formInputs = Array.from(form.elements);
|
48
|
+
|
49
|
+
form.addEventListener('submit', e => {
|
50
|
+
// Change the form action to the actual instance
|
51
|
+
form.action = document.querySelector('#instance').value + '/share';
|
52
|
+
|
53
|
+
const rememberInstance = document.querySelector('#remember').checked;
|
54
|
+
|
55
|
+
// If user disabled it, forget data.
|
56
|
+
if (!rememberInstance) localStorage.clear();
|
57
|
+
|
58
|
+
// Store the data. Form autocomplete should be helpful
|
59
|
+
// here but for some reason it doesn't.
|
60
|
+
formInputs.forEach(input => {
|
61
|
+
if (input.type == 'submit') return;
|
62
|
+
|
63
|
+
if (!rememberInstance) return;
|
64
|
+
|
65
|
+
localStorage.setItem(itemId(form, input), isCheckbox(input) ? input.checked : input.value);
|
66
|
+
});
|
67
|
+
});
|
68
|
+
|
69
|
+
// Recover information
|
70
|
+
formInputs.forEach(input => {
|
71
|
+
if (input.type == 'submit') return;
|
72
|
+
|
73
|
+
const value = localStorage.getItem(itemId(form, input));
|
74
|
+
|
75
|
+
if (value) input[isCheckbox(input) ? 'checked' : 'value'] = value;
|
37
76
|
});
|
77
|
+
|
78
|
+
// Redirect after a timeout, so users have time to disable.
|
79
|
+
setTimeout(() => {
|
80
|
+
if (!document.querySelector('#remember').checked) return;
|
81
|
+
document.querySelector('form').submit();
|
82
|
+
}, {{ site.auto_submit_seconds | default: 3 }} * 1000);
|
38
83
|
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: share-to-fediverse-jekyll-theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|