Draw the rest of the fucking owl
parent
e9a6a6bf2e
commit
1faa875989
|
@ -1 +1,4 @@
|
|||
blogtool
|
||||
blogtool
|
||||
lib
|
||||
shard.lock
|
||||
testsite/dist
|
16
Makefile
16
Makefile
|
@ -12,11 +12,19 @@ clean:
|
|||
run:
|
||||
crystal run src/blogtool.cr
|
||||
|
||||
release:
|
||||
release: dependencies
|
||||
crystal build --release --no-debug src/blogtool.cr
|
||||
|
||||
test:
|
||||
cd testsite && crystal run ../src/blogtool.cr
|
||||
dependencies:
|
||||
shards install
|
||||
|
||||
debug:
|
||||
crystal build src/blogtool.cr
|
||||
|
||||
test: debug
|
||||
cd testsite && ../blogtool
|
||||
|
||||
install:
|
||||
install swayfocus $(PREFIX)/bin/
|
||||
install blogtool $(PREFIX)/bin/
|
||||
mkdir -p /etc/blogtool
|
||||
install testsite/base.html /etc/blogtool/
|
10
README.md
10
README.md
|
@ -1,6 +1,6 @@
|
|||
## BLOGTOOL is a stupid simple static site generator
|
||||
## BLOGTOOL is a non-bloated static site generator.
|
||||
|
||||
There are no themes or templates. You write a project structure like this:
|
||||
There are no themes. You write a project structure like this:
|
||||
```
|
||||
myblog
|
||||
|
|
||||
|
@ -10,11 +10,10 @@ myblog
|
|||
|-> assets
|
||||
| |-> article1.jpg
|
||||
| |-> photo.png
|
||||
|-> profile.jpg
|
||||
|-> about.md
|
||||
|-> styles.css
|
||||
```
|
||||
with utf-8 encoded articles. Blogtool generates a static site in dist/ with a list of articles for the home page, an about page with a profile picture and bio from profile.jpg and about.md, each page will include styless.css and all assets will be available at /static.
|
||||
with utf-8 encoded articles. Blogtool generates a static site in dist/ with a list of articles for the home page, an about page from about.md, each page will include styless.css and all assets will be available at /static. Dashes (-) will be replaced with spaces in the index.
|
||||
```
|
||||
dist
|
||||
|
|
||||
|
@ -22,11 +21,10 @@ dist
|
|||
|-> static
|
||||
| |-> article1.jpg
|
||||
| |-> photo.png
|
||||
| |-> profile.jpg
|
||||
| |-> styles.css
|
||||
|-> article1.html
|
||||
|-> article2.html
|
||||
|-> about.html
|
||||
```
|
||||
|
||||
Invoke blogtool with `blogtool` after installing dependencies and adding the bin to your path. Run it in your project's root. There are no options. It will not remove old files from dist/.
|
||||
You can build blogtool by running `make && sudo make install`. Invoke blogtool by running `blogtool` in the project directory. There are no options. You can copy /etc/blogtool/base.html to the project root and make changes to overwrite the template.
|
|
@ -1,13 +1,56 @@
|
|||
require "markd"
|
||||
require "dir"
|
||||
require "file"
|
||||
require "path"
|
||||
|
||||
begin
|
||||
Dir.mkdir "dist"
|
||||
Dir.mkdir_p Path["dist/static"]
|
||||
rescue
|
||||
if !Dir.exists? Path["dist/static"]
|
||||
puts "Could not create required folders. Exiting."
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
articles = Dir.entries "articles"
|
||||
articles = articles.select { |i| i != "." && i != ".." }
|
||||
puts articles
|
||||
Base = begin
|
||||
if File.file? "base.html"
|
||||
File.read "base.html"
|
||||
elsif File.file? Path[ENV["HOME"]+"/.config/blogtool/base.html"]
|
||||
File.read Path[ENV["HOME"]+"/.config/blogtool/base.html"]
|
||||
elsif File.file? Path["/etc/blogtool/base.html"]
|
||||
File.read Path["/etc/blogtool/base.html"]
|
||||
else
|
||||
puts "Can't find base.html"
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
#print Markd.to_html(text, Markd::Options.new(smart: true, safe: false));
|
||||
|
||||
BaseCSS = begin
|
||||
if File.file? Path[ENV["HOME"]+"/.config/blogtool/styles.css"]
|
||||
File.read Path[ENV["HOME"]+"/.config/blogtool/styles.css"]
|
||||
elsif File.file? Path["/etc/blogtool/styles.css"]
|
||||
File.read Path["/etc/blogtool/styles.css"]
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def render_file(filename : String | Path)
|
||||
Base+Markd.to_html(File.read(filename), Markd::Options.new(smart: true, safe: false))+"</body></html>"
|
||||
end
|
||||
|
||||
Dir.entries("articles").select{ |i| i != "." && i != ".." }.each do |article|
|
||||
if article[article.size-3, article.size] == ".md"
|
||||
File.write Path.new("dist", article[0,article.size-3]+".html"), render_file("articles/"+article)
|
||||
else
|
||||
File.write Path.new("dist", article+".html"), render_file("articles/"+article)
|
||||
end
|
||||
end
|
||||
|
||||
Dir.entries("assets").select{ |i| i != "." && i != ".." }.each do |asset|
|
||||
File.copy Path.new("assets", asset), Path.new("dist", "static", asset)
|
||||
end
|
||||
|
||||
File.write Path.new("dist", "static", "styles.css"), BaseCSS+File.read("styles.css")
|
||||
File.write Path.new("dist", "about.html"), render_file("about.md")
|
||||
|
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
|
@ -2,8 +2,7 @@
|
|||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h2 id="yeet">yeet</h2>
|
||||
<h2>yeet</h2>
|
||||
<p><strong>this is</strong> a <em>test</em></p>
|
||||
<p><a href="http://google.com">weeeooo</a></p>
|
||||
</body>
|
||||
</html>
|
||||
</body></html>
|
Loading…
Reference in New Issue