krz/php-blog
clone: git clone https://gitbay.org/krz/php-blog.git
main: README.nfo · raw
1┌──────────────────────────────────────────────────────────────┐
2│ P H P - B L O G [ KRZ ] krz.sh │
3└──────────────────────────────────────────────────────────────┘
4
5WHAT
6 php-blog. database-free blogging app in php. articles in markdown,
7 metadata and comments in json.
8
9PHILOSOPHY
10 a blog should degrade gracefully over time. articles, metadata, and
11 comments live in the git repo, not a database.
12
13INSTALL
14 cd yourBlog.com
15 git clone <REPO_URL>
16
17 set the globals at the top of index.php:
18
19 $websiteProtocol = 'https://';
20 $shortDomain = 'yourBlog.com';
21
22 clear the sample data and posts:
23
24 cd _data/ && rm -rf *
25 touch comments.json && touch metadata.json
26 cd ../posts/ && rm -rf *
27 touch 001-your-first-post.md
28
29 add a metadata object in _data/metadata.json for every post. enable
30 FallbackResource in apache .conf or .htaccess:
31
32 FallbackResource /index.php
33
34STRUCTURE
35 index.php fallback resource; routes requests, calls
36 functions, fills the template
37 _classes/ Comment.php, Parsedown.php (erusev/parsedown, MIT),
38 Template.php
39 _data/ metadata.json (one object per post), comments.json
40 (written server-side as comments arrive)
41 _functions/ loadJSON.php, loadRSS.php, parseMarkdown.php,
42 submitComment.php
43 _templates/ template.html
44 posts/ markdown post bodies
45 static/ app.css, optional prism.css / prism.js for syntax
46 highlighting
47
48 metadata object:
49
50 {
51 "id": "001",
52 "title": "Title of Post",
53 "author": "Your Name",
54 "description": "...",
55 "tag": "my-category",
56 "created": "2018-12-08 00:00:00",
57 "modified": "2018-12-08 00:00:00",
58 "link": "https://www.example.com/post/name.html",
59 "published": "Yes"
60 }
61
62 let the web user write comments.json (apache is usually www-data):
63
64 chgrp -R www-data /path/to/website/
65 chmod -R g+w _data/comments.json
66
67┌──────────────────────────────────────────────────────────────┐
68│ krz.sh │
69└──────────────────────────────────────────────────────────────┘