all set up vibes

This commit is contained in:
gauthiier 2021-12-05 18:12:01 +01:00
parent 7f8b4f5325
commit f692fca824
8 changed files with 356 additions and 2 deletions

10
.gitignore vendored
View File

@ -1,4 +1,10 @@
# ---> macOS # pppadump
venv/
padinfo.json
.etherdump
out/
# ---> macOS
*.DS_Store *.DS_Store
.AppleDouble .AppleDouble
.LSOverride .LSOverride
@ -25,4 +31,4 @@ Icon
Network Trash Folder Network Trash Folder
Temporary Items Temporary Items
.apdisk .apdisk

14
Makefile Normal file
View File

@ -0,0 +1,14 @@
all: pull index
init:
etherdump init
mkdir out
pull:
etherdump pull --all --force --css styles/html.css --pub out/p --group out/g
index:
etherdump index input out/p/*.meta.json --title "Notes, __MAGICWORDS__, readers & more ..." --templatepath templates/ --output out/index.html
clean:
rm -Rf out/

33
setenv Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
if [ ! -d "venv/" ]
then
echo "venv DOES NOT exists..."
if [[ "$(read -e -p 'Setup venv? [y/N]> '; echo $REPLY)" == [Yy]* ]]
then
echo "Creating python3 venv"
python3 -m venv venv/
echo "Done."
else
echo "Aborting..."
return
fi
fi
source venv/bin/activate
if [ ! "$(pip list | grep -F etherdump)" ]
then
echo "etherdump IS NOT installed"
if [[ "$(read -e -p 'pip install etherdump? [y/N]> '; echo $REPLY)" == [Yy]* ]]
then
echo "Pip installing etherdump"
pip install -e etherdump/
echo "Done."
else
echo "Aborting..."
return
fi
fi
echo "--------------------------------> env set"

106
templates/index.html Normal file
View File

@ -0,0 +1,106 @@
<!DOCTYPE html>
<html lang="{{language}}">
<head>
<meta charset="utf-8" />
<title>{{title}}</title>
<link rel="stylesheet" type="text/css" href="{%block css %}styles.css{%endblock%}">
<link rel="alternate" type="application/rss+xml" href="recentchanges.rss">
{% block scripts %}
<script src="jquery-latest.js"></script>
<script src="jquery.tablesorter.min.js"></script>
{% endblock scripts %}
</head>
<body>
{% block namefilter %}
<div id="namefilter">
<input type="text" id="namefilterinput" value="" placeholder="name filter" autofocus >
<button id="newpadbutton">go/start pad</button>
</div>
<script>
var newpadbutton = document.getElementById("newpadbutton");
newpadbutton.addEventListener("click", function (e) {
var elt = document.getElementById("namefilterinput"),
newpadname = elt.value,
padbase = document.querySelector("td.versions a").href;
newpadname = newpadname.replace(/^\s*/g, "");
newpadname = newpadname.replace(/\s*$/g, "");
elt.value = newpadname;
padbase = padbase.replace(/\/[^/]+$/, "");
if (!newpadname) { alert("type the pad name, then click 'go'")}
else {
var newpadhref = padbase + "/" + encodeURIComponent(newpadname);
// console.log("goto", newpadhref);
window.location = newpadhref;
};
e.preventDefault();
})
var namefilter = (function (opts) {
var timeout_id = null,
filter_value = '',
delay = (opts && opts.delay) || 1000;
function update() {
// console.log("update", filter_value);
var pat = new RegExp(filter_value, "i");
$("tbody tr").each(function () {
var n = $(".name", this).text();
// console.log("n", n);
if (filter_value == "" || n.match(pat) !== null) {
$(this).show();
} else {
$(this).hide();
}
})
}
var ret = function (val) {
filter_value = val;
if (timeout_id !== null) {
window.clearTimeout(timeout_id);
timeout_id = null;
}
timeout_id = window.setTimeout(update, delay)
}
return ret;
})();
$("#namefilterinput").bind("keyup", function (e) { namefilter($(this).val()); })
$(document).ready(function()
{
$("table.listing").tablesorter({sortList: [[2,1]]});
}
);
</script>
{% endblock %}
<table class="listing tablesorter">
<thead>
<tr>
<th>name</th>
<th>versions</th>
<th>last edited</th>
<th>revisions</th>
<th>authors</th>
</tr>
</thead>
<tbody>
{% for pad in pads %}
<tr>
<td class="name">
<a href="{{pad.link}}">{{ pad.padid }}</a>
</td>
<td class="versions">
{% for v in pad.versions %}<a href="{{v.url}}">{{v.type}}</a> {% endfor %}
</td>
<td class="lastedited">{{ pad.lastedited_iso|datetimeformat }}</td>
<td class="revisions">{{ pad.revisions }}</td>
<td class="authors">{{ pad.author_ids|length }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% block info %}<p class="info">Last update {{timestamp}}.</p>{% endblock %}
<div id="footer"></div>
</body>
</html>

