Remove the file editor
This commit is contained in:
bovenliggende
4f8d817365
commit
a35af5fd19
11
README.md
11
README.md
@ -170,17 +170,6 @@ Include custom links in the sidebar.
|
||||
}
|
||||
```
|
||||
|
||||
###File editor:
|
||||
![File editor](https://f.cloud.github.com/assets/1788727/1954191/44358884-81d1-11e3-859d-254b9fb81808.png)
|
||||
|
||||
Enable front-end Markdown editor. _Disabled by default_.
|
||||
|
||||
```json
|
||||
{
|
||||
"file_editor": true
|
||||
}
|
||||
```
|
||||
|
||||
###Google Analytics:
|
||||
This will embed the google analytics tracking code.
|
||||
|
||||
|
@ -181,17 +181,6 @@ Include custom links in the sidebar.
|
||||
}
|
||||
```
|
||||
|
||||
### File editor:
|
||||
![File editor](https://f.cloud.github.com/assets/1788727/1954191/44358884-81d1-11e3-859d-254b9fb81808.png)
|
||||
|
||||
Enable front-end Markdown editor. _Disabled by default_.
|
||||
|
||||
```json
|
||||
{
|
||||
"file_editor": true
|
||||
}
|
||||
```
|
||||
|
||||
### Google Analytics:
|
||||
This will embed the google analytics tracking code.
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
"breadcrumb_separator": "Chevrons",
|
||||
"date_modified": true,
|
||||
"float": true,
|
||||
"file_editor": false,
|
||||
"repo": "justinwalsh/daux.io",
|
||||
"ignore": {
|
||||
"files": ["Work_In_Progress.md"],
|
||||
|
@ -23,7 +23,6 @@
|
||||
"toggle_code": false,
|
||||
"date_modified": false,
|
||||
"float": false,
|
||||
"file_editor": false,
|
||||
"timezone": "America/Los_Angeles",
|
||||
|
||||
"google_analytics": false,
|
||||
|
@ -104,46 +104,11 @@ class Server
|
||||
|
||||
$request = $this->getRequest();
|
||||
$request = urldecode($request);
|
||||
$request_type = isset($query['method']) ? $query['method'] : '';
|
||||
if ($request == 'first_page') {
|
||||
$request = $this->daux->tree->getFirstPage()->getUri();
|
||||
}
|
||||
|
||||
switch ($request_type) {
|
||||
case 'DauxEdit':
|
||||
if (!$this->daux->options['file_editor']) {
|
||||
throw new Exception('Editing is currently disabled in config');
|
||||
}
|
||||
|
||||
$content = isset($query['markdown']) ? $query['markdown'] : '';
|
||||
return $this->saveFile($request, $content);
|
||||
|
||||
default:
|
||||
return $this->getPage($request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $request
|
||||
* @param string $content
|
||||
* @return SimplePage
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
private function saveFile($request, $content)
|
||||
{
|
||||
$file = $this->getFile($request);
|
||||
|
||||
if ($file === false) {
|
||||
throw new NotFoundException('The Page you requested is yet to be made. Try again later.');
|
||||
}
|
||||
|
||||
if (!$file->write($content)) {
|
||||
throw new Exception('The file you wish to write to is not writable.');
|
||||
}
|
||||
|
||||
return new SimplePage('Success', 'Successfully Edited');
|
||||
return $this->getPage($request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,20 +181,6 @@ abstract class Entry
|
||||
$this->index_page = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
* @return bool
|
||||
*/
|
||||
public function write($content)
|
||||
{
|
||||
if (!is_writable($this->local_path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
file_put_contents($this->local_path, $content);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -1,53 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
var markdown_editor = $("#markdown_editor"),
|
||||
save_editor = $(".save_editor"),
|
||||
editor = $(".editor");
|
||||
|
||||
$("#editThis").click(function() {
|
||||
editor.css({"display":"block"});
|
||||
markdown_editor.autosize().val();
|
||||
});
|
||||
|
||||
$(".closeEditor").click(function() {
|
||||
editor.css({"display":"none"});
|
||||
});
|
||||
|
||||
save_editor.click(function() {
|
||||
var original_text = save_editor.text();
|
||||
save_editor.text("Saving...").addClass("disabled");
|
||||
|
||||
$.post(window.location.href, {markdown: markdown_editor.val(), method: 'DauxEdit' }, function() {
|
||||
save_editor.text("Done! Reloading page in 5 seconds. You can cancel it with ESC key");
|
||||
|
||||
var timeout = setTimeout(function() {
|
||||
location.reload()
|
||||
}, 5000); // lie
|
||||
|
||||
$(document).keyup(function(e) {
|
||||
if (e.keyCode == 27) { // esc key
|
||||
clearTimeout(timeout);
|
||||
save_editor.text("Page reload cancelled");
|
||||
setTimeout(function() {
|
||||
save_editor.text(original_text).removeClass('disabled');
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
}).fail(function() {
|
||||
save_editor.removeClass('disabled').addClass("btn-danger").text("Failed :( - try checking your read/write permissions");
|
||||
setTimeout(function() {
|
||||
save_editor.text(original_text).removeClass('btn-danger');
|
||||
},5000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
Autosize v1.18.4 - 2014-01-11
|
||||
Automatically adjust textarea height based on user input.
|
||||
(c) 2014 Jack Moore - http://www.jacklmoore.com/autosize
|
||||
license: http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
!function(a){var b,c={className:"autosizejs",append:"",callback:!1,resizeDelay:10,placeholder:!0},d='<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',e=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent"],f=a(d).data("autosize",!0)[0];f.style.lineHeight="99px","99px"===a(f).css("lineHeight")&&e.push("lineHeight"),f.style.lineHeight="",a.fn.autosize=function(d){return this.length?(d=a.extend({},c,d||{}),f.parentNode!==document.body&&a(document.body).append(f),this.each(function(){function c(){var b,c=window.getComputedStyle?window.getComputedStyle(m,null):!1;c?(b=m.getBoundingClientRect().width,0===b&&(b=parseInt(c.width,10)),a.each(["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],function(a,d){b-=parseInt(c[d],10)})):b=Math.max(n.width(),0),f.style.width=b+"px"}function g(){var g={};if(b=m,f.className=d.className,j=parseInt(n.css("maxHeight"),10),a.each(e,function(a,b){g[b]=n.css(b)}),a(f).css(g),c(),window.chrome){var h=m.style.width;m.style.width="0px";{m.offsetWidth}m.style.width=h}}function h(){var e,h;b!==m?g():c(),f.value=!m.value&&d.placeholder?(a(m).attr("placeholder")||"")+d.append:m.value+d.append,f.style.overflowY=m.style.overflowY,h=parseInt(m.style.height,10),f.scrollTop=0,f.scrollTop=9e4,e=f.scrollTop,j&&e>j?(m.style.overflowY="scroll",e=j):(m.style.overflowY="hidden",k>e&&(e=k)),e+=o,h!==e&&(m.style.height=e+"px",p&&d.callback.call(m,m))}function i(){clearTimeout(l),l=setTimeout(function(){var a=n.width();a!==r&&(r=a,h())},parseInt(d.resizeDelay,10))}var j,k,l,m=this,n=a(m),o=0,p=a.isFunction(d.callback),q={height:m.style.height,overflow:m.style.overflow,overflowY:m.style.overflowY,wordWrap:m.style.wordWrap,resize:m.style.resize},r=n.width();n.data("autosize")||(n.data("autosize",!0),("border-box"===n.css("box-sizing")||"border-box"===n.css("-moz-box-sizing")||"border-box"===n.css("-webkit-box-sizing"))&&(o=n.outerHeight()-n.height()),k=Math.max(parseInt(n.css("minHeight"),10)-o||0,n.height()),n.css({overflow:"hidden",overflowY:"hidden",wordWrap:"break-word",resize:"none"===n.css("resize")||"vertical"===n.css("resize")?"none":"horizontal"}),"onpropertychange"in m?"oninput"in m?n.on("input.autosize keyup.autosize",h):n.on("propertychange.autosize",function(){"value"===event.propertyName&&h()}):n.on("input.autosize",h),d.resizeDelay!==!1&&a(window).on("resize.autosize",i),n.on("autosize.resize",h),n.on("autosize.resizeIncludeStyle",function(){b=null,h()}),n.on("autosize.destroy",function(){b=null,clearTimeout(l),a(window).off("resize",i),n.off("autosize").off(".autosize").css(q).removeData("autosize")}),h())})):this}}(window.jQuery||window.$);
|
@ -11,5 +11,4 @@
|
||||
@import "mixins.less";
|
||||
@import "structure.less";
|
||||
@import "components.less";
|
||||
@import "tools.less";
|
||||
@import "highlight.less";
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* ===========================================================================================
|
||||
Markdown editor
|
||||
============================================================================================== */
|
||||
|
||||
.editor {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: white;
|
||||
padding: 20px;
|
||||
padding-bottom: 100px;
|
||||
min-height: 100%;
|
||||
height: auto;
|
||||
display: none;
|
||||
|
||||
h3 {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
&.paddingTop {
|
||||
padding-top: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
#markdown_editor {
|
||||
width: 85%;
|
||||
margin: 0 auto;
|
||||
padding: 10px;
|
||||
height: auto;
|
||||
font-size: 16px;
|
||||
min-height: 100px;
|
||||
font-family: "Ubuntu Mono", "Consolas", monospace;
|
||||
display: block;
|
||||
}
|
@ -6,7 +6,6 @@
|
||||
if ($page['breadcrumbs']) echo $this->get_breadcrumb_title($page, $base_page);
|
||||
else echo $page['title'];
|
||||
?>
|
||||
<?php if ($params['file_editor']) echo '<a href="javascript:;" id="editThis" class="btn">Edit this page</a>'; ?>
|
||||
</h1>
|
||||
<span style="float: left; font-size: 10px; color: gray;">
|
||||
<?php echo date("l, F j, Y", $page['modified_time']); ?>
|
||||
@ -21,23 +20,10 @@
|
||||
if ($page['breadcrumbs']) echo $this->get_breadcrumb_title($page, $base_page);
|
||||
else echo $page['title'];
|
||||
?>
|
||||
<?php if ($params['file_editor']) echo '<a href="javascript:;" id="editThis" class="btn">Edit this page</a>'; ?>
|
||||
</h1>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php echo $page['content']; ?>
|
||||
<?php if ($params['file_editor']) { ?>
|
||||
<div class="editor<?php if (!$params['date_modified']) echo ' paddingTop'; ?>">
|
||||
<h3>You are editing <?php echo $page['path']; ?> <a href="javascript:;" class="closeEditor btn btn-warning">Close</a></h3>
|
||||
<div class="navbar navbar-inverse navbar-default navbar-fixed-bottom" role="navigation">
|
||||
<div class="navbar-inner">
|
||||
<a href="javascript:;" class="save_editor btn btn-primary navbar-btn pull-right">Save file</a>
|
||||
</div>
|
||||
</div>
|
||||
<textarea id="markdown_editor"><?php echo $page['markdown']; ?></textarea>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</article>
|
||||
|
||||
|
@ -47,8 +47,6 @@
|
||||
<!-- JS -->
|
||||
<?php foreach ($params['theme']['js'] as $js) echo '<script src="' . $js . '"></script>'; ?>
|
||||
|
||||
<!-- Front end file editor -->
|
||||
<?php if ($params['file_editor']) echo '<script src="'. $base_url. 'resources/js/editor.js"></script>'; ?>
|
||||
<script src="<?php echo $base_url; ?>resources/js/custom.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
Laden…
Verwijs in nieuw issue
Block a user