├── .gitignore
├── LICENSE
├── README.md
├── index-daniel.php
├── index-theme-simple.php
├── index.php
├── rss.py
└── setup.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | posts
2 | image
3 | config.php
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2020- Daniel C
2 |
3 | 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:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | 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.
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TinyBlog
2 | Single File HTML/CSS/PHP blog in less than 100 lines.
3 | See it in action: http://danielc.dev/blog/
4 | Personally, I'm using https://github.com/petabyt/tinyblog2 now
5 |
6 | ## Features
7 | - Tiny source code. Just pull index.php and customize.
8 | - Minimal markdown parser. Easy to customize to your liking.
9 |
10 | ## Setup
11 | In the `posts` folder, create a file named "1" for the first
12 | post, "2" for the second, and so on.
13 |
14 | ## Theme
15 |
16 | A second drop-in replacement white theme is available (index-theme-simple.php),
17 | made by @xiamuguizhi.
18 |
19 | ## Markdown Syntax
20 |
21 |
22 | TinyBlog has a built-in Markdown parser. It supports most of the typical
23 | Markdown syntax, but has some additional features:
24 |
25 | - Type `---` to insert a "Read More" link, and cut off the rest of the text.
26 | - Use `\*` to prevent the asterisk from being recognized.
27 |
--------------------------------------------------------------------------------
/index-daniel.php:
--------------------------------------------------------------------------------
1 | ");
10 |
11 | $f = fopen("blog/posts/" . strval($postCount), "r");
12 | echo("" . substr(fgets($f), 2) . "
");
13 | echo("
$1
", $asHtml);
138 | $asHtml = preg_replace("/\`([^\n]+)\`/i", "$1
", $asHtml);
139 |
140 | # Replace bold, then italics
141 | $asHtml = preg_replace("/\*\*([^\n]+)\*\*/i", "$1", $asHtml);
142 | $asHtml = preg_replace("/\*([^\n]+)\*/i", "$1", $asHtml);
143 |
144 | # Replace --- with mothing and add "back" link or add "read more" if chosen.
145 | if ($showRest == TRUE) {
146 | $asHtml = preg_replace("/---/s", "", $asHtml);
147 | $asHtml .= "Back";
148 | } else {
149 | $asHtml = preg_replace("/---(.+)/s", "", $asHtml);
150 | }
151 |
152 | return $asHtml;
153 | }
154 | ?>
155 |
156 |
157 |
--------------------------------------------------------------------------------
/index-theme-simple.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | $1
", $asHtml);
240 | $asHtml = preg_replace("/\`([^\n]+)\`/i", "$1
", $asHtml);
241 |
242 | # Replace bold, then italics (don't replace \*)
243 | $asHtml = preg_replace("/\*\*([^\n]+)\*\*/i", "$1", $asHtml);
244 | $asHtml = preg_replace("/\*[^\\\\]([^\n]+)[^\\\\]\*/i", "$1", $asHtml);
245 |
246 | # Replace \* with *
247 | # Optional, may break C/C++ code.
248 | #$asHtml = preg_replace("/(\\\\\*)/i", "*", $asHtml);
249 |
250 | # Replace --- with mothing and add "back" link or add "read more" if chosen.
251 | if ($showRest == TRUE) {
252 | $asHtml = preg_replace("/---/s", "", $asHtml);
253 | $asHtml .= "Back";
254 | } else {
255 | $asHtml = preg_replace("/---(.+)/s", "", $asHtml);
256 | }
257 |
258 | return $asHtml;
259 | }
260 | ?>
261 | $1
", $asHtml);
94 | $asHtml = preg_replace("/\`([^\n`]+)\`/i", "$1
", $asHtml);
95 |
96 | # Replace bold, then italics
97 | $asHtml = preg_replace("/\*\*([^\n\*]+)\*\*/i", "$1", $asHtml);
98 | $asHtml = preg_replace("/\*([^\n\*]+)\*/i", "$1", $asHtml);
99 |
100 | # Replace --- with mothing and add "back" link or add "read more" if chosen.
101 | if ($showRest == TRUE) {
102 | $asHtml = preg_replace("/---/s", "", $asHtml);
103 | $asHtml .= "Back";
104 | } else {
105 | $asHtml = preg_replace("/---(.+)/s", "", $asHtml);
106 | }
107 |
108 | return $asHtml;
109 | }
110 | ?>
111 |
112 |
113 |
--------------------------------------------------------------------------------
/rss.py:
--------------------------------------------------------------------------------
1 | import os, re
2 |
3 | # Post RSS.py
4 | # For a basic PHP version with '@' seperated post information,
5 | # see https://github.com/petabyt/tinyblog/issues/6
6 |
7 | url = "https://petabyt.dev/blog/"
8 | title = "Daniel's Blog"
9 | desc = "This is the place where I put stuff"
10 |
11 | print("""
12 |