Change admin panel

Change admin panel.
This commit is contained in:
Danang Probo Sayekti 2014-01-29 10:30:45 +07:00
commit cdf2a4dd2b
49 changed files with 1988 additions and 1199 deletions

228
system/admin/admin.php Normal file
View file

@ -0,0 +1,228 @@
<?php
function user($key, $user=null) {
$value = 'config/users/' . $user . '.ini';
static $_config = array();
if (file_exists($value)) {
$_config = parse_ini_file($value, true);
return $_config[$key];
}
}
function login_message($str = null) {
echo $str;
}
function session($user, $pass) {
$user_file = 'config/users/' . $user . '.ini';
$user_pass = user('password', $user);
if(file_exists($user_file)) {
if($pass === $user_pass) {
$_SESSION['user'] = $user;
header('location: admin');
}
else {
$str = '<div style="text-align:center;padding-top:50px;"><h1>Your username and password are wrong.</h1><p><a href="' . site_url() . 'login">Back</a></p></div>';
login_message($str);
}
}
else {
$str = '<div style="text-align:center;padding-top:50px;"><h1>Username not found in our record.</h1><p><a href="' . site_url() . 'login">Back</a></p></div>';
login_message($str);
}
}
function edit_post($title, $tag, $url, $content, $oldfile) {
$oldurl = explode('_', $oldfile);
$post_title = $title;
$post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tag);
$post_tag = rtrim($post_tag, ',\.\-');
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url);
$post_url = rtrim($post_url, ',\.\-');
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
if(get_magic_quotes_gpc()) {
$post_content = stripslashes($post_content);
}
$newfile = $oldurl[0] . '_' . $post_tag . '_' . $post_url . '.md';
if($oldfile === $newfile) {
file_put_contents($oldfile, print_r($post_content, true));
}
else {
rename($oldfile, $newfile);
file_put_contents($newfile, print_r($post_content, true));
}
$redirect = site_url() . 'admin/posts';
header("Location: $redirect");
}
}
function edit_page($title, $url, $content, $oldfile) {
$dir = substr($oldfile, 0, strrpos($oldfile, '/'));
$post_title = $title;
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url);
$post_url = rtrim($post_url, ',\.\-');
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_url) && !empty($post_content)) {
if(get_magic_quotes_gpc()) {
$post_content = stripslashes($post_content);
}
$newfile = $dir . '/' . $post_url . '.md';
if($oldfile === $newfile) {
file_put_contents($oldfile, print_r($post_content, true));
}
else {
rename($oldfile, $newfile);
file_put_contents($newfile, print_r($post_content, true));
}
$redirect = site_url() . 'admin';
header("Location: $redirect");
}
}
function add_post($title, $tag, $url, $content, $user) {
$post_date = date('Y-m-d-H-i');
$post_title = $title;
$post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tag);
$post_tag = rtrim($post_tag, ',\.\-');
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url);
$post_url = rtrim($post_url, ',\.\-');
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
if(get_magic_quotes_gpc()) {
$post_content = stripslashes($post_content);
}
$filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md';
$dir = 'content/' . $user. '/blog/';
if(is_dir($dir)) {
file_put_contents($dir . $filename, print_r($post_content, true));
}
else {
mkdir($dir, 0777, true);
file_put_contents($dir . $filename, print_r($post_content, true));
}
$redirect = site_url() . 'admin/posts';
header("Location: $redirect");
}
}
function add_page($title, $url, $content) {
$post_title = $title;
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url);
$post_url = rtrim($post_url, ',\.\-');
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_url) && !empty($post_content)) {
if(get_magic_quotes_gpc()) {
$post_content = stripslashes($post_content);
}
$filename = $post_url . '.md';
$dir = 'content/static/';
if(is_dir($dir)) {
file_put_contents($dir . $filename, print_r($post_content, true));
}
else {
mkdir($dir, 0777, true);
file_put_contents($dir . $filename, print_r($post_content, true));
}
$redirect = site_url() . 'admin';
header("Location: $redirect");
}
}
function delete_post($file) {
$deleted_content = $file;
if(!empty($deleted_content)) {
unlink($deleted_content);
$redirect = site_url() . 'admin/posts';
header("Location: $redirect");
}
}
function delete_page($file) {
$deleted_content = $file;
if(!empty($deleted_content)) {
unlink($deleted_content);
$redirect = site_url() . 'admin';
header("Location: $redirect");
}
}
function edit_profile($title, $content, $user) {
$user_title = $title;
$user_content = '<!--t ' . $user_title . ' t-->' . "\n\n" . $content;
if(!empty($user_title) && !empty($user_content)) {
if(get_magic_quotes_gpc()) {
$user_content = stripslashes($user_content);
}
$dir = 'content/' . $user. '/';
$filename = 'content/' . $user . '/author.md';
if(is_dir($dir)) {
file_put_contents($filename, print_r($user_content, true));
}
else {
mkdir($dir, 0777, true);
file_put_contents($filename, print_r($user_content, true));
}
$redirect = site_url() . 'admin';
header("Location: $redirect");
}
}
function get_recent_posts() {
if (isset($_SESSION['user'])) {
$posts = get_profile($_SESSION['user'], 1, 5);
if(!empty($posts)) {
echo '<table>';
echo '<tr><th>Title</th><th>Published</th><th>Tag</th><th>Operations</th></tr>';
foreach($posts as $p) {
echo '<tr>';
echo '<td>' . $p->title . '</td>';
echo '<td>' . date('d F Y', $p->date) . '</td>';
echo '<td>' . $p->tag . '</td>';
echo '<td><a href="' . $p->url . '/edit">Edit</a> <a href="' . $p->url . '/delete">Delete</a></td>';
echo '</tr>';
}
echo '</table>';
}
}
}
// Auto generate menu from static page
function get_recent_pages() {
if (isset($_SESSION['user'])) {
$posts = get_static_post(null);
krsort($posts);
echo '<table>';
echo '<tr><th>Title</th><th>Operations</th></tr>';
foreach($posts as $p) {
echo '<tr>';
echo '<td>' . $p->title . '</td>';
echo '<td><a href="' . $p->url . '/edit">Edit</a> <a href="' . $p->url . '/delete">Delete</a></td>';
echo '</tr>';
}
echo '</table>';
}
}

