summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-09 17:09:27 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-09 17:09:27 -0500
commita70b39250252962df17670cee743d01d1a6f7c16 (patch)
tree58c390dfd181953cb790d3edfc57e79a5406ff08
parent5022d1a0df1534b1cbec1cbee23568f201ea1cc6 (diff)
fix
-rw-r--r--Makefile11
-rw-r--r--config.yaml2
-rw-r--r--lib/page.rb4
-rw-r--r--lib/page_index.rb9
-rw-r--r--lib/page_local.rb4
-rw-r--r--lib/person.rb2
-rw-r--r--lib/sitegen.rb26
-rw-r--r--tmpl/index.atom.erb2
-rw-r--r--tmpl/page.html.erb1
9 files changed, 29 insertions, 32 deletions
diff --git a/Makefile b/Makefile
index 92c3868..2c07400 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
MAKEFLAGS += -j1
# Default target
-all: out/index.html
+all: out/index.html out/main.css
phony += all
# Boilerplate
@@ -20,8 +20,13 @@ clean:
rm -rf out
phony += clean
-# For real files, just let the ./make script take care of it.
-$(sort out/index.html $(filter-out $(phony),$(MAKECMDGOALS))): FORCE
+# Real file rules
+out/%.css: src/%.scss
+ @mkdir -p $(@D)
+ scss --stdin < $< > $@
+
+targets = $(phony) %.css
+$(sort $(filter-out $(targets),out/index.html $(MAKECMDGOALS))): FORCE
./make
# Boilerplate
diff --git a/config.yaml b/config.yaml
index b2f7cd9..267ccb0 100644
--- a/config.yaml
+++ b/config.yaml
@@ -8,7 +8,7 @@ license_uris:
"WTFPL-2": "http://www.wtfpl.net/txt/copying/"
# People
-defualt_author: "Andrew Murrell"
+default_author: "Andrew Murrell"
person_uris:
"Luke Shumaker": "https://lukeshu.com/"
"Andrew Murrell": "https://andrewdm.me/"
diff --git a/lib/page.rb b/lib/page.rb
index 98223c5..20f9701 100644
--- a/lib/page.rb
+++ b/lib/page.rb
@@ -1,4 +1,5 @@
# coding: utf-8
+require 'erb'
require 'set'
require 'category'
@@ -97,3 +98,6 @@ class Page
ret += "</span>\n"
end
end
+
+ERB::new(File::read("tmpl/page.atom.erb")).def_method(Page, 'atom()', "tmpl/page.atom.erb")
+ERB::new(File::read("tmpl/page.html.erb")).def_method(Page, 'html()', "tmpl/page.html.erb")
diff --git a/lib/page_index.rb b/lib/page_index.rb
index fed7e5f..66b528a 100644
--- a/lib/page_index.rb
+++ b/lib/page_index.rb
@@ -3,9 +3,10 @@ require 'erb'
require 'set'
require 'yaml'
+require 'config'
require 'page_local'
require 'page_remote'
-require 'config'
+require 'person'
class IndexPage < LocalPage
def initialize(dirname)
@@ -71,6 +72,9 @@ class IndexPage < LocalPage
def atom_title
_metadata['title']
end
+ def atom_author
+ Person::new(_metadata['author'] || Config::get.default_author)
+ end
def local_intype
return 'markdown'
@@ -95,6 +99,9 @@ class IndexPage < LocalPage
end
@depends
end
+ def url
+ @outurl ||= Config::get.url + local_outfile.sub(/^out/, '').sub(/\/index\.html$/, '/')
+ end
def local_srcurl
return nil
end
diff --git a/lib/page_local.rb b/lib/page_local.rb
index da8689d..7121c8e 100644
--- a/lib/page_local.rb
+++ b/lib/page_local.rb
@@ -1,6 +1,5 @@
# coding: utf-8
require 'date'
-require 'erb'
require 'set'
require 'config'
@@ -121,6 +120,3 @@ class LocalPage < Page
@outurl ||= Config::get.url + local_outfile.sub(/^out/, '')
end
end
-
-ERB::new(File::read("tmpl/page.atom.erb")).def_method(LocalPage, 'atom()', "tmpl/page.atom.erb")
-ERB::new(File::read("tmpl/page.html.erb")).def_method(LocalPage, 'html()', "tmpl/page.html.erb")
diff --git a/lib/person.rb b/lib/person.rb
index 6882dd2..6ad1569 100644
--- a/lib/person.rb
+++ b/lib/person.rb
@@ -20,7 +20,7 @@ class Person
elsif not uri.nil?
return "<a href=\"#{uri}\">#{name}</a>"
else
- return @name
+ return name
end
end
def atom
diff --git a/lib/sitegen.rb b/lib/sitegen.rb
index 765cfbd..ca0c4bf 100644
--- a/lib/sitegen.rb
+++ b/lib/sitegen.rb
@@ -65,12 +65,14 @@ module Sitegen
when @mk[target].nil?
raise "No rule to make target '#{target}'. Stop."
when target.end_with?(".atom")
- write_ifchanged(target) do |file|
+ puts "atom #{target}"
+ write_atomic(target) do |file|
file.puts('<?xml version="1.0" encoding="utf-8"?>')
file.print(@mk[target].atom)
end
when target.end_with?(".html")
- write_ifchanged(target) do |file|
+ puts "html #{target}"
+ write_atomic(target) do |file|
file.print(@mk[target].html)
end
else
@@ -78,10 +80,9 @@ module Sitegen
end
end
- def self.write_ifchanged(outfilename)
+ def self.write_atomic(outfilename)
tmpfilename = "#{File::dirname(outfilename)}/.tmp#{File::basename(outfilename)}"
- # Write our stuff to tmpfile
FileUtils::mkdir_p(File::dirname(tmpfilename))
tmpfile = File::new(tmpfilename, 'wb')
begin
@@ -92,21 +93,6 @@ module Sitegen
raise e
end
tmpfile.close
-
- # Now see if we should replace outfile with tmpfile
- same = false
- begin
- if FileUtils::compare_file(tmpfilename, outfilename)
- same = true
- end
- rescue Errno::ENOENT
- end
-
- # And actually do so
- if same
- File::unlink(tmpfilename)
- else
- File::rename(tmpfilename, outfilename)
- end
+ File::rename(tmpfilename, outfilename)
end
end
diff --git a/tmpl/index.atom.erb b/tmpl/index.atom.erb
index 8719d05..390c02a 100644
--- a/tmpl/index.atom.erb
+++ b/tmpl/index.atom.erb
@@ -5,7 +5,7 @@
<link rel="alternate" type="text/html" href="./"/>
<link rel="alternate" type="text/markdown" href="./index.md"/>
<updated><%= index_pages_leaves.map{|p|p.atom_updated}.sort.last.to_datetime.rfc3339 %></updated>
- <author><%= Person.new(Config::get.default_author).atom %></author>
+ <author><%= atom_author.atom %></author>
<id><%= url %></id>
<% index_pages_leaves.sort_by{|p|p.atom_updated}.reverse.each do |page| %><%= page.atom %><% end %>
diff --git a/tmpl/page.html.erb b/tmpl/page.html.erb
index fb5ddaa..504dbcb 100644
--- a/tmpl/page.html.erb
+++ b/tmpl/page.html.erb
@@ -21,7 +21,6 @@
</form>
</ul>
</nav>
- <p </p>
</header>
<article>
<% if atom_categories.count > 0 %><p>Tags: <% atom_categories.each do |t| %><%= t.html %><% end %></p><% end %>