Skip to content

Commit

Permalink
Fixed #3 and added Favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
koostudios committed May 3, 2012
1 parent 3d09553 commit 4894a8e
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 47 deletions.
36 changes: 18 additions & 18 deletions views/admin/editor.jade
Expand Up @@ -2,9 +2,9 @@ form#editor(method= 'post', action= '/admin/edit')
input#title(type= 'text', name= 'title', placeholder='Title', value= article.title)
.slugger
b= 'Slug: '
input(type= 'text', value= article._id, name= 'slug', disabled= 'true')
input(type= 'hidden', value= article._rev, name= 'rev')
input(type= 'hidden', value= article.status, name= 'status', value= 'published')
input#slug(type= 'text', value= article._id, name= 'slug', disabled= 'true')
input#rev(type= 'hidden', value= article._rev, name= 'rev')
input#status(type= 'hidden', value= article.status, name= 'status', value= 'published')
#fullscreen-area
.tray
.visual
Expand All @@ -31,28 +31,28 @@ form#editor(method= 'post', action= '/admin/edit')
button#img.edit(title= 'Image')
img(src= '/admin/img/tray/icon-img.png')

//
.toggle-fullscreen
button#fullscreen.other(title= 'Fullscreen')
img(src= '/admin/img/tray/icon-fullscreen.png')
.toggle-fullscreen
button#fullscreen.other(title= 'Fullscreen')
img(src= '/admin/img/tray/icon-fullscreen.png')

.toggle-mode
button#markdown.selected= 'Markdown'
button#preview= 'Preview'

textarea.editor-markdown(name= 'body')!= article.markdown
textarea.editor-markdown(name= 'body', id= article._id)!= article.markdown
.preview!= article.body
input#submit(type= "submit", value= "Publish")
input#status(type= 'checkbox')
#dialog
#dialog-title= 'Information'
#dialog-content
#dialog-body
#dialog-buttons
button#dialog-cancel.dialog-button= 'Cancel'
button#dialog-ok.dialog-button= 'Ok'
#overlay
input#go(type= 'submit', value= 'Publish')
input#status-check(type= 'checkbox')
span= 'Draft'
#dialog
#dialog-title= 'Information'
#dialog-content
#dialog-body
#dialog-buttons
button#dialog-cancel.dialog-button= 'Cancel'
button#dialog-ok.dialog-button= 'Ok'
#overlay

script(type= 'text/javascript', src= 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js')
script(type= 'text/javascript', src= '/admin/js/showdown.js')
script(type= 'text/javascript', src= '/admin/js/cushy.dialog.js')
Expand Down
5 changes: 2 additions & 3 deletions views/admin/posts.jade
@@ -1,7 +1,6 @@
form(method= 'post', action= '/admin/new', id= 'newtitle')
input(type= 'text', placeholder= 'A new idea here...', name= 'title')
- if(typeof(articles) != 'undefined')
form(method= 'post', action= '/admin/new', id= 'newtitle')
input(type= 'text', placeholder= 'A new idea here...', name= 'title')

- each article in articles
.article
- var link = 'admin/edit/' + article._id
Expand Down
6 changes: 3 additions & 3 deletions views/admin/public/css/style.css
Expand Up @@ -404,7 +404,7 @@ form input {
font-family: 'Consolas';
}

form#editor #submit {
form#editor #go {
display: inline;
padding: 10px 15px;
width: 100px;
Expand All @@ -415,11 +415,11 @@ form input {
box-shadow: inset 0 1px 1px #FFF;
}

form#editor #submit:hover {
form#editor #go:hover {
background: #EEE;
}