View file

@ -0,0 +1,32 @@
A javascript port of Markdown, as used on Stack Overflow
and the rest of Stack Exchange network.
Largely based on showdown.js by John Fraser (Attacklab).
Original Markdown Copyright (c) 2004-2005 John Gruber
<http://daringfireball.net/projects/markdown/>
Original Showdown code copyright (c) 2007 John Fraser
Modifications and bugfixes (c) 2009 Dana Robinson
Modifications and bugfixes (c) 2009-2013 Stack Exchange Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

View file

@ -0,0 +1,146 @@
body {
font-family: sans-serif;
}
blockquote {
border-left: 2px dotted #888;
padding-left: 5px;
background: #d0f0ff;
}
.wmd-panel{
width: 44%;
float:left;
padding-right:20px;
}
.wmd-button-bar {
background-color: #FEFEFE;
padding: 5px 0;
margin-bottom:10px;
width: 100%;
}
.wmd-input {
min-height: 300px;
width: 96%;
background-color: #FFFFFF;
border:none;
padding: 2%;
}
.wmd-preview {
background-color: #c0e0ff;
width: 46%;
float:left;
padding:2%;
}
.wmd-button-row {
position: relative;
margin:0px;
padding: 0px;
height: 20px;
}
.wmd-spacer{
width: 1px;
height: 20px;
margin-left: 14px;
position: absolute;
background-color: Silver;
display: inline-block;
list-style: none;
}
.wmd-button {
width: 20px;
height: 20px;
padding-left: 2px;
padding-right: 3px;
position: absolute;
display: inline-block;
list-style: none;
cursor: pointer;
}
.wmd-button > span {
background-image: url(../img/wmd-buttons.png);
background-repeat: no-repeat;
background-position: 0px 0px;
width: 20px;
height: 20px;
display: inline-block;
}
.wmd-spacer1{
left: 50px;
}
.wmd-spacer2{
left: 175px;
}
.wmd-spacer3{
left: 300px;
}
.wmd-prompt-background{
background-color: Black;
}
.wmd-prompt-dialog{
border: 1px solid #999999;
background-color: #F5F5F5;
}
.wmd-prompt-dialog > div {
font-size: 0.8em;
font-family: arial, helvetica, sans-serif;
}
.wmd-prompt-dialog > form > input[type="text"] {
border: 1px solid #999999;
color: black;
}
.wmd-prompt-dialog > form > input[type="button"]{
border: 1px solid #888888;
font-family: trebuchet MS, helvetica, sans-serif;
font-size: 0.8em;
font-weight: bold;
}
pre {
margin: 1em 0;
overflow: auto;
background: #F1F1FF;
}
pre code {
color: #333333;
display: block;
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
font-size: 14px;
padding: 5px 10px;
}
@media all and (max-width: 980px) {
.nav {
width: 100%;
padding: 2%;
}
.wmd-panel, .wmd-preview {
width: 96%;
float:left;
padding:2%;
}
pre {
white-space: pre-wrap;
word-wrap:break-word;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,108 @@
(function () {
var output, Converter;
if (typeof exports === "object" && typeof require === "function") { // we're in a CommonJS (e.g. Node.js) module
output = exports;
Converter = require("./Markdown.Converter").Converter;
} else {
output = window.Markdown;
Converter = output.Converter;
}
output.getSanitizingConverter = function () {
var converter = new Converter();
converter.hooks.chain("postConversion", sanitizeHtml);
converter.hooks.chain("postConversion", balanceTags);
return converter;
}
function sanitizeHtml(html) {
return html.replace(/<[^>]*>?/gi, sanitizeTag);
}
// (tags that can be opened/closed) | (tags that stand alone)
var basic_tag_whitelist = /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i;
// <a href="url..." optional title>|</a>
var a_white = /^(<a\shref="((https?|ftp):\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i;
// <img src="url..." optional width optional height optional alt optional title
var img_white = /^(<img\ssrc="(https?:\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i;
function sanitizeTag(tag) {
if (tag.match(basic_tag_whitelist) || tag.match(a_white) || tag.match(img_white))
return tag;
else
return "";
}
/// <summary>
/// attempt to balance HTML tags in the html string
/// by removing any unmatched opening or closing tags
/// IMPORTANT: we *assume* HTML has *already* been
/// sanitized and is safe/sane before balancing!
///
/// adapted from CODESNIPPET: A8591DBA-D1D3-11DE-947C-BA5556D89593
/// </summary>
function balanceTags(html) {
if (html == "")
return "";
var re = /<\/?\w+[^>]*(\s|$|>)/g;
// convert everything to lower case; this makes
// our case insensitive comparisons easier
var tags = html.toLowerCase().match(re);
// no HTML tags present? nothing to do; exit now
var tagcount = (tags || []).length;
if (tagcount == 0)
return html;
var tagname, tag;
var ignoredtags = "<p><img><br><li><hr>";
var match;
var tagpaired = [];
var tagremove = [];
var needsRemoval = false;
// loop through matched tags in forward order
for (var ctag = 0; ctag < tagcount; ctag++) {
tagname = tags[ctag].replace(/<\/?(\w+).*/, "$1");
// skip any already paired tags
// and skip tags in our ignore list; assume they're self-closed
if (tagpaired[ctag] || ignoredtags.search("<" + tagname + ">") > -1)
continue;
tag = tags[ctag];
match = -1;
if (!/^<\//.test(tag)) {
// this is an opening tag
// search forwards (next tags), look for closing tags
for (var ntag = ctag + 1; ntag < tagcount; ntag++) {
if (!tagpaired[ntag] && tags[ntag] == "</" + tagname + ">") {
match = ntag;
break;
}
}
}
if (match == -1)
needsRemoval = tagremove[ctag] = true; // mark for removal
else
tagpaired[match] = true; // mark paired
}
if (!needsRemoval)
return html;
// delete all orphaned tags from the string
var ctag = 0;
html = html.replace(re, function (match) {
var res = tagremove[ctag] ? "" : match;
ctag++;
return res;
});
return html;
}
})();

View file

@ -0,0 +1,43 @@
// Usage:
//
// var myConverter = new Markdown.Editor(myConverter, null, { strings: Markdown.local.fr });
(function () {
Markdown.local = Markdown.local || {};
Markdown.local.fr = {
bold: "Gras <strong> Ctrl+B",
boldexample: "texte en gras",
italic: "Italique <em> Ctrl+I",
italicexample: "texte en italique",
link: "Hyperlien <a> Ctrl+L",
linkdescription: "description de l'hyperlien",
linkdialog: "<p><b>Insérer un hyperlien</b></p><p>http://example.com/ \"titre optionnel\"</p>",
quote: "Citation <blockquote> Ctrl+Q",
quoteexample: "Citation",
code: "Extrait de code <pre><code> Ctrl+K",
codeexample: "votre extrait de code",
image: "Image <img> Ctrl+G",
imagedescription: "description de l'image",
imagedialog: "<p><b>Insérer une image</b></p><p>http://example.com/images/diagram.jpg \"titre optionnel\"<br><br><a href='http://www.google.com/search?q=free+image+hosting' target='_blank'>Vous chercher un hébergement d'image grauit ?</a></p>",
olist: "Liste numérotée <ol> Ctrl+O",
ulist: "Liste à point <ul> Ctrl+U",
litem: "Elément de liste",
heading: "Titre <h1>/<h2> Ctrl+H",
headingexample: "Titre",
hr: "Trait horizontal <hr> Ctrl+R",
undo: "Annuler - Ctrl+Z",
redo: "Refaire - Ctrl+Y",
redomac: "Refaire - Ctrl+Shift+Z",
help: "Aide sur Markdown"
};
})();

View file

@ -0,0 +1,2 @@
exports.Converter = require("./Markdown.Converter").Converter;
exports.getSanitizingConverter = require("./Markdown.Sanitizer").getSanitizingConverter;

View file

@ -0,0 +1,12 @@
{
"name": "pagedown",
"version": "1.1.0",
"description": "markdown converter, based on showdown",
"repository": { "type": "hg", "url": "https://code.google.com/p/pagedown/" },
"keywords": ["markdown"],
"license": "MIT",
"files": ["Markdown.Converter.js", "Markdown.Sanitizer.js", "node-pagedown.js"],
"main": "node-pagedown.js",
"bugs": "http://code.google.com/p/pagedown/issues/list",
"homepage": "http://code.google.com/p/pagedown/wiki/PageDown"
}

View file

@ -0,0 +1,23 @@
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css" />
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<div class="wmd-panel">
<form method="POST">
Title: <br><input type="text" class="text" name="title"/><br><br>
Url: <br><input type="text" class="text" name="url"/><br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"></textarea><br/>
<input type="submit" name="submit" class="submit" value="Publish"/>
</form>
</div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript">
(function () {
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter);
editor.run();
})();
</script>

View file

@ -0,0 +1,24 @@
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css" />
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<div class="wmd-panel">
<form method="POST">
Title: <br><input type="text" class="text" name="title"/><br><br>
Tag: <br><input type="text" class="text" name="tag"/><br><br>
Url: <br><input type="text" class="text" name="url"/><br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"></textarea><br/>
<input type="submit" name="submit" class="submit" value="Publish"/>
</form>
</div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript">
(function () {
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter);
editor.run();
})();
</script>

View file

@ -0,0 +1,820 @@
/*-------------------------
Simple reset
--------------------------*/
*{
margin:0;
padding:0;
}
body {
font-family: Georgia, sans-serif, Arial;
font-size: 17px;
line-height: 1.6;
color: #343A3F;
padding: 0;
margin: 0;
}
section, footer, header, aside, nav{
display: block;
}
img {
border: 0 none;
height: auto;
max-width: 100%;
outline: 0 none;
}
/*-------------------------
Heading
--------------------------*/
h1, h2, h3, h4, h5, h6 {
font-family: 'Open Sans',sans-serif;
line-height: 1.3;
margin: 0.5em 0;
}
h1 {
font-size: 28px;
}
h2 {
font-size: 24px;
}
h3 {
font-size: 18px;
}
h4 {
font-size: 16px;
}
h5 {
font-size: 14px;
}
h6 {
font-size: 12px;
}
/*-------------------------
Toolbar
--------------------------*/
#toolbar {
background: none repeat scroll 0 0 #666666;
box-shadow: 0 3px 20px #000000;
color: #CCCCCC;
font-family: 'Open Sans',sans-serif;
left: 0;
margin: 0 -20px;
padding: 0 25px;
position: fixed;
right: 0;
top: 0;
z-index: 600;
border: 0 none;
font-size: 15px;
text-align: left;
vertical-align: baseline;
}
#toolbar ul {
margin:0;
}
#toolbar ul li, #toolbar ul li a {
float: left;
list-style: none outside none;
}
#toolbar a {
color: #FFFFFF;
font-size: 0.846em;
text-decoration: none;
border-radius: 10px;
padding: 0 10px;
}
/*-------------------------
Layout
--------------------------*/
#outer-wrapper {
margin:0;
padding:0;
float:left;
width: 100%;
}
#inner-wrapper {
padding: 0 10px;
}
.container {
padding: 0 20px;
}
#header-wrapper {
background: #546673;
position:relative;
padding: 1em 0;
float:left;
width: 100%;
color: #ffffff;
font-family: Georgia, sans-serif;
font-style:italic;
}
#content-wrapper {
float:left;
width: 100%;
padding: 3em 0;
background-color: #FAFAFA;
}
#menu, #header, #content, #footer {
width: 980px;
margin: 0 auto;
}
#header {
text-align:center;
}
.hide {
display:none;
}
.wmd-panel {
display:table-row;
}
/*-------------------------
Link
--------------------------*/
a, a:visited {
outline:none;
color:#2E9FFF;
text-decoration:none;
}
a:hover{
text-decoration:underline;
}
/*-------------------------
Text element
--------------------------*/
blockquote:before {
color: #BBBBBB;
content: "“";
font-size: 3em;
line-height: 0.1em;
margin-right: 0.2em;
vertical-align: -0.4em;
}
blockquote:after {
color: #BBBBBB;
content: "”";
font-size: 3em;
line-height: 0.1em;
vertical-align: -0.45em;
}
blockquote {
font-style: italic;
margin: 1em 0 1em 1em;
}
blockquote p {
display:inline;
}
pre {
margin: 1em 0;
overflow: auto;
background: #F1F1FF;
}
code {
color: #333333;
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
font-size: 15px;
padding: 5px 10px;
background: #F1F1FF;
}
pre code {
color: #333333;
display: block;
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
font-size: 14px;
padding: 5px 10px;
}
.thumbnail {
float: left;
height: 80px;
width: 80px;
margin: 5px 15px 0 0;
overflow: hidden;
display: block;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
ul, ol {
padding-left: 30px;
margin: 1em 0;
}
ul li, ol li{
margin: 0.25em 0;
}
input.text, input.password {
width: 75%;
}
/*-------------------------
Table
--------------------------*/
table {
font-size:12px;
border: none;
width:100%;
color:#333333;
border: 1px solid #E3E3E3;
margin: 1em 0;
}
table h2.title {
margin:5px 0;
}
th, td {
padding: 5px 10px;
border: none;
}
th.title {
margin:5px 0;
font-family: 'Open Sans',sans-serif;
font-size:16px;
font-weight:normal;
}
td.title {
font-weight:normal;
background-color: #f6f6f6;
font-family: 'Open Sans',sans-serif;
}
th {
background-color: #f6f6f6;
border-bottom: 1px solid #E3E3E3;
border-right: 1px solid #E3E3E3;
font-family: 'Open Sans',sans-serif;
font-size:16px;
}
td {
background-color: #fafafa;
border: 1px solid #E3E3E3;
border-top: none;
border-left:none;
}
/*-------------------------
Menu
--------------------------*/
#menu-wrapper {
font-family: 'Open Sans',sans-serif;
color: #7E909D;
padding: 10px 0;
float:left;
width:100%;
}
#menu {
font-weight:bold;
font-family: 'Open Sans',sans-serif;
color: #7E909D;
font-size: 14px;
}
#menu ul {
margin:0;
padding:0;
}
#menu a {
color: #7E909D;
}
#menu ul li {
float:left;
margin:0 20px 0 0;
list-style:none;
padding-top:3px;
}
#menu ul li:last-child {
margin:0;
}
/*----------------------------
Search form
-----------------------------*/
#search-form {
position:relative;
float:right;
}
.search-input{
margin: 0;
padding: 4px 15px;
font-size:14px;
border:1px solid #0076a3;
border-top-left-radius: 5px 5px;
border-bottom-left-radius: 5px 5px;
width: 120px;
color: #888888;
}
.search-button {
margin: 0;
padding: 4px;
font-size:14px;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
color: #ffffff;
border: solid 1px #546673;
border-right:0px;
background: #0095cd;
background: -webkit-gradient(linear, left top, left bottom, from(#2E9FFF), to(#2E9CCC));
background: -moz-linear-gradient(top, #2E9FFF, #2E9CCC);
border-top-right-radius: 5px 5px;
border-bottom-right-radius: 5px 5px;
width: 60px;
}
.search-button:hover {
text-decoration: none;
background: #007ead;
background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
background: -moz-linear-gradient(top, #0095cc, #00678e);
}
/* Fixes submit button height problem in Firefox */
.search-button::-moz-focus-inner {
border: 0;
}
/*-------------------------
Post
--------------------------*/
.post {
border-bottom: 1px solid #EBF2F6;
padding: 1em 0;
float: left;
width: 100%;
}
.inpost .post {
padding-bottom: 0;
}
p, ul {
margin :1em 0;
}
.breadcrumb {
font-family: 'Open Sans',sans-serif;
font-size: 14px;
font-weight:normal;
}
.date {
font-family: 'Open Sans',sans-serif;
font-size: 14px;
color: #A7A7A7;
font-weight:normal;
margin:1em 0;
}
h1.blog-title {
font-style:normal;
}
h1.title-post a, h2.title-index a{
color:#4f4f4f;
text-decoration: none;
}
h1.title-post a:hover, h2.title-index a:hover {
color: #2E9FFF;
}
.inpost .post {
padding-top:0;
border: none;
}
.inpage .border {
padding:0;
margin:0;
border:0;
}
.inpage .post {
padding-top:0;
}
.infront .first, .inpost .post, .intag .first, .inarchive .first, .insearch .first {
padding-top:0;
}
.infront .first h2.title-index {
margin-top:0;
}
.inprofile .bio {
font-size: 14px;
font-style:italic;
border-bottom: 1px solid #EBF2F6;
padding-bottom: 1em;
margin-bottom: 2em;
}
.post-list {
font-size: 14px;
}
/*-------------------------
Comments
--------------------------*/
.comments {
position:relative;
display:block;
font-size:16px;
float:left;
width:100%;
}
.border {
border-top: 1px solid #DFDFDF;
margin-bottom: 15px;
margin-top: 10px;
padding-bottom: 15px;
width: 100%;
float:left;
}
.border #disqus_thread {
padding-top: 1.2em;
}
#disqus_thread {
font-family: Georgia, Times, Cambria, serif;
float:left;
width:100%;
}
/*-------------------------
Raleted posts
--------------------------*/
.related {
font-size: 14px;
font-family: 'Open Sans',sans-serif;
width:100%;
float:left;
margin-bottom: 1em;
}
.related ul {
margin:0;
}
/*-------------------------
Pagination + Postnav
--------------------------*/
.postnav{
width:100%;
float:left;
padding-bottom:1em;
font-family: 'Open Sans',sans-serif;
font-size: 12px;
font-weight:bold;
}
.postnav a {
background: none repeat scroll 0 0 #E4E7EE;
border-radius: 3px;
color: #555555;
line-height: 1;
text-align: center;
}
.postnav a:hover {
text-decoration:none;
color:#333333;
}
.postnav .newer {
float:left;
margin-right:1em;
margin-bottom:0.1em;
padding: 10px 15px 10px 25px;
}
.postnav .older {
float:right;
padding: 10px 25px 10px 15px;
}
.postnav .pagination-arrow{
display: inline-block;
border-radius: 3px;
color: #555 !important;
text-decoration: none !important;
text-transform: none;
position: relative;
}
.postnav .pagination-arrow.newer:before,
.postnav .pagination-arrow.older:before{
content: '';
border: 5px solid #555;
border-color: transparent #555 transparent transparent;
width: 0;
height: 0;
position: absolute;
left: 5px;
top: 12px;
}
.postnav .pagination-arrow.older:before{
left:auto;
right:5px;
border-color: transparent transparent transparent #555;
}
.pager {
width:100%;
float:left;
padding: 30px 0 1em 0;
font-family: 'Open Sans',sans-serif;
font-size: 12px;
font-weight:bold;
}
.pager a {
background: none repeat scroll 0 0 #E4E7EE;
border-radius: 3px;
color: #555555;
line-height: 1;
padding: 10px 20px;
text-align: center;
}
.pager .newer {
float:left;
}
.pager .older {
float:right;
}
.pager a:hover {
text-decoration:none;
color:#333333;
}
/*-------------------------
Footer
--------------------------*/
#footer-wrapper {
background: #546673;
position:relative;
padding: 20px 0;
float:left;
width: 100%;
color: #ABB6C5;
font-family: 'Open Sans', sans-serif;
}
#footer {
font-size: 14px;
}
#footer a {
color: #CBD2DC;
font-weight:bold;
}
#footer ul {
margin:0.5em 0;
}
.footer-column {
padding-bottom: 1.5em;
float:left;
width:100%;
}
.column {
float: left;
width: 33%;
}
.social {
float:right;
}
.social .inner {
padding-left:30px;
}
.tagcloud ul {
padding:0;
margin:0;
}
.tagcloud ul li {
float:left;
list-style:none;
margin-right: 10px;
}
.copyright {
font-size: 12px;
float:left;
width: 100%;
border-top: 1px solid #ABB6C5;
padding-top:1em;
}
.copyright p {
margin: 0.5em 0;
line-height: 1.2;
}
/*----------------------------
The 404 page
-----------------------------*/
.message{
padding:50px 20px 20px 20px;
}
.message h1{
font-size:36px;
margin-bottom: 18px;
}
.message p{
font-size:13px;
}
.center{
text-align:center;
}
.search-404 {
position:relative;
float:left;
width:100%;
margin-bottom: 1.2em;
}
.search-404 #search-form {
float:none;
}
/*----------------------------
Media queries
-----------------------------*/
@media all and (max-width: 700px) {
#menu, #header, #content, #footer {
margin: 0 auto;
width: 100%;
}
#menu-wrapper {
text-align:center;
}
#menu ul li {
float:none;
display:inline-block;
}
#search-form {
float:none;
padding: 10px 0;
}
.author-info {
width: 100%;
float:left;
}
.share {
width:100%;
margin-right: 0;
padding-bottom: 1em;
}
.column {
float:left;
width:100%;
}
.postnav .newer {
float:left;
margin-bottom:1em;
}
.postnav .older {
float:left;
}
.social .inner {
padding-left:0px;
}
pre {
white-space: pre-wrap;
word-wrap:break-word;
}
}
/*----------------------------
Video
-----------------------------*/
.video-wrapper {
margin:1em 0;
}
@media all and (min-width: 420px) {
.video-wrapper {
padding-top:315px!important;
position:relative;
width:100%;
max-width:420px!important;
max-height:315px!important;
}
.video-wrapper iframe, .video-wrapper object, .video-wrapper embed {
height: 100%;
left: 0;
position: absolute;
top: 0;
max-width:420px!important;
width: 100%;
max-height:315px!important;
}
}
@media all and (max-width: 420px) {
.video-wrapper {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.video-wrapper iframe, .video-wrapper object, .video-wrapper embed {
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
}

View file

@ -0,0 +1,6 @@
<?php echo '<p>Are you sure want to delete <strong>' . $p->title . '</strong>?</p>';?>
<form method="POST">
<input type="hidden" name="file" value="<?php echo $p->file ?>"/><br>
<input type="submit" name="submit" value="Delete"/>
<span><a href="<?php echo site_url() . 'admin' ?>">Cancel</a></span>
</form>

View file

@ -0,0 +1,6 @@
<?php echo '<p>Are you sure want to delete <strong>' . $p->title . '</strong>?</p>';?>
<form method="POST">
<input type="hidden" name="file" value="<?php echo $p->file ?>"/><br>
<input type="submit" name="submit" value="Delete"/>
<span><a href="<?php echo site_url() . 'admin/posts' ?>">Cancel</a></span>
</form>

View file

@ -0,0 +1,43 @@
<?php
$url = $p->file;
$content = file_get_contents($url);
$arr = explode('t-->', $content);
if(isset($arr[1])) {
$oldtitle = ltrim(rtrim(str_replace('<!--t','',$arr[0]), ' '));
$oldcontent = ltrim($arr[1]);
}
else {
$oldtitle = 'Untitled';
$oldcontent = ltrim($arr[0]);
}
$dir = substr($url, 0, strrpos($url, '/'));
$oldurl = str_replace($dir . '/','',$url);
$oldmd = str_replace('.md','',$oldurl);
?>
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css" />
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<div class="wmd-panel">
<form method="POST">
Title: <br><input type="text" name="title" class="text" value="<?php echo $oldtitle?>"/><br><br>
Url: <br><input type="text" name="url" class="text" value="<?php echo $oldmd ?>"/><br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br>
<input type="hidden" name="oldfile" class="text" value="<?php echo $url ?>"/>
<input type="submit" name="submit" class="submit" value="Submit"/>
</form>
</div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript">
(function () {
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter);
editor.run();
})();
</script>

View file

@ -0,0 +1,47 @@
<?php
$url = $p->file;
$content = file_get_contents($url);
$arr = explode('t-->', $content);
if(isset($arr[1])) {
$oldtitle = ltrim(rtrim(str_replace('<!--t','',$arr[0]), ' '));
$oldcontent = ltrim($arr[1]);
}
else {
$oldtitle = 'Untitled';
$oldcontent = ltrim($arr[0]);
}
$dir = substr($url, 0, strrpos($url, '/'));
$oldurl = explode('_', $url);
$oldtag = $oldurl[1];
$oldmd = str_replace('.md','',$oldurl[2]);
?>
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css" />
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<div class="wmd-panel">
<form method="POST">
Title: <br><input type="text" name="title" class="text" value="<?php echo $oldtitle?>"/><br><br>
Tag: <br><input type="text" name="tag" class="text" value="<?php echo $oldtag?>"/><br><br>
Url: <br><input type="text" name="url" class="text" value="<?php echo $oldmd ?>"/><br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br>
<input type="hidden" name="oldfile" class="text" value="<?php echo $url ?>"/>
<input type="submit" name="submit" class="submit" value="Submit"/>
</form>
</div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript">
(function () {
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter);
editor.run();
})();
</script>

