Replace a string in the template so that we can add a footer
parent
2dd0c6467d
commit
88f93a1395
|
@ -1,4 +1,5 @@
|
||||||
blogtool
|
blogtool
|
||||||
lib
|
lib
|
||||||
shard.lock
|
shard.lock
|
||||||
testsite/dist
|
testsite/dist
|
||||||
|
.deps
|
12
Makefile
12
Makefile
|
@ -6,7 +6,7 @@ all: release
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -f blogtool
|
rm -f blogtool .deps
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run:
|
run:
|
||||||
|
@ -16,15 +16,15 @@ release: dependencies
|
||||||
crystal build --release --no-debug src/blogtool.cr
|
crystal build --release --no-debug src/blogtool.cr
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
shards install
|
[ -e .deps ] || shards install
|
||||||
|
touch .deps
|
||||||
debug:
|
debug: dependencies
|
||||||
crystal build src/blogtool.cr
|
crystal build src/blogtool.cr
|
||||||
|
|
||||||
test: debug
|
test:
|
||||||
cd testsite && ../blogtool
|
cd testsite && ../blogtool
|
||||||
|
|
||||||
install:
|
install:
|
||||||
install blogtool $(PREFIX)/bin/
|
install blogtool $(PREFIX)/bin/
|
||||||
mkdir -p /etc/blogtool
|
mkdir -p /etc/blogtool
|
||||||
install testsite/base.html /etc/blogtool/
|
install testsite/base.html /etc/blogtool/
|
||||||
|
|
|
@ -27,4 +27,4 @@ dist
|
||||||
|-> about.html
|
|-> about.html
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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, as long as the string "## CONTENT\n" is in the template somewhere, as that will be replaced with the article or about page.
|
|
@ -41,16 +41,18 @@ def render_file(filename : String | Path)
|
||||||
end
|
end
|
||||||
|
|
||||||
index = Base
|
index = Base
|
||||||
|
content = ""
|
||||||
Dir.entries("articles").select{ |i| i != "." && i != ".." }.each do |article|
|
Dir.entries("articles").select{ |i| i != "." && i != ".." }.each do |article|
|
||||||
if article[article.size-3, article.size] == ".md"
|
if article[article.size-3, article.size] == ".md"
|
||||||
File.write Path.new("dist", article[0,article.size-3]+".html"), render_file("articles/"+article)
|
File.write Path.new("dist", article[0,article.size-3]+".html"), render_file("articles/"+article)
|
||||||
index += "<h3><a href=\"/"+article[0,article.size-3]+".html\"/>"+article[0,article.size-3].gsub("-", " ")+"</a></h3>\n"
|
content += "<h3><a href=\"/"+article[0,article.size-3]+".html\">"+article[0,article.size-3].gsub("-", " ")+"</a></h3>\n"
|
||||||
else
|
else
|
||||||
File.write Path.new("dist", article+".html"), render_file("articles/"+article)
|
File.write Path.new("dist", article+".html"), render_file("articles/"+article)
|
||||||
index += "<h3><a href=\"/"+article+".html\"/>"+article.gsub("-", " ")+"</a></h3>\n"
|
content += "<h3><a href=\"/"+article+".html\">"+article.gsub("-", " ")+"</a></h3>\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
File.write Path["dist/index.html"], index+"</body></html>"
|
index.gsub("## CONTENT\n") { content }
|
||||||
|
File.write Path["dist/index.html"], index
|
||||||
|
|
||||||
Dir.entries("assets").select{ |i| i != "." && i != ".." }.each do |asset|
|
Dir.entries("assets").select{ |i| i != "." && i != ".." }.each do |asset|
|
||||||
File.copy Path.new("assets", asset), Path.new("dist", "static", asset)
|
File.copy Path.new("assets", asset), Path.new("dist", "static", asset)
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,8 +0,0 @@
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2>yeet</h2>
|
|
||||||
<p><strong>this is</strong> a <em>test</em></p>
|
|
||||||
<p><a href="http://google.com">weeeooo</a></p>
|
|
||||||
</body></html>
|
|
Loading…
Reference in New Issue