17
templates/pad.html Normal file
View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>{{title}}</title>
<link rel="edit" href="{{ editurl }}" />
<link rel="source" href="{{ sourceurl }}" />
<link rel="stylesheet" type="text/css" href="../styles.css" />
<script src ="../page.js"></script>
<script>
var padmeta = {{ metadata_json }};
</script>
</head>
<body>
{{body}}
</body>
</html>

17
templates/pad_colors.html Normal file
View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>{{padid}}</title>
<meta charset="utf-8">
<meta revision="{{revision}}">
<link rel="stylesheet" type="text/css" href="pad.css">
{{ style }}
</head>
<body>
{{ html }}
<div class="etherdump_version_links">
Pad last edited {{lastedited}}; other versions: <a href="{{raw_url}}">text-only</a> <a href="{{meta_url}}">metadata</a>
</div>
</body>
</html>

128
templates/pad_index.html Normal file
View File

@ -0,0 +1,128 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
overflow: hidden;
margin: 0;
padding: 0;
}
td {
vertical-align: top;
}
table ul {
margin: 0;
padding-left: 0;
list-style: none;
}
#content {
position: absolute;
left:0;
top: 0;
right: 0;
bottom: 0;
overflow: auto;
background: gray;
}
iframe {
position: absolute;
left: 0; top: 0;
width: 100%;
height: 100%;
border: none;
margin: 0;
padding: 0;
background: white;
}
#overlay {
position: absolute;
z-index: 10;
right: 20px;
top: 40px;
width: auto;
height: auto;
overflow: hidden;
background: black;
color: white;
padding: 10px;
font-size: 10px;
font-family: monospace;
}
#overlay a {
color: white;
text-decoration: none;
}
#overlay a:hover {
background: gray;
color: black;
}
a.active {
background: white !important;
color: black !important;
}
td.key {
font-style: italic;
}
#overlay.open {}
#overlay .closedcontent { display: block; }
#overlay.open .closedcontent { display: none; }
#overlay .opencontent { display: none; }
#overlay.open .opencontent { display: block; }
</style>
</head>
<body>
<div id="content">
<iframe src="{{padid}}.html" id="frame" name="frame"></iframe>
<div id="overlay">
<div class="closedcontent">
versions
</div>
<table class="opencontent">
<tr><td class="key">padid</td><td>{{padid}}</td></tr>
<tr><td class="key">lastedited</td><td>{{lastedited_iso}}</td></tr>
<tr><td class="key">revisions</td><td>{{revisions}}</td></tr>
<tr>
<td class="key">versions</td>
<td>
<ul>
<li><a href="{{padurl}}" target="frame">Etherpad (editable)</a><li>
<li><a href="{{padid}}.html" target="frame">HTML</a></li>
<li><a href="{{padid}}.txt" target="frame">plain text</a></li>
<li><a href="{{padid}}.diff.html" target="frame">HTML with authorship colors</a></li>
<li><a href="{{padid}}.meta.json" target="frame">Meta data (JSON)</a></li>
</ul>
</td>
</tr>
</table>
</div>
<script>
(function () {
var frame = document.getElementById("frame"),
overlay = document.getElementById("overlay");
frame.addEventListener("load", function () {
var loaded_href = frame.contentDocument.location.href,
links = document.querySelectorAll("#overlay a");
// console.log("load", loaded_href);
for (var i=0, len=links.length; i<len; i++) {
var linkhref = links[i].href;
// console.log("*", linkhref);
if (linkhref == loaded_href) {
links[i].classList.add("active");
} else {
links[i].classList.remove("active");
}
}
});
overlay.addEventListener("mouseenter", function () {
overlay.classList.add("open");
}, false);
overlay.addEventListener("mouseleave", function () {
overlay.classList.remove("open");
}, false);
})()
</script>
</body>
</html>

33
templates/rss.xml Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title>{{title}}</title>
<atom:link href="{{feedurl}}" rel="self" type="application/rss+xml" />
<link>{{siteurl}}</link>
<description>{{description}}</description>
<lastBuildDate>{{utcnow}}</lastBuildDate>
<language>{{language}}</language>
<sy:updatePeriod>{{updatePeriod}}</sy:updatePeriod>
<sy:updateFrequency>{{updateFrequency}}</sy:updateFrequency>
<generator>{{generator}}</generator>
{% for p in pads %}
<item>
<title>{{p.pad}}</title>
<link>{{p.link}}</link>
<pubDate>{{p.lastedited_822}}</pubDate>
<guid isPermaLink="false">{{p.link}}</guid>
<description><![CDATA[{{p.text|excerpt(100)}}]]></description>
{% if content %}<content:encoded><![CDATA[{{p.text}}]]></content:encoded>{% endif %}
</item>
{% endfor %}
</channel>
</rss>