View file

@ -0,0 +1,50 @@
<?php
if(isset($_SESSION['user'])) {
$user = $_SESSION['user'];
}
$filename = 'content/' . $user . '/author.md';
if(file_exists($filename)) {
$content = file_get_contents($filename);
$arr = explode('t-->', $content);
if(isset($arr[1])) {
$oldtitle = ltrim(rtrim(str_replace('<!--t','',$arr[0]), ' '));
$oldcontent = ltrim($arr[1]);
}
else {
$oldtitle = $user;
$oldcontent = ltrim($arr[0]);
}
}
else {
$oldtitle = $user;
$oldcontent = 'Just another HTMLy user.';
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css" />
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<div class="wmd-panel">
<form method="POST">
Title: <br><input type="text" name="title" class="text" value="<?php echo $oldtitle?>"/><br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br>
<input type="hidden" name="oldfile" class="text" value="<?php echo $url ?>"/>
<input type="submit" name="submit" class="submit" value="Submit"/>
</form>
</div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript">
(function () {
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter);
editor.run();
})();
</script>

View file

@ -0,0 +1,76 @@
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title; ?></title>
<link href='<?php echo site_url() ?>favicon.ico' rel='icon' type='image/x-icon'/>
<meta charset="utf-8" />
<meta content='htmly' name='generator'/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" user-scalable="no" />
<meta name="description" content="<?php echo $description; ?>" />
<link rel="sitemap" href="<?php echo site_url() ?>sitemap.xml" />
<link rel="canonical" href="<?php echo $canonical; ?>" />
<link rel="alternate" type="application/rss+xml" title="<?php echo config('blog.title')?> Feed" href="<?php echo site_url()?>feed/rss" />
<link href="<?php echo site_url() ?>system/admin/views/css/style.css" rel="stylesheet" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<?php if (publisher() == true):?><link href="<?php echo publisher() ?>" rel="publisher" /><?php endif;?>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body itemscope="itemscope" itemtype="http://schema.org/Blog">
<div class="hide">
<meta content="<?php echo config('blog.title') ?>" itemprop="name"/>
<meta content="<?php echo config('blog.description')?>" itemprop="description"/>
</div>
<?php if(login()) {?>
<style> #outer-wrapper{ padding-top:30px;}</style>
<div id="toolbar">
<ul>
<li><a href="<?php echo site_url() ?>">Home</a></li>
<li><a href="<?php echo site_url() ?>admin">Admin</a></li>
<li><a href="<?php echo site_url() ?>admin/posts">Posts</a></li>
<li><a href="<?php echo site_url() ?>add/post">Add post</a></li>
<li><a href="<?php echo site_url() ?>add/page">Add page</a></li>
<li><a href="<?php echo site_url() ?>edit/profile">Edit profile</a></li>
<li><a href="<?php echo site_url() ?>logout">Logout</a></li>
</ul>
</div>
<?php } ?>
<div id="outer-wrapper">
<div id="menu-wrapper">
<div class="container">
<nav id="menu">
<?php echo menu() ?>
<?php echo search() ?>
</nav>
</div>
</div>
<div id="header-wrapper">
<div class="container">
<header id="header">
<section id="branding">
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo config('blog.title') ?></a></h1>
<div class="blog-tagline"><p><?php echo config('blog.tagline')?></p></div>
</section>
</header>
</div>
</div>
<div id="content-wrapper">
<div class="container">
<section id="content">
<?php echo content()?>
</section>
</div>
</div>
<div id="footer-wrapper">
<div class="container">
<footer id="footer">
<div class="copyright"><?php echo copyright() ?></div>
</footer>
</div>
</div>
</div>
<?php if (analytics() == true):?><?php echo analytics() ?><?php endif;?>
</body>
</html>

