Skip to content

Commit

Permalink
bring back nix unstable manual
Browse files Browse the repository at this point in the history
  • Loading branch information
garbas committed Sep 4, 2020
1 parent 4c78323 commit 849cacd
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 71 deletions.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -42,7 +42,8 @@ NIX_MANUAL_UNSTABLE_OUT = manual/nix/unstable
all: $(NIX_MANUAL_UNSTABLE_OUT)

$(NIX_MANUAL_UNSTABLE_OUT): $(call rwildcard, $(NIX_MANUAL_UNSTABLE_IN), *) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIX_MANUAL_UNSTABLE_IN) $(NIX_MANUAL_UNSTABLE_OUT) 'Nix $(NIX_UNSTABLE_VERSION) manual' nix https://github.com/NixOS/nix/tree/master/doc/manual
mkdir -p $(NIX_MANUAL_UNSTABLE_OUT)
cp --no-preserve=mode,ownership -RL $(NIX_MANUAL_UNSTABLE_IN)/* $(NIX_MANUAL_UNSTABLE_OUT)


### Prettify the Nixpkgs manual.
Expand Down
32 changes: 0 additions & 32 deletions css/nixos-site.css
Expand Up @@ -560,35 +560,3 @@ ul.comma-separated > li:last-of-type:after {
text-align: center;
}
}

.injected-select-manual {
background: #333333;
color: #FFFFFF;
padding: 0.5em 1em;
position: fixed;
bottom: 0.5em;
right: 0.5em;
font-size: 0.8em;
}
.injected-select-manual > div {
text-align: right;
cursor: pointer;
}
.injected-select-manual > dl {
display: none;
width: 210px;
margin: 0 0 1em 0;
}
.injected-select-manual > dl > dt {
color: #999999;
}
.injected-select-manual > dl > dd {
display: inline-block;
}
.injected-select-manual > dl > dd > a {
color: #FFFFFF;
font-weight: bold;
}
.injected-select-manual.opened > dl {
display: block;
}
24 changes: 21 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

178 changes: 144 additions & 34 deletions js/manual-version-switch.js
@@ -1,44 +1,154 @@
$(window).load(function() {
// IMPORTANT! We need to place this script at the bottom of the body

(function() {

let project = window.location.pathname.split('/')[2];

function createElement(tag, attrs, text) {
let el = document.createElement(tag);

if (text) {
el.appendChild(document.createTextNode(text));
}

if (attrs) {
attrs.forEach(function (attr) {
el.setAttribute(attr[0], attr[1]);
});
}

return el;
}


function mkItem(name, version) {
return $("<a/>")
.attr("href", "/manual/" + project + "/" + name)
.text(name + " (" + version + ")");
let versionParts = version.split("pre");
let cleanedVersion;
if (versionParts.length == 1) {
cleanedVersion = version;
} else {
cleanedVersion = versionParts[0] + "pre";
}
return createElement(
"a",
[
[ "style", "color: #FFFFFF;" +
"font-weight: bold;" +
"text-decoration: none;"],
["href", "/manual/" + project + "/" + name]
],
name + " (" + cleanedVersion + ")"
);
}

function mkItems(title, items) {
let el = $("<dl>")
.append($("<dt/>").text(title));
items.forEach(function(item) {
el.append($("<dd/>").append(mkItem(item.channel, item.version)))
let dt = createElement(
"dt",
[
["style", "color: #999999;"]
],
title
);

let el = createElement(
"dl",
[
["style", "width: 240px;" +
"margin: 0 0 1em 0;" +
"display: none;"]
]
);
el.appendChild(dt)

let dd;
items.forEach(function (item) {
dd = createElement(
"dd",
[
["style", "display: inline-block;" +
"margin-left: 1em;"]
]
);
dd.appendChild(mkItem(item.channel, item.version));
el.appendChild(dd);
});

return el;
}

let plus = $("<i class=\"fa fa-plus\" aria-hidden=\"true\"></i>");
let minus = $("<i class=\"fa fa-minus\" aria-hidden=\"true\"></i>").hide();
let selected = $("<span>v: " + window.location.pathname.split('/')[3] + "</span>");
let header = $("<div/>")
.click(function(e) {
e.preventDefault();
e.stopPropagation();
let wrapper = $(this).parent();
wrapper.toggleClass("opened");
if (wrapper.hasClass("opened")) {
$(".fa-plus", this).hide()
$(".fa-minus", this).show()
} else {
$(".fa-plus", this).show()
$(".fa-minus", this).hide()
}
})
.append([selected, " ", plus, minus]);

let injected = $("<div/>")
.addClass("injected-select-manual")
.append(header)
.append(mkItems("Channels", $("body").data(project + '-channels')));

$("body").append(injected);
})
function toggleVisibility(e) {
e.preventDefault();
e.stopPropagation();

let [plus, minus] = this.getElementsByTagName("strong");
let channels = this.parentNode.getElementsByTagName("dl")[0];

if (plus.getAttribute("style") === "display: none;") {
plus.removeAttribute("style");
minus.setAttribute("style", "display: none;");
channels.setAttribute("style", channels.getAttribute("style") + "display: none;")
} else {
plus.setAttribute("style", "display: none;");
minus.removeAttribute("style");
channels.setAttribute("style", channels.getAttribute("style").replace("display: none;", ""));
}
}

let plus = createElement(
"strong",
[
["aria-hidden", "true"]
],
"\uFF0B"
);
let minus = createElement(
"strong",
[
["style", "display: none;"],
["aria-hidden", "true"]
],
"\uFF0D"
);
let selected = createElement(
"span",
[],
("v: " + window.location.pathname.split('/')[3])
);

let header = createElement(
"div",
[
["style", "text-align: right;" +
"cursor: pointer;"]
]
);
[selected, document.createTextNode(" "), plus, minus].forEach(function(item) {
header.appendChild(item);
});
header.onclick = toggleVisibility;

let body = document.getElementsByTagName('body')[0];

let channels = mkItems(
"Channels:",
JSON.parse(body.getAttribute("data-" + project + "-channels"))
)

let wrapper = createElement(
"div",
[
["style", "background: #333333;" +
"color: #FFFFFF;" +
"padding: 0.5em 1em;" +
"position: fixed;" +
"bottom: 0.5em;" +
"right: 0.5em;" +
"font-size: 0.8em;"]
]
);
wrapper.appendChild(header);
wrapper.appendChild(channels);

body.appendChild(wrapper);

})();
2 changes: 1 addition & 1 deletion update.sh
Expand Up @@ -7,6 +7,6 @@ UPDATE=1 nix shell nixpkgs#gnumake nixpkgs#curl -c make update --keep-going
nix flake update \
--update-input released-nixpkgs-unstable \
--update-input released-nixpkgs-stable \
--update-input released-nix-unstable \
--update-input released-nix-stable \
--update-input nix-pills
#--update-input released-nix-unstable \

0 comments on commit 849cacd

Please sign in to comment.