krz/php-blog

A PHP blogging system with built-in static comments. blog comments php static

README.org

main
php-blog/README.org rendered · source · history · blame · raw

77 lines · 1916 bytes

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