View file

@ -0,0 +1,11 @@
<?php if(!login()) {?>
<?php login_message(null);?>
<h1>Login</h1>
<form method="POST" action="login">
User:<br>
<input type="text" name="user"/><br><br>
Pass:<br>
<input type="password" name="password"/><br><br>
<input type="submit" name="submit" value="Login"/>
</form>
<?php } else {header('location: admin');} ?>

View file

@ -0,0 +1,7 @@
<?php
session_destroy();
header('location: login');
?>

View file

@ -0,0 +1,5 @@
<?php
echo '<h2>Your recent posts</h2>';
get_recent_posts();
echo '<h2>Static pages</h2>';
get_recent_pages(); ?>

View file

View file

@ -0,0 +1,37 @@
<h2 class="post-index">Your posts</h2>
<?php if(!empty($posts)) {?>
<table class="post-list">
<tr><th>Title</th><th>Published</th><th>Tag</th><th>Operations</th></tr>
<?php $i = 0; $len = count($posts);?>
<?php foreach($posts as $p):?>
<?php
if ($i == 0) {
$class = 'first';
}
elseif ($i == $len - 1) {
$class = 'last';
}
else {
$class = '';
}
$i++;
?>
<tr>
<td><?php echo $p->title ?></td>
<td><?php echo date('d F Y', $p->date) ?></td>
<td><?php echo $p->tag ?></td>
<td><a href="<?php echo $p->url ?>/edit">Edit</a> <a href="<?php echo $p->url ?>/delete">Delete</a></td>
</tr>
<?php endforeach;?>
</table>
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])):?>
<div class="pager">
<?php if (!empty($pagination['prev'])):?>
<span><a href="?page=<?php echo $page-1?>" class="pagination-arrow newer" rel="prev">Newer</a></span>
<?php endif;?>
<?php if (!empty($pagination['next'])):?>
<span><a href="?page=<?php echo $page+1?>" class="pagination-arrow older" rel="next">Older</a></span>
<?php endif;?>
</div>
<?php endif;?>
<?php } else { echo 'No posts found!'; }?>