mfbg

my fmbg fork
git clone git://shroom.party/mfbg.git
Log | Files | Refs | README | LICENSE

commit 9a63b76129d0580fd139238aa325a158bfe2be4d
Author: Jeremy Williams <jeremy.williams@paytm.com>
Date:   Tue, 20 Nov 2018 12:37:00 -0500

Wrote a mother fucking blog generator

Diffstat:
.gitignore | 2++
LICENSE | 21+++++++++++++++++++++
Makefile | 38++++++++++++++++++++++++++++++++++++++
README.md | 16++++++++++++++++
layout/footer.html | 3+++
layout/header.html | 26++++++++++++++++++++++++++
layout/index_footer.html | 4++++
layout/index_header.html | 28++++++++++++++++++++++++++++
posts/a-mother-fucking-blog-generator.md | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
posts/older-fucking-blog-post.md | 6++++++
10 files changed, 212 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +site +*.swp diff --git a/LICENSE b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Jeremy Williams + +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. diff --git a/Makefile b/Makefile @@ -0,0 +1,38 @@ +POST_DIR=posts +LAYOUT_DIR=layout +OUTPUT_DIR=site +BUILD_DIR=build + +POSTS=$(notdir $(wildcard $(POST_DIR)/*.md)) +POSTS_HTML=$(POSTS:%.md=$(OUTPUT_DIR)/%.html) + +.PHONY: clean + +all: $(POSTS_HTML) $(OUTPUT_DIR)/index.html + +$(OUTPUT_DIR)/index.html: $(LAYOUT_DIR)/index_header.html $(LAYOUT_DIR)/index_footer.html $(POST_DIR) + cp $(LAYOUT_DIR)/index_header.html $@ + for filename in `ls -t $(POST_DIR)`; do \ + f=$(POST_DIR)/$$filename; \ + echo "<a href=\"/$$(basename $$f .md)\">`sed '3q;d' $$f` - `sed '1q;d' $$f`</a><br/>" >> $@; \ + done + cat $(LAYOUT_DIR)/index_footer.html >> $@ + +$(OUTPUT_DIR)/%.html: $(BUILD_DIR)/%.html $(BUILD_DIR)/%_header.html $(LAYOUT_DIR)/footer.html | $(OUTPUT_DIR) + cat $(BUILD_DIR)/$*_header.html $< $(LAYOUT_DIR)/footer.html > $@ + +$(BUILD_DIR)/%_header.html: $(POST_DIR)/%.md $(LAYOUT_DIR)/header.html + sed "s/{title}/$(shell head -1 $<)/g" $(LAYOUT_DIR)/header.html > $@ + +$(BUILD_DIR)/%.html: $(POST_DIR)/%.md | $(BUILD_DIR) + pandoc -f markdown+pipe_tables -t html --ascii $< > $@ + +$(OUTPUT_DIR): + mkdir -p $@ + +$(BUILD_DIR): + mkdir -p $@ + +clean: + @rm -rf $(OUTPUT_DIR) $(BUILD_DIR) + diff --git a/README.md b/README.md @@ -0,0 +1,16 @@ +# MFBG +Mother Fucking Blog Generator + +## Usage +1. Fork +2. Install pandoc: `brew install pandoc` +3. Add some posts, change the layout +4. run `make` + +## Caveats +posts should start with the first three lines formatted as so to properly generate index.html: +``` +Blog Title +========== +2018-11-20 +``` diff --git a/layout/footer.html b/layout/footer.html @@ -0,0 +1,3 @@ + <a href="/"><< Back</a> + </body> +</html> diff --git a/layout/header.html b/layout/header.html @@ -0,0 +1,26 @@ +<html> + <head> + <title>{title}</title> + <style> + body { + margin: 40px auto; + max-width: 650px; + line-height: 1.6; + font-size: 17px; + font-family: sans-serif; + color: #444; + padding: 0 10px + } + h1,h2,h3 { + line-height:1.2 + } + pre { + background-color: #eeeeee; + padding: 5px 10px; + margin: 0px; + overflow: scroll; + } + </style> + </head> + <body> + <a href="/"><< Back</a> diff --git a/layout/index_footer.html b/layout/index_footer.html @@ -0,0 +1,4 @@ + <hr> + <p>Yes, this is fucking satire. Inspired by <a href="http://www.motherfuckingwebsite.com/">motherfuckingwebsite.com</a> and <a href="http://bettermotherfuckingwebsite.com/">bettermotherfuckingwebsite.com</a> + </body> +</html> diff --git a/layout/index_header.html b/layout/index_header.html @@ -0,0 +1,28 @@ +<html> + <head> + <title>Mother Fucking Blog</title> + <style> + body { + margin: 40px auto; + max-width: 650px; + line-height: 1.6; + font-size: 17px; + font-family: sans-serif; + color: #444; + padding: 0 10px + } + h1,h2,h3 { + line-height:1.2 + } + pre { + background-color: #eeeeee; + padding: 5px 10px; + margin: 0px; + } + </style> + </head> + <body> + <h1>This is a mother fucking blog.</h1> + <p>You've probably got a blog on Medium to complain about how shitty Medium is for blogging like this guy (<a href="https://medium.com/@nikitonsky/medium-is-a-poor-choice-for-blogging-bb0048d19133">Medium is a poor choice for blogging</a>) or you've wasted a bunch of time researching the bazillion static site generators to see if they will work and how to configure them for your needs. Well, fuck you, forget about that shit and just fork <a href="https://github.com/jeremycw/mfbg">github.com/jeremycw/mfbg</a>. Read my post below if you don't want to be an ignorant asshole. + <h2>Posts</h2> + diff --git a/posts/a-mother-fucking-blog-generator.md b/posts/a-mother-fucking-blog-generator.md @@ -0,0 +1,68 @@ +A Mother Fucking Blog Generator +=============================== +2018-11-20 + +This is a mother fucking blog post and it's been generated from markdown by my +fucking blog generator. + +### It can +- Generate your html pages from markdown because fuck writing blogs in raw html +- Generate an index.html containing a list of all the posts you've written + +That's it. What more do you need, it's a fucking blog. + +### How to use it +1. Fork [jeremycw/mfbg](https://github.com/jeremycw/mfbg) +2. Install pandoc: `brew install pandoc` because fuck you, I wanted markdown. +3. Add some posts, change the layout, do whatever the fuck you want. +4. run `make` + +Here it is, all 37 glorious lines of make: + +``` +POST_DIR=posts +LAYOUT_DIR=layout +OUTPUT_DIR=site +BUILD_DIR=build + +POSTS=$(notdir $(wildcard $(POST_DIR)/*.md)) +POSTS_HTML=$(POSTS:%.md=$(OUTPUT_DIR)/%.html) + +.PHONY: clean + +all: $(POSTS_HTML) $(OUTPUT_DIR)/index.html + +$(OUTPUT_DIR)/index.html: $(LAYOUT_DIR)/index_header.html $(LAYOUT_DIR)/index_footer.html $(POST_DIR) + cp $(LAYOUT_DIR)/index_header.html $@ + for filename in `ls -t $(POST_DIR)`; do \ + f=$(POST_DIR)/$$filename; \ + echo "<a href=\"/$$(basename $$f .md)\">`sed '3q;d' $$f` - `sed '1q;d' $$f`</a><br/>" >> $@; \ + done + cat $(LAYOUT_DIR)/index_footer.html >> $@ + +$(OUTPUT_DIR)/%.html: $(BUILD_DIR)/%.html $(BUILD_DIR)/%_header.html $(LAYOUT_DIR)/footer.html | $(OUTPUT_DIR) + cat $(BUILD_DIR)/$*_header.html $< $(LAYOUT_DIR)/footer.html > $@ + +$(BUILD_DIR)/%_header.html: $(POST_DIR)/%.md $(LAYOUT_DIR)/header.html + sed "s/{title}/$(shell head -1 $<)/g" $(LAYOUT_DIR)/header.html > $@ + +$(BUILD_DIR)/%.html: $(POST_DIR)/%.md | $(BUILD_DIR) + pandoc -f markdown+pipe_tables -t html --ascii $< > $@ + +$(OUTPUT_DIR): + mkdir -p $@ + +$(BUILD_DIR): + mkdir -p $@ + +clean: + @rm -rf $(OUTPUT_DIR) $(BUILD_DIR) +``` + +### Stupid Questions +- **Q:** But where are my rubies and my gems and my npms and webpacks and transpilers? +- **A:** Fuck you, you don't need any of that shit. This uses make cause that shit's fucking everywhere +- **Q:** Where are the .yml and .json files to configure it? +- **A:** It's 37 fucking lines, just change the fucking Makefile +- **Q:** Does it work on linux? +- **A:** I don't know, probably. Just fucking try it. If it doesn't fucking fix it. diff --git a/posts/older-fucking-blog-post.md b/posts/older-fucking-blog-post.md @@ -0,0 +1,6 @@ +Older Fucking Blog Post +======================= +2018-11-19 + +This is just to show you skeptical fucks that this generator can actually handle +multiple posts.