Skip to content

Commit

Permalink
The new doc styling.
Browse files Browse the repository at this point in the history
Move the Gem bundling in docker build.
Skip the initial copy and link the original folders instead in docker build.
Both docker changes should shorten the build a bit.
  • Loading branch information
bundyo committed Jun 14, 2018
1 parent 24e226c commit 8a682b0
Show file tree
Hide file tree
Showing 85 changed files with 15,488 additions and 18,301 deletions.
3 changes: 2 additions & 1 deletion build/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*
!docs-watcher/start.sh
!Gemfile
!docs-watcher/start.sh
22 changes: 19 additions & 3 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM ruby:2.3.5-alpine3.4

RUN mkdir /www

COPY docs-watcher/start.sh /
COPY Gemfile /www/

RUN apk add --update \
bash \
Expand All @@ -12,11 +15,24 @@ RUN apk add --update \
rsync \
nginx \
nodejs \
&& rm -rf /var/cache/apk/* \
&& npm config set cache /var --global \
&& rm -rf /var/cache/apk/*

RUN npm config set cache /var --global \
&& npm install -g grunt \
&& mkdir /run/nginx \
&& chmod +x /start.sh
&& chmod +x /start.sh \
&& echo "Symlinking folders..." \
&& ln -s /root/docs /www/docs \
&& ln -s /root/NativeScript /www/NativeScript \
&& ln -s /root/nativescript-angular /www/nativescript-angular \
&& ln -s /root/nativescript-sdk-examples-ng /www/nativescript-sdk-examples-ng \
&& ln -s /root/nativescript-sdk-examples-js /www/nativescript-sdk-examples-js \
&& ln -s /root/sidekick-docs /www/sidekick-docs \
&& ln -s /root/nativescript-cli /www/nativescript-cli

RUN cd /www \
&& bundle install \
&& bundle config build.nokogiri --use-system-libraries

ENTRYPOINT [ "/start.sh" ]

Expand Down
1 change: 1 addition & 0 deletions build/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ gem 'jekyll-assets'
gem 'github-markdown'
gem 'html-pipeline'
gem 'jekyll-unsanitize', '0.4'
gem 'commonmarker'
190 changes: 136 additions & 54 deletions build/_assets/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ function preventParentSelection(e) {
}
}

function traverseAnchors(elements, level) {
var html = "<ul>";

elements.each(function(index, anchor) {
if (!anchor.textContent.startsWith("Example")) {
html += '<li><a href="' + anchor.hash + '">' + anchor.textContent + '</a>';

html += traverseAnchors($(anchor.parentElement).nextUntil('h' + level, 'h' + (level + 1)).children("a"), level + 1);

html += "</li>";
}
});

return html + "</ul>";
}

$(function(){

$("pre[lang]").each(function() {
Expand All @@ -72,15 +88,19 @@ $(function(){

tabs[0].addClass("k-state-active");

var tabstrip = $("<div>")
var tabstrip = $("<div class='nd-code-container'>")
.insertBefore(this)
.append($("<ul>").append(tabs))
.append(langs);

langs.wrap("<div>");

tabstrip.kendoTabStrip({
animation: false
animation: {
open: {
effects: "fadeIn"
}
}
});
});

Expand Down Expand Up @@ -203,22 +223,124 @@ $(function(){

ul.appendTo(this);
});
});

$(function() {
$(document.body)
.on("click", ".hamb", function(e) {
e.preventDefault();
$("#page-nav").toggleClass("expanded");
})
.kendoTouch({
tap: function(e) {
var navigation = $("#page-nav");
if (!$.contains(navigation[0], e.target)) {
navigation.removeClass("expanded");
var options = {
root: null,
rootMargin: "0px",
threshold: 1.0
};

window.addEventListener("scroll", function(e) {
e.target.documentElement.classList[e.target.scrollingElement.scrollTop !== 0 ? "add" : "remove"]("ns-state-scrolled");
}, { passive: true });

var visibleElements = [];

var observer = new IntersectionObserver(function (entries) {
entries.forEach(function(entry) {
if (entry.intersectionRatio < 1) {
visibleElements.splice(visibleElements.indexOf(entry.target), 1);
} else {
visibleElements[entry.intersectionRect.y < entry.rootBounds.height ? "unshift" : "push"](entry.target);
}
});

if (visibleElements[0]) {
var topElement = { offsetTop: 9999999 };

visibleElements.forEach(function (element) {
if (element.offsetTop < topElement.offsetTop) {
topElement = element;
}
});

topElement = $('.right-nav__tree [href$="#' + topElement.id + '"]');

if (topElement[0]) {
$(".right-nav__tree a").removeClass("ns-state-selected");

topElement.addClass("ns-state-selected");
}
}
}, options);

var seeAlso = $("#see-also");
var seeAlsoLinks = seeAlso.next("ul");

seeAlso.remove();

var apiReferences = $("article > p > a[href*=api-reference]");
var rightNavLinks = $(".right-nav__links");

var rightNav = $('\
<div class="right-nav__container">\
<input id="right-nav__toggle" class="right-nav__input" type="checkbox">\
<label for="right-nav__toggle" class="right-nav__label"></label>\
<div class="right-nav__tree"></div>\
<div class="right-nav__sizer"></div>\
</div>')
.insertBefore($("article"))
.children(".right-nav__tree");

var articleAnchors = $(traverseAnchors($("article > h2 > a"), 2));

if (articleAnchors.children()[0]) {
rightNav
.append($("<div class='-allcaps'>In this article</div>"))
.append(articleAnchors);
}

if (seeAlsoLinks[0]) {
rightNav
.append($("<div class='-allcaps'>Related articles</div>"))
.append(seeAlsoLinks);
}

if (apiReferences[0]) {
apiReferences.parent().remove();

rightNav
.append($("<div class='-allcaps'>API Reference</div>"))
.append(apiReferences.wrap("<li></li>").parent().wrapAll("<ul></ul>").parent());
}

if (rightNavLinks[0]) {
rightNav
.append($("<div>Not finding the help you need?</div>"))
.append(rightNavLinks);
}

$(document.documentElement).on("click", function() {
var toggle = $("#right-nav__toggle")[0];

if (toggle) {
toggle.checked = false;
}
});

$(".right-nav__container").on("click", function(e) {
e.stopPropagation();
});

$("article > h2, article > h3").each(function(index, node) {
observer.observe(node);
});

var bodyObserver = new MutationObserver(function(entries) {
entries.forEach(function() {
if (document.body.classList.contains("gsc-overflow-hidden")) {
document.documentElement.classList.add("-overflow-hidden");
} else {
document.documentElement.classList.remove("-overflow-hidden");
}
});
});

bodyObserver.observe(document.body, {
attributes: true,
attributeOldValue: true,
attributeFilter: ["class"]
});
});

$(function() {
Expand Down Expand Up @@ -268,43 +390,3 @@ $(function() {
window.setTimeout(handleBanner, 1000);
});

$(function() {
'use strict';

var $searchBtn = $('.Search-open');
var $searchBar = $('.Search-container');
var $searchCancel = $('.Btn--cancel');
var $navLinks = $('.Nav-menu .-fl');
var $navLinksMobileToggle = $('.Nav-open-menu');

// improve menu
$navLinks.find('a').each(function() {
if ($(this).attr('href') === document.location.pathname) {
$(this).addClass('is-current');
}
});

// show search menu
$searchBtn.on('click', function() {
$searchBtn.toggleClass('is-active');
$searchBar.toggle();
$('[name=search]').first().focus();
// hide nav when opening search
$navLinks.removeClass('is-visible');
$navLinksMobileToggle.removeClass('is-active');
});
$searchCancel.on('click', function() {
$searchBar.toggle();
$searchBtn.toggleClass('is-active');
});

// show mobile menu
$navLinksMobileToggle.on('click', function() {
$(this).toggleClass('is-active');
$navLinks.toggleClass('is-visible');
// hide search when opening nav
$searchBar.hide();
$searchBtn.removeClass('is-active');
});
});

25 changes: 14 additions & 11 deletions build/_assets/javascripts/feedback-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ $(document).ready(function () {
textFeedback: "",
acceptFeedbackContact: false
};

$("#feedback-checkbox-area").click(function (e) {
$("span.k-tooltip-validation").remove();

var checkboxArea = $("#feedback-checkbox-area");

checkboxArea.click(function () {
checkboxArea.find("span.k-tooltip-validation").remove();
checkboxArea.find("textarea").removeClass("k-invalid");
});

var formIsProcessing = false;
Expand Down Expand Up @@ -66,7 +69,7 @@ $(document).ready(function () {
};

//Feedback menu controls
var feedbackButtonsContainer = $("#helpful-buttons-container");
var feedbackButtonsContainer = $("#feedback-buttons-container");
var feedbackSubmittedContainer = $("#feedback-submitted-container");
var toggleFeedbackButtons = function (toggle) {
if (toggle) {
Expand All @@ -87,8 +90,8 @@ $(document).ready(function () {
//FORM
//Init the form popup window
var win = $("#feedback-form-window").kendoWindow({
title: "Give article feedback",
actions: ["Close"],
title: "Article feedback",
actions: [],
draggable: true,
modal: true,
pinned: false,
Expand Down Expand Up @@ -125,7 +128,7 @@ $(document).ready(function () {
//Bind model to form
kendo.bind($("div#feedback-form-window"), formModel);
//Attach to form submit to adjust variables and send request
var emptyFormValidator = $("#feedback-checkbox-area").kendoValidator({
var emptyFormValidator = checkboxArea.kendoValidator({
validateOnBlur: false,
messages: {
// defines a message for the custom validation rule
Expand Down Expand Up @@ -294,7 +297,7 @@ $(document).ready(function () {


var windowHeight = $window.height();
var headerHeight = $(".TK-Hat").outerHeight() + $("#page-header").outerHeight();
var headerHeight = $(".TK-Hat").outerHeight() + $(".ns-navigation").outerHeight();
var footerHeight = $("#feedback-section").outerHeight() + $("footer").outerHeight();
var articleHeight = windowHeight - (headerHeight + footerHeight);
var feedbackOffsetTop = document.body.scrollHeight - footerHeight;
Expand All @@ -305,7 +308,7 @@ $(document).ready(function () {

function updateVariables() {
windowHeight = $window.height();
headerHeight = $(".TK-Hat").outerHeight() + $("#page-header").outerHeight();
headerHeight = $(".TK-Hat").outerHeight() + $(".ns-navigation").outerHeight();
footerHeight = $("#feedback-section").outerHeight() + $("footer").outerHeight();
articleHeight = windowHeight - (headerHeight + footerHeight);
feedbackOffsetTop = document.body.scrollHeight - footerHeight;
Expand Down Expand Up @@ -380,8 +383,8 @@ $(document).ready(function () {
if (!shouldOverlayFeedback || showingFeedbackBar) {
return;
}
if (scrollFold - $("#feedback-section").outerHeight() < feedbackOffsetTop) {

if (scrollFold - $("#feedback-section").outerHeight() * 2 < feedbackOffsetTop) {
Feedback.pinFeedback();
}
else {
Expand Down
Loading

0 comments on commit 8a682b0

Please sign in to comment.