"
10 |
11 | lazy val about = templatizeFile(new File(Config.template),
12 | immutable.Map("XTITLE" -> "About",
13 | "XBODY" -> aboutHTML))
14 |
15 | def write = writeFile(new File(Config.aboutPath), about)
16 | }
17 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | CLASSES = src/classes
2 | CLASSPATH = src/lib/jtextile.jar:src/lib/gnu-regexp-1.1.4.jar
3 |
4 | .PHONY: all clean cleanwww post sync
5 |
6 | all: clean run
7 |
8 | run: src/classes/net/al3x/blog/Blog.class
9 | scala -classpath $(CLASSES):$(CLASSPATH) net.al3x.blog.Blog
10 |
11 | src/classes/%.class:
12 | fsc -d src/classes -classpath $(CLASSPATH) `find src/ -name \*.scala -print`
13 |
14 | clean:
15 | rm -rf src/classes/*
16 |
17 | cleanwww:
18 | rm -rf www/*
19 |
20 | post:
21 | scala -classpath $(CLASSES):$(CLASSPATH) net.al3x.blog.Blog -n
22 |
23 | rebuild:
24 | scala -classpath $(CLASSES):$(CLASSPATH) net.al3x.blog.Blog -f
25 |
26 | sync:
27 | rsync -avz -e ssh /path/to/your/blog/www/ you@your.host:/var/www/blog
28 |
--------------------------------------------------------------------------------
/posts/2009/01/31/test-post.textile:
--------------------------------------------------------------------------------
1 | h1. Test Post
2 |
3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque lobortis vehicula magna. Praesent auctor hendrerit mauris. Etiam consectetur. Nunc ac augue non justo commodo eleifend. Duis quis enim. Aenean vehicula mattis tortor. Aliquam mattis. Maecenas et ante. Donec augue. Etiam vitae leo at justo feugiat aliquam. Morbi fringilla dignissim ligula. Integer ipsum lectus, sagittis a, tristique pretium, elementum vitae, ligula. Quisque ac massa. Curabitur vitae libero. Suspendisse at quam eget nisl convallis condimentum.
4 |
5 | Duis nunc. Morbi eu neque. Fusce tempor risus. Sed luctus. Curabitur non mauris. Pellentesque lorem. Etiam pretium dui et lectus. Suspendisse at est non turpis rhoncus imperdiet. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis sit amet pede. In tempus. Phasellus vulputate risus non dui.
--------------------------------------------------------------------------------
/posts/2009/02/01/another-test-post.textile:
--------------------------------------------------------------------------------
1 | h1. Another Test Post
2 |
3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque lobortis vehicula magna. Praesent auctor hendrerit mauris. Etiam consectetur. Nunc ac augue non justo commodo eleifend. Duis quis enim. Aenean vehicula mattis tortor. Aliquam mattis. Maecenas et ante. Donec augue. Etiam vitae leo at justo feugiat aliquam. Morbi fringilla dignissim ligula. Integer ipsum lectus, sagittis a, tristique pretium, elementum vitae, ligula. Quisque ac massa. Curabitur vitae libero. Suspendisse at quam eget nisl convallis condimentum.
4 |
5 | Duis nunc. Morbi eu neque. Fusce tempor risus. Sed luctus. Curabitur non mauris. Pellentesque lorem. Etiam pretium dui et lectus. Suspendisse at est non turpis rhoncus imperdiet. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis sit amet pede. In tempus. Phasellus vulputate risus non dui.
--------------------------------------------------------------------------------
/README.textile:
--------------------------------------------------------------------------------
1 | h1. Simple Scala Blog
2 |
3 | A lightweight blogging system, designed to transmute a directory of Textile files into an equivalent directory of HTML files with a minimum of fuss.
4 |
5 | h2. Rationalization
6 |
7 | Writing a custom blogging system is a wholly unnecessary act. This system was written so the author could muck about with Scala. Though there's some basic attempt at providing a configuration mechanism, templates and logic are currently too intertwined. Improving this is an exercise for the reader/forker.
8 |
9 | You're encouraged to borrow chunks of code you fancy. The good parts are mostly the use of XML literals. You might find the FileHelpers trait handy, as it provides easy-to-use methods for stuff that should really be in java.io.File or similar.
10 |
11 | h2. Requirements
12 |
13 | * Scala (tested with 2.7.2 final)
14 | * GNU Make
15 | * JTextile (included, but is kind of wonky)
16 | * GNU RegExp for Java (included)
17 |
18 | h2. License
19 |
20 | Licensed under the "Apache Public License, Version 2":http://www.apache.org/licenses/LICENSE-2.0.html.
21 |
--------------------------------------------------------------------------------
/src/Blog.scala:
--------------------------------------------------------------------------------
1 | package net.al3x.blog
2 |
3 | import java.io.File
4 | import scala.collection.{immutable, mutable}
5 | import scala.collection.jcl
6 | import scala.xml.XML
7 |
8 | object Blog extends FileHelpers {
9 | def main(args: Array[String]) {
10 | val posts = findPosts(new File(Config.postDir))
11 | val lastTenPosts = posts.reverse.slice(0, 10)
12 |
13 | if (args.isDefinedAt(0)) {
14 | args(0) match {
15 | case "-f" => posts.foreach(post => { post.write; print(".") }); println("Done.")
16 | case "-n" => Post.newPost
17 | case _ => println("Unknown argument."); System.exit(-1)
18 | }
19 | } else {
20 | lastTenPosts.foreach(post => { post.write; print(".") }); println("Done.")
21 | }
22 |
23 | // copy static files
24 | copyAllFiles(Config.staticDir, Config.wwwDir)
25 |
26 | // generate dynamic files
27 | new About(Config.aboutPost).write
28 | new Archive(posts).write
29 | new Sitemap(posts).write
30 | new AtomFeed(lastTenPosts).write
31 | new Index(lastTenPosts).write
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/static/50x.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Missing Post?
8 |
9 |
10 |