Remove ribbon, add "Edit on Github" links, fixes #398
This commit is contained in:
parent
8ac4137007
commit
e9cd1e3c27
|
@ -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"
|
||||
}
|
||||
}
|
||||
```
|
|
@ -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": {
|
||||
|
|
|
@ -79,6 +79,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
|||
'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'],
|
||||
|
|
|
@ -139,6 +139,21 @@ abstract class Entry
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -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']; ?>
|
||||
|
|
|
@ -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']) {
|
||||
|
|
|
@ -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>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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 () {
|
||||
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
@ -252,13 +252,6 @@ Components
|
|||
}
|
||||
}
|
||||
|
||||
.Github {
|
||||
position: absolute;
|
||||
top: @navbar-height;
|
||||
right: 0;
|
||||
z-index: 200;
|
||||
}
|
||||
|
||||
.Links {
|
||||
padding: 0 20px;
|
||||
|
||||
|
|
Loading…
Reference in New Issue