Skip to content

Commit

Permalink
Remove ribbon, add "Edit on Github" links, fixes #398
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Goetz committed Aug 16, 2016
1 parent 8ac4137 commit e9cd1e3
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 97 deletions.
17 changes: 17 additions & 0 deletions docs/01_Features/Edit_on_GitHub_links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

As you can see on the top of this page, you can add "Edit on Github" links to your pages, this feature can be enabled with a single parameter.

The value has to be the path to the root of your documentation folder in your repository.

In the value you see below, Daux's documentation is in the `docs` folder in the `master` branch.

Daux.io will handle the rest


```json
{
"html": {
"edit_on_github": "justinwalsh/daux.io/blob/master/docs"
}
}
```
1 change: 1 addition & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"inherit_index": true,

"repo": "justinwalsh/daux.io",
"edit_on_github": "justinwalsh/daux.io/blob/master/docs",
"twitter": ["justin_walsh", "todaymade"],
"google_analytics": "UA-12653604-10",
"links": {
Expand Down
1 change: 1 addition & 0 deletions libs/Format/HTML/ContentPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ protected function generatePage()
'filename' => $this->file->getName(),
'language' => $this->language,
'path' => $this->file->getPath(),
'relative_path' => $this->file->getRelativePath(),
'modified_time' => filemtime($this->file->getPath()),
'markdown' => $this->content,
'request' => $params['request'],
Expand Down
15 changes: 15 additions & 0 deletions libs/Tree/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ public function getPath()
return $this->path;
}

/**
* Get the path to the file from the root of the documentation
*
* @return string
*/
public function getRelativePath()
{
$root = $this;
while($root->getParent() != null) {
$root = $root->getParent();
}

return substr($this->path, strlen($root->getPath()) +1);
}

/**
* @return SplFileInfo
*/
Expand Down
26 changes: 13 additions & 13 deletions templates/content.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php $this->layout('theme::layout/05_page') ?>
<article class="Page">
<?php if ($params['html']['date_modified']) {
?>
<div class="Page__header">
<h1><?= $page['breadcrumbs'] ? $this->get_breadcrumb_title($page, $base_page) : $page['title'] ?></h1>
</div>
<?php

} else {
?>
<div class="Page__header">
<h1><?= $page['breadcrumbs'] ? $this->get_breadcrumb_title($page, $base_page) : $page['title'] ?></h1>
</div>
<?php
<div class="Page__header">
<h1><?= $page['breadcrumbs'] ? $this->get_breadcrumb_title($page, $base_page) : $page['title'] ?></h1>
<?php if ($params['html']['date_modified']) { ?>
<span style="float: left; font-size: 10px; color: gray;">
<?= date("l, F j, Y g:i A", $page['modified_time']); ?>
</span>
<?php } ?>
<?php if ($params['html']['edit_on_github']) { ?>
<span style="float: right; font-size: 10px; color: gray;">
<a href="https://github.com/<?= $params['html']['edit_on_github'] ?>/<?= $page['relative_path'] ?>" target="_blank">Edit on GitHub</a>
</span>
<?php } ?>
</div>

} ?>

<div class="s-content">
<?= $page['content']; ?>
Expand Down
7 changes: 0 additions & 7 deletions templates/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
</div>
</div>

<?php if ($params['html']['repo']) {
?>
<a href="https://github.com/<?= $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="Github hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<?php

} ?>

<div class="Homepage">
<div class="HomepageTitle container">
<?php if ($params['tagline']) {
Expand Down
7 changes: 0 additions & 7 deletions templates/layout/05_page.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?php $this->layout('theme::layout/00_layout') ?>

<?php if ($params['html']['repo']) {
?>
<a href="https://github.com/<?= $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="Github hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<?php

} ?>

<header class="Navbar hidden-print">
<?php $this->insert('theme::partials/navbar_content', ['params' => $params]); ?>
</header>
Expand Down
2 changes: 1 addition & 1 deletion themes/daux/css/theme-blue.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/daux/css/theme-green.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/daux/css/theme-navy.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/daux/css/theme-red.min.css

Large diffs are not rendered by default.

59 changes: 0 additions & 59 deletions themes/daux/js/daux.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,4 @@
/** global localStorage */
var _ = {};

_.now = Date.now || function() {
return new Date().getTime();
};

_.debounce = function(func, wait, immediate) {
var timeout, args, context, timestamp;

var later = function() {
var last = _.now() - timestamp;

if (last < wait && last >= 0) {
timeout = setTimeout(later, wait - last);
} else {
timeout = null;
if (!immediate) {
func.apply(context, args);
if (!timeout) {
context = args = null;
}
}
}
};

return function() {
context = this;
args = arguments;
timestamp = _.now();
var callNow = immediate && !timeout;
if (!timeout) {
timeout = setTimeout(later, wait);
}
if (callNow) {
func.apply(context, args);
context = args = null;
}

return true;
};
};



//Initialize CodeBlock Visibility Settings
$(function () {
Expand Down Expand Up @@ -130,21 +87,5 @@ $(function () {
$('.Collapsible__trigger').click(function () {
$('.Collapsible__content').slideToggle();
});

//Github ribbon placement
var ribbon = $('#github-ribbon');
function onResize() {
//Fix GitHub Ribbon overlapping Scrollbar
var a = $('article');
if (ribbon.length && a.length) {
if (a[0] && a[0].scrollHeight > $('.right-column').height()) {
ribbon[0].style.right = '16px';
} else {
ribbon[0].style.right = '';
}
}
}
$(window).resize(_.debounce(onResize, 100));
onResize();
});

7 changes: 0 additions & 7 deletions themes/daux/less/_components.less
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,6 @@ Components
}
}

.Github {
position: absolute;
top: @navbar-height;
right: 0;
z-index: 200;
}

.Links {
padding: 0 20px;

Expand Down

0 comments on commit e9cd1e3

Please sign in to comment.