Skip to content

Commit 598751a

Browse files
committed
docs(gh-pages): move to main branch
1 parent bf12849 commit 598751a

File tree

6 files changed

+225
-2
lines changed

6 files changed

+225
-2
lines changed

.github/workflows/super-linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ jobs:
7070
DEFAULT_BRANCH: main
7171
ENFORCE_COMMITLINT_CONFIGURATION_CHECK: true
7272
GITHUB_ACTIONS_ZIZMOR_CONFIG_FILE: .zizmor.yml
73+
FILTER_REGEX_EXCLUDE: "(docs/_layouts/default\\.html)$"
7374
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7475
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
To view each bookmarklet source code, you can browse the [javascripts](/javascripts) directory of the main branch.
77

8-
There is also a [user-friendly](https://thomasleplus.github.io/bookmarklets) version of this repository in the form of a GitHub Pages site. The source code of that is in the [gh-pages](../../tree/gh-pages) branch.
8+
There is also a [user-friendly](https://thomasleplus.github.io/bookmarklets) version of this repository in the form of a GitHub Pages site.
99

10-
Feel free to open issues or pull requets for [bugs](../../issues/new?template=bookmarklet-bug-report.md) or [feature requests](../../issues/new?template=bookmarklet-feature-request.md).
10+
Feel free to open issues or pull requets for [bugs](https://github.com/thomasleplus/bookmarklets/issues/new?template=bookmarklet-bug-report.md) or [feature requests](https://github.com/thomasleplus/bookmarklets/issues/new?template=bookmarklet-feature-request.md).

docs/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Bookmarklets
2+
3+
If you don't know what bookmarklets are, I recommend this [introduction](https://www.howtogeek.com/189358/beginner-geek-how-to-use-bookmarklets-on-any-device/).
4+
5+
If you are familiar with bookmarklets but you are not sure how to install one, you can find here [detailed instructions](https://mreidsma.github.io/bookmarklets/installing.html).
6+
7+
Bookmarklets are pretty powerwul. In particular they can have significant security impact (see some of the examples below). The good news is that since they are written in JavaScript, it's pretty easy to review their code. For complete transparency, I show the formatted source code next to each of the bookmarklets below.

docs/_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
theme: jekyll-theme-hacker

docs/_layouts/default.html

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!DOCTYPE html>
2+
<html lang="{{ site.lang | default: "en-US" }}">
3+
<head>
4+
<meta charset='utf-8'>
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
8+
<script src="{{ '/javascripts/fill.js' | relative_url }}"></script>
9+
10+
{% seo %}
11+
</head>
12+
13+
<body onload="init('{{site.github.repository_nwo}}');">
14+
15+
<header>
16+
<div class="container">
17+
<h1>{{ site.title | default: site.github.repository_name }}</h1>
18+
<h2>{{ site.description | default: site.github.project_tagline }}</h2>
19+
</div>
20+
</header>
21+
22+
<div class="container">
23+
<section id="main_content">
24+
{{ content }}
25+
</section>
26+
</div>
27+
28+
<div class="container">
29+
<section id="editor">
30+
<hr>
31+
<h3>Playground</h3>
32+
Modify the name and the source code below and the bookmarklet
33+
in the "Result" section will update to reflect it in real-time.
34+
<h4 style="margin-top: 10px;">Name</h4>
35+
<input class="container" style="background: rgba(0,0,0,0.9); border: 1px solid rgba(255,255,255,0.15); padding: 10px; font-size: 16px; color: #d0d0d0; border-radius: 2px; word-wrap: normal; overflow: scroll;" type="text" id="mininame" name="mininame" value="Hello, world!">
36+
<h4 style="margin-top: 10px;">Source code</h4>
37+
<textarea class="container" style="height: 20em; background: rgba(0,0,0,0.9); border: 1px solid rgba(255,255,255,0.15); padding: 10px; font-size: 16px; color: #d0d0d0; border-radius: 2px; word-wrap: normal; overflow: scroll;" id="plaintext" name="plaintext">"use strict";&#013;&#010;alert('Hello, world!');</textarea>
38+
<h4 style="margin-top: 10px;">Result</h4>
39+
<a id="minified" href="javascript:(function()%7B%22use%20strict%22%3B%20alert('Hello%2C%20world!')%3B%7D)()">Hello, world!</a>
40+
</section>
41+
</div>
42+
43+
<div class="container">
44+
<section id="bookmarklets-list">
45+
<hr/>
46+
<div id="loading">Please wait while content is loading.</div>
47+
<hr/>
48+
</section>
49+
</div>
50+
51+
<footer>
52+
<div class="container">
53+
<section id="downloads">
54+
{% if site.show_downloads %}
55+
<a href="{{ site.github.zip_url }}" class="btn">Download as .zip</a>
56+
<a href="{{ site.github.tar_url }}" class="btn">Download as .tar.gz</a>
57+
{% endif %}
58+
<a href="{{ site.github.repository_url }}" class="btn btn-github"><span class="icon"></span>View on GitHub</a>
59+
</section>
60+
<section id="copyright">
61+
Copyright &copy; 2019-{{ site.time | date: '%Y' }} <a href="https://www.leplus.org" target="_blank">Thomas Leplus</a>.
62+
</section>
63+
<section id="license">
64+
Unless otherwise noted, the content of this site is licensed under <a href="{{site.github.license.url}}" target="_blank">{{site.github.license.name}}</a>.
65+
</section>
66+
</div>
67+
</footer>
68+
69+
</body>
70+
</html>

docs/javascripts/fill.js

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
"use strict";
2+
3+
/*jslint white:true */
4+
5+
function minify(js) {
6+
return (
7+
"javascript:(function()%7B" +
8+
encodeURIComponent(
9+
js
10+
.replace(/[\r\n\t]+/gm, " ")
11+
.replace(/\x20+/gm, " ")
12+
.trim(),
13+
) +
14+
"%7D)()"
15+
);
16+
}
17+
18+
function normalize(s) {
19+
return s
20+
.replaceAll(
21+
/[^a-zA-Z0-9\x21$\x26\x27()*+\x2c\x2d./\x3a\x3b\x3d?\x40_]/g,
22+
"-",
23+
)
24+
.replaceAll(/\x2d+/g, "-");
25+
}
26+
27+
// init() is used in HTML
28+
// eslint-disable-next-line no-unused-vars
29+
async function init(path) {
30+
document.getElementById("mininame").oninput = function () {
31+
document.getElementById("minified").textContent =
32+
document.getElementById("mininame").value;
33+
};
34+
document.getElementById("plaintext").oninput = function () {
35+
document.getElementById("minified").href = minify(
36+
document.getElementById("plaintext").value,
37+
);
38+
};
39+
var content = [];
40+
console.debug("Fetching index");
41+
var index = await fetch(
42+
"https://raw.githubusercontent.com/" +
43+
path +
44+
"/main/javascripts/index.json",
45+
)
46+
.then(function (response) {
47+
return response.json();
48+
})
49+
.catch(console.error);
50+
console.debug("Fetched index");
51+
content.push(document.createElement("hr"));
52+
var toc = document.createElement("section");
53+
content.push(toc);
54+
toc.id = "toc";
55+
var ttoc = document.createElement("h3");
56+
toc.appendChild(ttoc);
57+
ttoc.textContent = "Examples (" + index.length + ")";
58+
var ul = document.createElement("ul");
59+
toc.appendChild(ul);
60+
var i;
61+
for (i = 0; i < index.length; i++) {
62+
var li = document.createElement("li");
63+
ul.appendChild(li);
64+
li.innerHTML =
65+
'<a href="#' +
66+
encodeURIComponent(normalize(index[i].name)) +
67+
'">' +
68+
index[i].name +
69+
"</a>";
70+
}
71+
var loading = document.getElementById("loading");
72+
var j;
73+
for (j = 0; j < index.length; j++) {
74+
loading.textContent += ".";
75+
content.push(document.createElement("hr"));
76+
console.debug("Adding " + index[j].name);
77+
var bookmarklet = document.createElement("section");
78+
content.push(bookmarklet);
79+
bookmarklet.className = "bookmarklet";
80+
var title = document.createElement("h3");
81+
bookmarklet.appendChild(title);
82+
var tlink = document.createElement("a");
83+
title.appendChild(tlink);
84+
tlink.className = "name";
85+
tlink.id = normalize(index[j].name);
86+
tlink.textContent = index[j].name;
87+
var desc = document.createElement("h4");
88+
bookmarklet.appendChild(desc);
89+
desc.textContent = "Description";
90+
var description = document.createElement("p");
91+
bookmarklet.appendChild(description);
92+
description.textContent = index[j].description;
93+
console.debug("Fetching source code for " + index[j].name);
94+
var js = await fetch(
95+
"https://raw.githubusercontent.com/" +
96+
path +
97+
"/main/javascripts/" +
98+
encodeURIComponent(index[j].name) +
99+
".js",
100+
)
101+
.then(function (response) {
102+
return response.text();
103+
})
104+
.catch(console.error);
105+
console.debug("Fetched source code for " + index[j].name);
106+
var book = document.createElement("h4");
107+
bookmarklet.appendChild(book);
108+
book.textContent = "Bookmarklet";
109+
var instructions = document.createElement("p");
110+
bookmarklet.appendChild(instructions);
111+
instructions.innerHTML =
112+
'Drag and drop or bookmark this link: <a href="' +
113+
minify(js) +
114+
'">' +
115+
index[j].name +
116+
"</a>";
117+
var code = document.createElement("h4");
118+
bookmarklet.appendChild(code);
119+
code.textContent = "Source code";
120+
var pre = document.createElement("pre");
121+
bookmarklet.appendChild(pre);
122+
pre.className = "highlight";
123+
var source = document.createElement("code");
124+
pre.appendChild(source);
125+
source.textContent = js.trim();
126+
var edit = document.createElement("a");
127+
bookmarklet.appendChild(edit);
128+
edit.textContent = "Edit it!";
129+
edit.href = "#editor";
130+
edit.onclick = (function (a1, a2) {
131+
return function () {
132+
var e1 = document.getElementById("plaintext");
133+
e1.value = a1;
134+
e1.dispatchEvent(new Event("input"));
135+
var e2 = document.getElementById("mininame");
136+
e2.value = a2;
137+
e2.dispatchEvent(new Event("input"));
138+
};
139+
})(js, index[j].name);
140+
}
141+
content.push(document.createElement("hr"));
142+
document.getElementById("bookmarklets-list").replaceChildren(...content);
143+
}

0 commit comments

Comments
 (0)