Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
Added Edit This Page functionality in plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rdsubhas committed Jun 15, 2014
1 parent 5def77e commit a17d32f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions gitbook-plugin-rapidftr/book/edit-this-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require(["gitbook", "utils/url", "jQuery"], function(gitbook, URL, jQuery) {

var editBaseUrl = $(".contribute-link").attr("href");
var bookBaseUrl = URL.join(window.location.pathname, $(".book-header h1 a").attr("href"));

function updateLink() {
var editPath = window.location.pathname.replace(bookBaseUrl, "");

if (editPath.indexOf("/") !== 0) editPath = "/" + editPath;
if (editPath === "/") editPath = editPath + "README.md";
if (editPath.indexOf("/index.html") >= 0) editPath = editPath.replace("/index.html", "/README.md");
if (editPath.indexOf(".html") >= 0) editPath = editPath.replace(".html", ".md");
if (editPath.indexOf(".md", editPath.length - 3) === -1) editPath = editPath + ".md";

var editUrl = editBaseUrl.replace("/tree/", "/edit/") + editPath;
$(".contribute-link").attr("href", editUrl);
}

gitbook.events.bind("page.change", updateLink);

});
3 changes: 2 additions & 1 deletion gitbook-plugin-rapidftr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module.exports = {
book: {
assets: './book',
js: [
'rapidftr.js'
'guide-dropdown.js',
'edit-this-page.js'
]
}
}

0 comments on commit a17d32f

Please sign in to comment.