Delete Posts
Edit Posts Back to blog
This commit is contained in:
parent
fbca74ccec
commit
6e6e26ad26
11 changed files with 574 additions and 121 deletions
3
articles/main/2015-07-24-example.md
Normal file → Executable file
3
articles/main/2015-07-24-example.md
Normal file → Executable file
|
@ -1,7 +1,10 @@
|
||||||
%TITLE: The Rangitaki logo
|
%TITLE: The Rangitaki logo
|
||||||
%DATE: 24 July 2015
|
%DATE: 24 July 2015
|
||||||
|
%AUTHOR: The great testers
|
||||||
%TAGS: design, artwork, logo
|
%TAGS: design, artwork, logo
|
||||||
|
|
||||||
|
|
||||||
This is the official Rangitaki logo.
|
This is the official Rangitaki logo.
|
||||||
|
|
||||||
![The Rangitaki logo](media/example.png)
|
![The Rangitaki logo](media/example.png)
|
||||||
|
|
|
@ -15,7 +15,7 @@ $bloghome = 'yes';
|
||||||
$bloghomeurl = '../';
|
$bloghomeurl = '../';
|
||||||
// Home name - Set here an individual name for your main page
|
// Home name - Set here an individual name for your main page
|
||||||
$bloghomename = 'Home';
|
$bloghomename = 'Home';
|
||||||
// Main Blog name -> Set a specific name for your name blog
|
// Main Blog name -> Set a specific name for your main blog
|
||||||
// This value is empty by default
|
// This value is empty by default
|
||||||
$blogmainname = '';
|
$blogmainname = '';
|
||||||
// Intro - set yes if you have a blog intro and no if you don't have one
|
// Intro - set yes if you have a blog intro and no if you don't have one
|
||||||
|
|
112
rcc/edit/index.php
Normal file
112
rcc/edit/index.php
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
<?php
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<!--
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright 2015 mmk2410.
|
||||||
|
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Rangitaki Control Center</title>
|
||||||
|
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
|
||||||
|
<link rel="stylesheet" href="../res/rcc.css"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header">
|
||||||
|
<a href="../" class="title">Rangitaki Control Center</a>
|
||||||
|
</div>
|
||||||
|
<div class="main">
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
if ($_SESSION['login']) {
|
||||||
|
include_once("../../res/php/ArticleGenerator.php");
|
||||||
|
$directory = "./../../articles/" . $_GET['blog'] . "/";
|
||||||
|
$article = $_GET['post'] . ".md";
|
||||||
|
?>
|
||||||
|
<section class="card">
|
||||||
|
<div class="headline">Edit Post</div>
|
||||||
|
<p>Title:<br><br><input type="text" class="itextfield"
|
||||||
|
value="<?php echo ArticleGenerator::getTitle($directory, $article) ?>"
|
||||||
|
name="title"
|
||||||
|
id="title"/>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>Date:<br><br><input type="text" class="itextfield"
|
||||||
|
value="<?php echo ArticleGenerator::getDate($directory, $article) ?>" name="date"
|
||||||
|
id="date"/>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>Author:<br><br><input type="text"
|
||||||
|
value="<?php echo ArticleGenerator::getAuthor($directory, $article) ?>"
|
||||||
|
class="itextfield" name="author"
|
||||||
|
id="author"/></p>
|
||||||
|
|
||||||
|
<p>Tags:<br><br><input type="text"
|
||||||
|
value="<?php
|
||||||
|
$tags = "";
|
||||||
|
foreach (ArticleGenerator::getTags($directory, $article) as $tag) {
|
||||||
|
$tags = $tags . ', ' . $tag;
|
||||||
|
}
|
||||||
|
$tags = substr($tags, 2);
|
||||||
|
echo $tags;
|
||||||
|
?>"
|
||||||
|
class="itextfield" name="tags"
|
||||||
|
id="tags"/></p>
|
||||||
|
|
||||||
|
<p>Text:</p>
|
||||||
|
<textarea class="itextarea" name="text" id="text">
|
||||||
|
<?php echo ArticleGenerator::getText($directory, $article) ?>
|
||||||
|
</textarea>
|
||||||
|
<br><br>
|
||||||
|
<a class="button" id="save_changes">SAVE CHANGES</a>
|
||||||
|
</section>
|
||||||
|
<section class="card">
|
||||||
|
<div class="headline">Back</div>
|
||||||
|
<p>
|
||||||
|
Go back to the RCC home. All changes will be lost.
|
||||||
|
</p>
|
||||||
|
<a class="button" href="../">BACK</a>
|
||||||
|
</section>
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
?>
|
||||||
|
<section class="card">
|
||||||
|
<div class="headline">Access denied</div>
|
||||||
|
<p>
|
||||||
|
The access to this area is not granted. Make sure you're logged in.
|
||||||
|
</p>
|
||||||
|
<a class="button" href="../">BACK</a>
|
||||||
|
</section>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
var getVariables = <?php echo json_encode($_GET); ?>;
|
||||||
|
</script>
|
||||||
|
<script src="../../res/js/jquery-2.1.4.min.js"></script>
|
||||||
|
<script src="../res/rcc.js"></script>
|
||||||
|
<script src="../res/edit.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -23,27 +23,27 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Rangitaki Control Center</title>
|
<title>Rangitaki Control Center</title>
|
||||||
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
|
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport'/>
|
||||||
<link rel="stylesheet" href="./res/rcc.css" />
|
<link rel="stylesheet" href="./res/rcc.css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<a href="./" class="title">Rangitaki Control Center</a>
|
<a href="./" class="title">Rangitaki Control Center</a>
|
||||||
<a href="../" class="back">Back to the blog</a>
|
<a href="../" class="back">Back to the blog</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<?php
|
<?php
|
||||||
require '../config.php';
|
require '../config.php';
|
||||||
if ($rcc == "yes") {
|
if ($rcc == "yes") {
|
||||||
include 'password.php';
|
include 'password.php';
|
||||||
session_start();
|
session_start();
|
||||||
if(isset($_POST['passwd'])) {
|
if (isset($_POST['passwd'])) {
|
||||||
$passwd = $_POST['passwd'];
|
$passwd = $_POST['passwd'];
|
||||||
$_SESSION['passwd'] = $_POST['passwd'];
|
$_SESSION['passwd'] = $_POST['passwd'];
|
||||||
} else if(isset($_SESSION['passwd'])) {
|
} else if (isset($_SESSION['passwd'])) {
|
||||||
$passwd = $_SESSION['passwd'];
|
$passwd = $_SESSION['passwd'];
|
||||||
}
|
}
|
||||||
if ($passwd == "") {
|
if ($passwd == "") {
|
||||||
|
@ -59,6 +59,7 @@ THE SOFTWARE.
|
||||||
} else {
|
} else {
|
||||||
if ($passwd == $password) {
|
if ($passwd == $password) {
|
||||||
$_SESSION['login'] = true;
|
$_SESSION['login'] = true;
|
||||||
|
include_once("./../res/php/BlogListGenerator.php");
|
||||||
?>
|
?>
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<div class="headline">Post Upload</div>
|
<div class="headline">Post Upload</div>
|
||||||
|
@ -74,8 +75,8 @@ THE SOFTWARE.
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
|
<input type="hidden" name="MAX_FILE_SIZE" value="100000"/>
|
||||||
<input id="" name="userfile" type="file" value="Choose a file" />
|
<input id="" name="userfile" type="file" value="Choose a file"/>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<input id="button" type="submit" value="Upload" class="button"/>
|
<input id="button" type="submit" value="Upload" class="button"/>
|
||||||
|
@ -111,11 +112,53 @@ THE SOFTWARE.
|
||||||
<input id="button" type="submit" value="Post" class="button"/>
|
<input id="button" type="submit" value="Post" class="button"/>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
<section class="card">
|
||||||
|
<div class="headline">Edit post</div>
|
||||||
|
<p>
|
||||||
|
First select the blog of the post you wan't to edit.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p id="edit_select_blog">
|
||||||
|
<select name="blog" id="edit_selected_blog">
|
||||||
|
<?php
|
||||||
|
$blogs = scandir("../blogs/");
|
||||||
|
foreach ($blogs as $blog) {
|
||||||
|
if (strlen($blog) >= 3 && substr($blog, -3) == ".md") {
|
||||||
|
$blog = substr($blog, 0, -3);
|
||||||
|
echo "<option value='$blog'>$blog</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<a class="button" id="edit_get_posts">GET POSTS</a>
|
||||||
|
</section>
|
||||||
|
<section class="card">
|
||||||
|
<div class="headline">Delete Post</div>
|
||||||
|
<p>
|
||||||
|
First select the subblog of the post you want to delete.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p id="delete_select_blog">
|
||||||
|
<select name="blog" id="delete_selected_blog">
|
||||||
|
<?php
|
||||||
|
$blogs = scandir("../blogs/");
|
||||||
|
foreach ($blogs as $blog) {
|
||||||
|
if (strlen($blog) >= 3 && substr($blog, -3) == ".md") {
|
||||||
|
$blog = substr($blog, 0, -3);
|
||||||
|
echo "<option value='$blog'>$blog</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<a class="button" id="delete_get_posts">GET POSTS</a>
|
||||||
|
</section>
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<div class="headline">Media Upload</div>
|
<div class="headline">Media Upload</div>
|
||||||
<form enctype="multipart/form-data" action="media/" method="POST">
|
<form enctype="multipart/form-data" action="media/" method="POST">
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000" />
|
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000"/>
|
||||||
<input id="" name="userfile" type="file" value="Choose a file" />
|
<input id="" name="userfile" type="file" value="Choose a file"/>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<input id="button" type="submit" value="Upload" class="button"/>
|
<input id="button" type="submit" value="Upload" class="button"/>
|
||||||
|
@ -139,7 +182,8 @@ THE SOFTWARE.
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<div class="headline">Rangitaki Control Center</div>
|
<div class="headline">Rangitaki Control Center</div>
|
||||||
<p>
|
<p>
|
||||||
The Rangitaki Control Center is disabled. You can enable it in your config file. But please read first the documentation.
|
The Rangitaki Control Center is disabled. You can enable it in your config file. But please read first
|
||||||
|
the documentation.
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
<?php
|
<?php
|
||||||
|
@ -152,7 +196,10 @@ THE SOFTWARE.
|
||||||
</p>
|
</p>
|
||||||
<a href="../" class="button">GO BACK</a>
|
<a href="../" class="button">GO BACK</a>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<script src="./res/rcc.js"></script>
|
<script src="./res/rcc.js"></script>
|
||||||
</body>
|
<script src="../res/js/jquery-2.1.4.min.js"></script>
|
||||||
|
<script src="./res/delete.js"></script>
|
||||||
|
<script src="./res/edit.js"></script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
62
rcc/res/delete.js
Normal file
62
rcc/res/delete.js
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/**
|
||||||
|
* Created by mmk2410 on 12/6/15.
|
||||||
|
*
|
||||||
|
* JavaScript for the functionality to delete blogs
|
||||||
|
*/
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
|
||||||
|
// listener and function for recieving the posts of the selected blogs
|
||||||
|
$("#delete_get_posts").click(function () {
|
||||||
|
var selectedBlog = $("#delete_selected_blog").val();
|
||||||
|
$.get("res/get_posts.php", {
|
||||||
|
blog: selectedBlog
|
||||||
|
}, function (data) {
|
||||||
|
$("#delete_select_post").remove();
|
||||||
|
$("#delete_select_post_info").remove();
|
||||||
|
$("#delete_post_button").remove();
|
||||||
|
$("#delete_get_posts").after("<p id='delete_select_post'></p>");
|
||||||
|
$("#delete_get_posts").after("<p id='delete_select_post_info'>Now select the post you want to delete. " +
|
||||||
|
"Remember that once a post is deleted it can't be restored.</p>");
|
||||||
|
$("#delete_select_post").append("<select id='delete_selected_post'></select>");
|
||||||
|
$.each($.parseJSON(data), function (index, value) {
|
||||||
|
var post = value.substring(0, value.length - 3);
|
||||||
|
$("#delete_selected_post").append("<option value='" + post + "'>" + post + "</option>");
|
||||||
|
});
|
||||||
|
$("#delete_select_post").after("<a class='button' id='delete_post_button' " +
|
||||||
|
"onclick='deletePostButton()'>DELETE POST</a>")
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the selected posts
|
||||||
|
*/
|
||||||
|
function deletePostButton() {
|
||||||
|
|
||||||
|
var selectedBlog = $("#delete_selected_blog").val();
|
||||||
|
var selectedPost = $("#delete_selected_post").val();
|
||||||
|
$.get("res/delete_post.php", {
|
||||||
|
blog: selectedBlog,
|
||||||
|
post: selectedPost
|
||||||
|
}, function (data) {
|
||||||
|
$("#delete_select_post").remove();
|
||||||
|
$("#delete_select_post_info").remove();
|
||||||
|
$("#delete_post_button").remove();
|
||||||
|
if (data == "901") {
|
||||||
|
alert("ERROR 901: No post as get argument given.");
|
||||||
|
} else if (data == "921") {
|
||||||
|
alert("ERROR 921: No post with given argument available.");
|
||||||
|
} else if (data == "941") {
|
||||||
|
alert("ERROR 941: No blog as get argument given");
|
||||||
|
} else if (data == "961") {
|
||||||
|
alert("ERROR 961: Error while deleting the file. Check if the web server has the permission to do so.");
|
||||||
|
} else if (data == "0") {
|
||||||
|
alert("Post successfully deleted.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(main());
|
25
rcc/res/delete_post.php
Normal file
25
rcc/res/delete_post.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* User: mmk2410
|
||||||
|
* Date: 12/6/15
|
||||||
|
*
|
||||||
|
* Error Codes:
|
||||||
|
* 901 No post given as get argument
|
||||||
|
* 921 No post with the given name available
|
||||||
|
* 941 No blog given as get argument
|
||||||
|
* 961 Error while deleting the post
|
||||||
|
*/
|
||||||
|
$post = $_GET["post"];
|
||||||
|
$blog = $_GET["blog"];
|
||||||
|
if (!isset($post)) {
|
||||||
|
echo "901";
|
||||||
|
} else if (!isset($blog)) {
|
||||||
|
echo "941";
|
||||||
|
} else if (!file_exists("./../../articles/$blog/$post.md")) {
|
||||||
|
echo "921";
|
||||||
|
} else {
|
||||||
|
if (unlink("./../../articles/$blog/$post.md")) {
|
||||||
|
echo "0";
|
||||||
|
}
|
||||||
|
echo "961";
|
||||||
|
}
|
72
rcc/res/edit.js
Normal file
72
rcc/res/edit.js
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
* Created by mmk2410 on 12/6/15.
|
||||||
|
*
|
||||||
|
* JavaScript for the functionality to delete blogs
|
||||||
|
*/
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
|
||||||
|
// listener and function for recieving the posts of the selected blogs
|
||||||
|
$("#edit_get_posts").click(function () {
|
||||||
|
var selectedBlog = $("#edit_selected_blog").val();
|
||||||
|
$.get("res/get_posts.php", {
|
||||||
|
blog: selectedBlog
|
||||||
|
}, function (data) {
|
||||||
|
$("#edit_select_post").remove();
|
||||||
|
$("#edit_select_post_info").remove();
|
||||||
|
$("#edit_post_button").remove();
|
||||||
|
$("#edit_get_posts").after("<p id='edit_select_post'></p>");
|
||||||
|
$("#edit_get_posts").after("<p id='edit_select_post_info'>Now select the post you want to edit.</p>");
|
||||||
|
$("#edit_select_post").append("<select id='edit_selected_post'></select>");
|
||||||
|
$.each($.parseJSON(data), function (index, value) {
|
||||||
|
var post = value.substring(0, value.length - 3);
|
||||||
|
$("#edit_selected_post").append("<option value='" + post + "'>" + post + "</option>");
|
||||||
|
});
|
||||||
|
$("#edit_select_post").after("<a class='button' id='edit_post_button' " +
|
||||||
|
"onclick='editPostButton()'>EDIT POST</a>")
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#save_changes").click(function () {
|
||||||
|
var postTitle = $("#title").val();
|
||||||
|
var postDate = $("#date").val();
|
||||||
|
var postAuthor = $("#author").val();
|
||||||
|
var postTags = $("#tags").val();
|
||||||
|
var postText = $("#text").val();
|
||||||
|
|
||||||
|
var file = "../../articles/" + getVariables['blog'] + "/" + getVariables['post'] + ".md";
|
||||||
|
console.log(file);
|
||||||
|
|
||||||
|
$.post("../res/save.php", {
|
||||||
|
title: postTitle,
|
||||||
|
date: postDate,
|
||||||
|
author: postAuthor,
|
||||||
|
tags: postTags,
|
||||||
|
text: postText,
|
||||||
|
file: file
|
||||||
|
}, function (data) {
|
||||||
|
if (data == "0") {
|
||||||
|
alert("File successfully changed.");
|
||||||
|
window.open("../");
|
||||||
|
} else if (data == "1") {
|
||||||
|
alert("Error while saving the changes.");
|
||||||
|
} else if (data == "-1") {
|
||||||
|
alert("file");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the selected posts
|
||||||
|
*/
|
||||||
|
function editPostButton() {
|
||||||
|
|
||||||
|
var selectedBlog = $("#edit_selected_blog").val();
|
||||||
|
var selectedPost = $("#edit_selected_post").val();
|
||||||
|
var href = "./edit/?blog=" + selectedBlog + "&post=" + selectedPost;
|
||||||
|
window.open(href);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(main());
|
25
rcc/res/get_posts.php
Normal file
25
rcc/res/get_posts.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* User: mmk2410
|
||||||
|
* Date: 12/6/15
|
||||||
|
*
|
||||||
|
* Error Codes:
|
||||||
|
* 901 No blog given as get argument
|
||||||
|
* 921 No blog with the given name available
|
||||||
|
*/
|
||||||
|
$blog = $_GET["blog"];
|
||||||
|
if (!isset($blog)) {
|
||||||
|
echo "901";
|
||||||
|
} else if (!file_exists("./../../blogs/$blog.md")) {
|
||||||
|
echo "921";
|
||||||
|
} else {
|
||||||
|
$posts = array();
|
||||||
|
$i = 0;
|
||||||
|
foreach (scandir("./../../articles/$blog/") as $article) {
|
||||||
|
if (substr($article, -3) == ".md") {
|
||||||
|
$posts[$i] = $article;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print json_encode($posts);
|
||||||
|
}
|
|
@ -97,6 +97,15 @@ body{
|
||||||
border-bottom: none!important;
|
border-bottom: none!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.subheadline {
|
||||||
|
font-size: 20px;
|
||||||
|
color: #383838 !important;
|
||||||
|
text-decoration: none;
|
||||||
|
display: block;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
border-bottom: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
.card > p{
|
.card > p{
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
|
|
22
rcc/res/save.php
Normal file
22
rcc/res/save.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
$title = $_POST["title"];
|
||||||
|
$date = $_POST["date"];
|
||||||
|
$author = $_POST["author"];
|
||||||
|
$tags = $_POST["tags"];
|
||||||
|
$text = $_POST["text"];
|
||||||
|
$filename = $_POST["file"];
|
||||||
|
$md = <<<EOD
|
||||||
|
%TITLE: $title
|
||||||
|
%DATE: $date
|
||||||
|
%AUTHOR: $author
|
||||||
|
%TAGS: $tags
|
||||||
|
|
||||||
|
$text
|
||||||
|
EOD;
|
||||||
|
if (file_put_contents($filename, $md)) {
|
||||||
|
echo 0;
|
||||||
|
} else if (file_exists(($filename))) {
|
||||||
|
echo 1;
|
||||||
|
} else {
|
||||||
|
echo -1;
|
||||||
|
}
|
|
@ -112,7 +112,7 @@ class ArticleGenerator
|
||||||
* @param string $articlefile The name of the article file
|
* @param string $articlefile The name of the article file
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getTags($directory, $articlefile)
|
static function getTags($directory, $articlefile)
|
||||||
{
|
{
|
||||||
$article = file_get_contents($directory . $articlefile); // get the article
|
$article = file_get_contents($directory . $articlefile); // get the article
|
||||||
if (substr($article, 0, 6) == "%TITLE") { // detect and remove the title
|
if (substr($article, 0, 6) == "%TITLE") { // detect and remove the title
|
||||||
|
@ -140,7 +140,7 @@ class ArticleGenerator
|
||||||
* @param string $articlefile The name of the article file
|
* @param string $articlefile The name of the article file
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getTitle($directory, $articlefile)
|
static function getTitle($directory, $articlefile)
|
||||||
{
|
{
|
||||||
$article = file_get_contents($directory . $articlefile); // get the article
|
$article = file_get_contents($directory . $articlefile); // get the article
|
||||||
if (substr($article, 0, 6) == "%TITLE") { // detect and remove the title
|
if (substr($article, 0, 6) == "%TITLE") { // detect and remove the title
|
||||||
|
@ -149,4 +149,80 @@ class ArticleGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function to get the date of an article
|
||||||
|
*
|
||||||
|
* @param $directory The directory where the article is stored
|
||||||
|
* @param $articlefile The name of the article file
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
static function getDate($directory, $articlefile)
|
||||||
|
{
|
||||||
|
$article = file_get_contents($directory . $articlefile);
|
||||||
|
|
||||||
|
if (substr($article, 0, 6) == "%TITLE") { // detect and remove the title
|
||||||
|
$article = substr($article, strpos($article, "\n") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($article, 0, 5) == "%DATE") { // detect and remove the title
|
||||||
|
$date = substr($article, 7, strpos($article, "\n") - 7);
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function to get the author of an article
|
||||||
|
*
|
||||||
|
* @param $directory The directory where the article is stored
|
||||||
|
* @param $articlefile The name of the article file
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
static function getAuthor($directory, $articlefile)
|
||||||
|
{
|
||||||
|
$article = file_get_contents($directory . $articlefile);
|
||||||
|
|
||||||
|
if (substr($article, 0, 6) == "%TITLE") { // detect and remove the title
|
||||||
|
$article = substr($article, strpos($article, "\n") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($article, 0, 5) == "%DATE") { // detect and remove the title
|
||||||
|
$article = substr($article, strpos($article, "\n") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($article, 0, 7) == "%AUTHOR") { // detect and remove the title
|
||||||
|
$author = substr($article, 9, strpos($article, "\n") - 9);
|
||||||
|
return $author;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function to get the text of an article
|
||||||
|
*
|
||||||
|
* @param $directory The directory where the article is stored
|
||||||
|
* @param $articlefile The name of the article file
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
static function getText($directory, $articlefile)
|
||||||
|
{
|
||||||
|
$article = file_get_contents($directory . $articlefile);
|
||||||
|
|
||||||
|
if (substr($article, 0, 6) == "%TITLE") { // detect and remove the title
|
||||||
|
$article = substr($article, strpos($article, "\n") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($article, 0, 5) == "%DATE") { // detect and remove the title
|
||||||
|
$article = substr($article, strpos($article, "\n") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($article, 0, 7) == "%AUTHOR") { // detect and remove the title
|
||||||
|
$article = substr($article, strpos($article, "\n") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($article, 0, 5) == "%TAGS") { // detect the tags
|
||||||
|
$article = substr($article, strpos($article, "\n") + 1); // remove the tags
|
||||||
|
}
|
||||||
|
|
||||||
|
return $article;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue