Skip to content

Commit

Permalink
restifyGH-88 Add github ribbon
Browse files Browse the repository at this point in the history
  • Loading branch information
mcavage committed Mar 5, 2012
1 parent 70e2154 commit 29d465f
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -13,7 +13,7 @@ TAP := ./node_modules/.bin/tap
#
# Files
#
DOC_FILES = guide.restdown
DOC_FILES = index.restdown
JS_FILES := $(shell find lib test -name '*.js')
JSL_CONF_NODE = tools/jsl.node.conf
JSL_FILES_NODE = $(JS_FILES)
Expand Down
12 changes: 6 additions & 6 deletions Makefile.targ
Expand Up @@ -121,12 +121,12 @@ clean:
# identify the subdirectories in docs/media, recreate them in
# $(DOC_BUILD)/media, then do the same with the files.
#
DOC_MEDIA_DIRS := $(shell find docs/media -type d | grep -v "^docs/media$$")
DOC_MEDIA_DIRS := $(DOC_MEDIA_DIRS:docs/media/%=%)
DOC_MEDIA_DIRS := $(shell find docs/branding/media -type d | grep -v "^docs/branding/media$$")
DOC_MEDIA_DIRS := $(DOC_MEDIA_DIRS:docs/branding/media/%=%)
DOC_MEDIA_DIRS_BUILD := $(DOC_MEDIA_DIRS:%=$(DOC_BUILD)/media/%)

DOC_MEDIA_FILES := $(shell find docs/media -type f)
DOC_MEDIA_FILES := $(DOC_MEDIA_FILES:docs/media/%=%)
DOC_MEDIA_FILES := $(shell find docs/branding/media -type f)
DOC_MEDIA_FILES := $(DOC_MEDIA_FILES:docs/branding/media/%=%)
DOC_MEDIA_FILES_BUILD := $(DOC_MEDIA_FILES:%=$(DOC_BUILD)/media/%)

#
Expand Down Expand Up @@ -165,10 +165,10 @@ CLEAN_FILES += \
$(DOC_MEDIA_FILES_BUILD): | $(DOC_MEDIA_DIRS_BUILD)

$(DOC_BUILD)/%: docs/% | $(DOC_BUILD)
$(CP) $< $@
$(MV) $< $@

docs/%.json docs/%.html: docs/%.restdown | $(DOC_BUILD)
$(RESTDOWN) -m $(DOC_BUILD) $<
$(RESTDOWN) -b docs/branding -m $(DOC_BUILD) $<

$(DOC_BUILD):
$(MKDIR) $@
Expand Down
61 changes: 61 additions & 0 deletions docs/branding/footer.html.in
@@ -0,0 +1,61 @@
<script type="text/javascript" charset="utf-8">
$(function() {
var headerHeight = $("#header").height();

var sections = $("#content h1[id], #content h2[id]");
var sectionOffsets = [];
var slack = 100; // Give the section scroll some slack (in pixels).
sections.each(function(elem) {
sectionOffsets.push($(this).offset().top - headerHeight - slack);
});

var currSectionIdx = -1;
function getSectionIdx(scrollDistance) {
if (scrollDistance < sectionOffsets[0]) {
return -1;
} else {
for (var id = sectionOffsets.length; id > 0; id--) {
if (scrollDistance > sectionOffsets[id - 1]) {
return id - 1;
break;
}
}
}
}

/** {{{ http://code.activestate.com/recipes/577787/ (r2) */
_slugify_strip_re = /[^\w\s-]/g;
_slugify_hyphenate_re = /[-\s]+/g;
function slugify(s) {
s = s.replace(_slugify_strip_re, '').trim().toLowerCase();
s = s.replace(_slugify_hyphenate_re, '-');
return s;
}
/** end of http://code.activestate.com/recipes/577787/ }}} */


$("#content").scroll(function() {
var scrollDistance = $("#content").attr('scrollTop');
var sectionIdx = getSectionIdx(scrollDistance);

if (sectionIdx !== currSectionIdx) {
$("#sidebar li>div").removeClass("current");
currSectionIdx = sectionIdx;
if (currSectionIdx >= 0) {
var heading = $(sections[currSectionIdx]).text();
var possibleAnchors = [
slugify(heading), // h1 or non-method h2
heading.replace(/ /g, '-'), // h2 method, just name or just endpoint
heading.slice(0, heading.lastIndexOf(' (')).trimRight().replace(/ /g, '-'), // h2 method, name and endpoint
]
for (var i=0; i < possibleAnchors.length; i++) {
$("#sidebar a[href|=#" + possibleAnchors[i] + "]").parent().addClass("current");
}
}
}
});
});
</script>

</body>
</html>
18 changes: 18 additions & 0 deletions docs/branding/header.html.in
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>%(title)s</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="%(mediaroot)s/css/restdown.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<a href="http://github.com/mcavage/node-restify">
<img style="position: absolute; top: 0; right: 0; border: 0; z-index: 3;"
src="https://a248.e.akamai.net/assets.github.com/img/7afbc8b248c68eb468279e8c17986ad46549fb71/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub"/ >
</a>
<div id="header">
<h1>%(title)s Documentation</h1>
</div>

Expand Up @@ -32,7 +32,6 @@ ul {

ul > li {
list-style:disc;
list-style-position:inside;
margin:10px 0px;
}

Expand Down Expand Up @@ -88,6 +87,7 @@ h4 {
/* tables still need cellspacing="0" in the markup */
table {
border-collapse:collapse; border-spacing:0;
margin: 20px 0;
}
th,
td {
Expand All @@ -96,6 +96,7 @@ td {
line-height: 23px;
padding: 0 12px;
text-align: left;
vertical-align: text-bottom;
}
th {
border-collapse: separate;
Expand Down Expand Up @@ -203,26 +204,33 @@ pre.shell code::before {
#sidebar li {
list-style:none;
padding:1px 0px 1px 0px;
white-space: nowrap;
}

#sidebar li span.verb {
color:#aaa;
padding:2px 3px 0px;
width:30px;
display:block;
float:left;
color: #999;
width:4em;
display:inline-block;
font-size:9px;
font-family:verdana;
-moz-border-radius:3px;
-webkit-border-radius:3px;
margin-left:0px;
margin-right:5px;
}
#sidebar span.both .endpoint {
display: none;
}
#content span.both .endpoint {
color: #999;
font-size: 80%;
}

#sidebar li.current {
background-image: url(../img/tab.gif);
background-repeat: no-repeat;
background-position: right top;
#sidebar li div.current {
background: -moz-linear-gradient(left, rgba(227,222,217,0) 0%, rgba(193,185,173,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(227,222,217,0)), color-stop(100%,rgba(193,185,173,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(227,222,217,0) 0%,rgba(193,185,173,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(227,222,217,0) 0%,rgba(193,185,173,1) 100%); /* Opera11.10+ */
background: -ms-linear-gradient(left, rgba(227,222,217,0) 0%,rgba(193,185,173,1) 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00e3ded9', endColorstr='#c1b9ad',GradientType=1 ); /* IE6-9 */
background: linear-gradient(left, rgba(227,222,217,0) 0%,rgba(193,185,173,1) 100%); /* W3C */
}


Expand Down Expand Up @@ -312,4 +320,3 @@ h3:first-child {
color: black !important;
}
}

File renamed without changes.
Binary file removed docs/media/img/tab.gif
Binary file not shown.

0 comments on commit 29d465f

Please sign in to comment.