parent:
21802ef2dde6b8415dea1084c6dd42faeb6a3329
Nick Mykins <nick.mykins@gmail.com>
2014-11-08T08:43:08-05:00
link to individual posts
diff --git a/README.md b/README.md
index 043265a0b866553b61f8b6e37b7267b8701eed2e..726590bb8c3b1d6864a7f30a9a73b233a1ed10be 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,11 @@
-# a minimalist cowsay blog
+# a minimal cowsay blog
-example:
+usage:
+
+ # Make necessary directories
+ mkdir posts cowposts cowposts_html public_html;
- mkdir posts cowposts public_html
+ # Moo!
echo "hello world" > hello_world
. cowpost hello_world
. deploy
diff --git a/cowposttemplate.html b/cowposttemplate.html
new file mode 100644
index 0000000000000000000000000000000000000000..eb5fed3e148b3a0b4be2c86606d8bb887ea1bd00
--- /dev/null
+++ b/cowposttemplate.html
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <title>nick's tilde.farm page</title>
+ </head>
+ <body>
+ <link rel="stylesheet" type="text/css" href="../style.css">
+ <h1>~ nick at tilde dot farm ~</h1>
+ <pre>
+ <p class=cowdate>{{cowpost.date}}</p>{{cowpost.cowtext}}
+ </pre>
+ <a href="../index.html">~ home</a>
+ </body>
+</html>
diff --git a/cowtemplate.html b/cowtemplate.html
index 24c44e5a27f3cd2332f52cc0e9b4c8de6a03aedb..ecba2e6ac26c433d9bfb1cf6209459b8a69fe9eb 100644
--- a/cowtemplate.html
+++ b/cowtemplate.html
@@ -3,32 +3,15 @@ <head>
<title>nick's tilde.farm page</title>
</head>
<body>
- <style type="text/css">
- body {background-color: black;
- color: rgb(255,225,148);
- width: 800;
- padding: 4em;
- font-family: Ubuntu Mono,
- DejaVu Sans Mono,
- Droid Sans Mono,
- Liberation Mono,
- Monospace;}
- a { color: rgb(0,255,0); }
- a:visited { color: rgb(0,192,0) }
- a:hover { color: white; }
- h1 { font-size: 18pt;
- color: rgb(246,96,171);
- text-align: center; }
- * { font-size: 12pt; }
- </style>
+ <link rel="stylesheet" type="text/css" href="style.css">
<h1>~ nick at tilde dot farm ~</h1>
<h2>Optimized for 800x600 -- Welcome to the farm.<br><br>You know when you talk to God as a kid, but then you realize that what you were trying to convince yourself was God responding to your prayers was just more of your own internal monologue? I do.</h2>
<div>
<div style="float:left">
- <pre>{% for cowpost in cowposts %}
-<font color="cyan">{{cowpost.date}}</font>
-{{cowpost.cowtext}}
-{% endfor %}</pre>
+{% for cowpost in cowposts %}<pre>
+<a href="cowposts/{{cowpost.htmltitle}}"><p class=cowdate>{{cowpost.date}}</p></a>{{cowpost.cowtext}}
+</pre>
+{% endfor %}
</div>
<div style="float:right">
<h2>Here's some other stuff:</h2>
@@ -37,6 +20,7 @@ <li><a href="http://lt-dan.tumblr.com">Lieutenant Dan</a>
<li><a href="http://nickmykins.com:5000">Random Java class name</a>
<li><a href="http://comics-jam.tumblr.com">Comics Jam</a>
<li><a href="http://github.com/nmyk/cowsay-blog">This site</a>
+ <li><a href="http://tilde.farm">~ Join us ~</a>
</ul>
<br>
About me: <br>
@@ -51,6 +35,8 @@ (__)\ )\/\
||----w |
<font color=green>\|/</font> || ||
</pre>
+ <br>
+ <a href="cowposts">All posts</a>
</div>
</body>
</html>
diff --git a/deploy b/deploy
index f61b90ac5db4357449d7742fb4c2b84ec90b3deb..c32ab7d3388a32aff1fe99374a7b3933f906c770 100755
--- a/deploy
+++ b/deploy
@@ -1,4 +1,5 @@
#!/bin/bash
python deploy.py
-scp public_html/index.html nick@tilde.farm:~/public_html/
+scp public_html/index.html public_html/style.css nick@tilde.farm:~/public_html/
+scp cowposts_html/*.html nick@tilde.farm:~/public_html/cowposts/
diff --git a/deploy.py b/deploy.py
index 381b583c3b8367930952f4e32fdf547d77ef61c9..2cff45f153d005e5cd72bab76efd4ede3de1caf6 100644
--- a/deploy.py
+++ b/deploy.py
@@ -9,11 +9,11 @@ template_loader = jinja2.FileSystemLoader(searchpath=PATH)
template_env = jinja2.Environment(loader=template_loader)
-def make_cowdict(cowlinelists):
- cowdate = lambda moo: moo[0].strip()
- cowtext = lambda moo: ''.join(moo[1:])
- return {cowdate(cowlinelist): cowtext(cowlinelist)
- for cowlinelist in cowlinelists}
+def make_cowdict(cownamedlines):
+ cowdate = lambda moo: moo[1][0].strip()
+ cowtext = lambda moo: ''.join(moo[1][1:])
+ return {cowdate(cownamedpost): (cownamedpost[0], cowtext(cownamedpost))
+ for cownamedpost in cownamedlines}
def cowblogsort(cowdict):
@@ -21,21 +21,30 @@ cowarrows = [arrow.get(cowdate, COWDATE_FMT)
for cowdate in cowdict]
cowblogorder = [moo.format(COWDATE_FMT)
for moo in sorted(cowarrows)[::-1]]
- return [{'date': cowdate, 'cowtext': cowdict[cowdate]}
+ return [{'htmltitle': cowdict[cowdate][0].replace('cowpost','html'),
+ 'date': cowdate,
+ 'cowtext': cowdict[cowdate][1]}
for cowdate in cowblogorder]
def cowmain():
os.chdir(COWPOSTPATH)
cowlinelists = []
- for cowpostfile in os.listdir(COWPOSTPATH):
+ cowpostfiles = os.listdir(COWPOSTPATH)
+ for cowpostfile in cowpostfiles:
with open(cowpostfile, 'r') as moo:
cowlinelists.append(moo.readlines())
- cowdict = make_cowdict(cowlinelists)
+ cownamedlines = zip(cowpostfiles, cowlinelists)
+ cowdict = make_cowdict(cownamedlines)
cowposts = cowblogsort(cowdict)
cowtemplate = template_env.get_template('cowtemplate.html')
+ cowposttemplate = template_env.get_template('cowposttemplate.html')
with open(PATH + '/public_html/index.html', 'w') as moo:
moo.write(cowtemplate.render(cowposts=cowposts))
+ for cowpost in cowposts:
+ with open(PATH + '/cowposts_html/%s'
+ % cowpost['htmltitle'], 'w') as moo:
+ moo.write(cowposttemplate.render(cowpost=cowpost))
if __name__ == '__main__':