GithubHelp home page GithubHelp logo

paintedsky / dead-simple-blog Goto Github PK

View Code? Open in Web Editor NEW
32.0 7.0 10.0 308 KB

A flat-file, database-free, almost-single-file blog "engine" using PHP.

License: MIT License

PHP 93.80% CSS 6.20%
php blogging blogging-system flat-file database-free simple blog

dead-simple-blog's Introduction

Dead Simple Blog

Version 1.1 (2022-11-15)

I've wanted for a long time to create a simple way of blogging that eschews basically all bells and whistles. Many "flat file" Content Management Systems exist already, as well as "static site generators", but none of these that I looked at were simple enough for my liking.

I don't want to have to install Ruby, or Python, or Composer, or whatever else on a server to run a blog. On the other hand, installing WordPress or one of the other popular PHP-based CMSes for this use case is like hammering in a nail with a sledgehammer.

Many people dislike PHP, and while it has its warts, I like it. I like using (vanilla) PHP simply because it is nearly ubiquitous. Having to install or configure it is often unnecessary because it is usually already installed, configured, and running.

I wanted to use plain text files, but some formatting is nice -- Markdown was the obvious solution for this, since it offers quite a lot of options in terms of text formatting, without sacrificing the readability of the plain text itself. I was not keen on adding dependencies but I found Parsedown which offers Markdown parsing by including a single PHP file. I can deal with that.

That's really all there is to it -- dead simple PHP-based templating, and Markdown-formatted plain text content.

I know I'm probably forgetting about a million edge cases, but I want to keep it simple. So, we'll roll with this for now and add features as they become necessary.

Installation

Download the files and upload them to a webserver somewhere. That's it!

Usage

  1. Duplicate config-default.php as config-custom.php, and change the config variables to your liking.
  2. Create text files with a NUMERIC file name, I use YYYY-MM-DD date-based names (e.g. 2018-10-30.md).
  3. Format text files with Markdown, or not. Whatever. ;)
  4. If you need to link to image/video/audio/etc. files, you can upload them to the media folder.
  5. Upload text files to the content directory.
  6. You're done!!

Changelog

Version 1.1

  • Updated Parsedown to 1.7.4
  • Config has now been moved to config-default.php, added support for config-custom.php
  • Added dark mode! Adjust the APPEARANCE constant to enable
  • Change default file type to .md files instead of .txt. Adjust FILE_EXT constant if needed
  • Reorganize folder structure (CSS and fonts are now in /src)
  • Small text update to /content/drafts/AboutDrafts.md
  • Defined $content in global scope to avoid PHP errors in some configurations
  • Added default favicon at /img/favicon.png
  • Including fonts.css in <head> instead of using @import for better caching behaviour
  • Added file hash query strings to <link> tags in <head> for better caching behaviour
  • index.php now uses <main> for content on list view and <article> on single post view
  • List view now explicitly sorts posts using sortPosts() function - default is sorting by filename, descending

Other Versions

User @shoaiyb has a fork going with additional features that I didn't think were "absolutely necessary" but if you want some extra bells and whistles, I recommend checking out his fork.

Attributions

dead-simple-blog's People

Contributors

paintedsky avatar shoaiyb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dead-simple-blog's Issues

Notice: Undefined variable: content in (...)\index.php on line 34

Apache v2.4.33
PHP v7.2.4

I just uploaded the files to my web server, edited the variable "$base_url" in index.php, and loaded the blog on the web browser.
I get the message "Notice: Undefined variable: content in C:\xampp\htdocs\blog\index.php on line 34".

I tried both relative and absolute URLs in the "$base_url"variable and the results were the same.

I also tried to load the available page (2018-10-30.txt) directly using http://127.0.0.1/blog/?post=2018-10-30 and the page loads fine, without errors.

The problem seems to be only in the "home page" of the website.

Index sorting

Hi people,

For some reasons, I can't find the logic in the way the index is sorted. In my case it is not chronological nor alphabetical, nor following any logic. Is there any way to fix this ?

Thanks in advance,

ordering of files retrieved from /content

Hi,

I am using a modified older version. It always pulled the posts out in the right order before my site moved server. Now the posts come out in a consistent but not newest descending order. Do you have any idea why the directoryIterator loop would change the order of the files retrieved? I am using YYYY-MM-DD

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.