form#editor #submit:active {
form#editor #go:active {
background: #555;
color: #FFF;
box-shadow: inset 0 1px 1px #222;
Expand Down
9 changes: 6 additions & 3 deletions views/admin/public/js/cushy.dialog.js
Expand Up @@ -13,14 +13,17 @@ MIT License
var Dialog;
Dialog = {
attachEvents: function(ok) {
$('#dialog-ok').on('click', ok);
$('#dialog-cancel').on('click', Dialog.hide);
return $('#dialog-body input').keydown(function(e) {
$('#dialog-ok').on('click', function(e) {
e.preventDefault && e.preventDefault();
return ok();
});
$('#dialog-body input').keydown(function(e) {
if (e.keyCode === 13) {
e.preventDefault && e.preventDefault();
return ok();
}
});
return $('#dialog-cancel').on('click', Dialog.hide);
},
createFields: function(obj) {
var field, html, _i, _len;
Expand Down
86 changes: 66 additions & 20 deletions views/admin/public/js/editor.js
Expand Up @@ -10,7 +10,7 @@ MIT License
(function() {

$(function() {
var Editor, markdown;
var Draft, Editor, markdown;
markdown = {
'bold': {
search: /([^\n]+)([\n\s]*)/g,
Expand Down Expand Up @@ -56,7 +56,7 @@ MIT License
type: 'text'
}
],
ok: function() {
ok: function(e) {
var text;
text = '[' + $('#dialog-text').val() + '](' + $('#dialog-url').val() + ')';
Editor.add(text);
Expand Down Expand Up @@ -135,11 +135,56 @@ MIT License
};
}
};
Draft = {
slug: $('.editor-markdown').attr('id'),
load: function() {
var md, slug, title;
slug = Draft.slug;
title = localStorage[slug + '.title'];
md = localStorage[slug + '.markdown'];
if ((title !== '' && title !== $('#title').val()) || (md !== '' && md !== $('.editor-markdown').val())) {
return $.Dialog.init({
title: 'Load Draft',
body: 'There seems to be a newer, autosaved version of this post last edited at ' + localStorage[slug + '.time'] + '. Would you like to load it?',
ok: function() {
if (title) $('#title').val(title);
if (md) $('.editor-markdown').val(md);
if (localStorage[slug + '.slug']) {
$('#slug').val(localStorage[slug + '.slug']);
}
return $.Dialog.hide();
}
});
}
},
save: function() {
var slug;
slug = Draft.slug;
localStorage[slug + '.title'] = $('#title').val();
localStorage[slug + '.slug'] = $('#slug').val();
localStorage[slug + '.markdown'] = $('.editor-markdown').val();
localStorage[slug + '.time'] = new Date();
return console.log('Draft saved at ' + new Date());
},
clear: function() {
var slug;
slug = Draft.slug;
localStorage[slug + '.title'] = '';
localStorage[slug + '.slug'] = '';
localStorage[slug + '.markdown'] = '';
return localStorage[slug + '.time'] = '';
}
};
Draft.load();
setInterval(Draft.save, 30000);
$('#dialog-buttons button').on('click', function(e) {
return e.preventDefault && e.preventDefault();
});
$('.edit').on('click', function(e) {
var func, pos, text;
e.preventDefault && e.preventDefault();
pos = Editor.getPosition(Editor.elem);
text = Editor.elem.val().substring(pos.start, pos.end);
e.preventDefault && e.preventDefault();
if ($(this).attr('id')) {
func = markdown[$(this).attr('id')];
if (typeof func.exec === 'object') {
Expand All @@ -153,20 +198,16 @@ MIT License
}
}
});
/*
Fullscreen not supported yet
$('#fullscreen').on 'click', (e) ->
e.preventDefault && e.preventDefault()
if $(this).hasClass 'selected'
document.webkitCancelFullScreen()
$(this)
.removeClass('selected').children('img').attr('src', '/admin/img/tray/icon-fullscreen.png')
else
document.getElementById('fullscreen-area').webkitRequestFullScreen Element.ALLOW_KEYBOARD_INPUT
$(this)
.addClass('selected')
.children('img').attr('src', '/admin/img/tray/icon-fullscreen-selected.png')
*/
$('#fullscreen').on('click', function(e) {
e.preventDefault && e.preventDefault();
if ($(this).hasClass('selected')) {
document.webkitCancelFullScreen();
return $(this).removeClass('selected').children('img').attr('src', '/admin/img/tray/icon-fullscreen.png');
} else {
document.getElementById('fullscreen-area').webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
return $(this).addClass('selected').children('img').attr('src', '/admin/img/tray/icon-fullscreen-selected.png');
}
});
$('.toggle-mode button').on('click', function(e) {
var converter;
e.preventDefault && e.preventDefault();
Expand All @@ -192,15 +233,20 @@ MIT License
$('#overlay').on('click', function() {
return $.Dialog.hide();
});
return $('#status').on('change', function() {
$('#status-check').on('change', function() {
if ($(this).is(':checked')) {
$('#submit').val('Save');
$('#go').val('Save');
return $('input[name=status]').val('draft');
} else {
$('#submit').val('Publish');
$('#go').val('Publish');
return $('input[name=status]').val('published');
}
});
return $('#go').on('click', function(e) {
e.preventDefault && e.preventDefault();
Draft.clear();
return $('#editor').submit();
});
});

}).call(this);
1 change: 1 addition & 0 deletions views/soothe/layout.jade
Expand Up @@ -4,6 +4,7 @@ html(lang="en")
title= title
meta(name= 'description', content= config.site.description)
meta(name= 'viewport', content= "width=device-width, initial-scale=0.5, user-scalable=yes")
link(rel= 'shortcut icon', href='/favicon.ico')
link(rel= 'stylesheet', href= '/css/style.css')
body
header
Expand Down
Binary file added views/soothe/public/favicon.ico
Binary file not shown.

0 comments on commit 4894a8e

Please sign in to comment.