Skip to content

Commit

Permalink
Convert to using ruby, haml, scss, and AWS cli
Browse files Browse the repository at this point in the history
  • Loading branch information
rdj committed Apr 3, 2015
1 parent 73a48c8 commit 190e35b
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
public/
.sass-cache/
1 change: 1 addition & 0 deletions .ruby-gemset
@@ -0,0 +1 @@
latentninja
1 change: 1 addition & 0 deletions .ruby-version
@@ -0,0 +1 @@
2.2.1
7 changes: 7 additions & 0 deletions Gemfile
@@ -0,0 +1,7 @@
# -*- mode: ruby -*-

source 'https://rubygems.org'

gem 'haml'
gem 'sass'
gem 'thin'
22 changes: 22 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,22 @@
GEM
remote: https://rubygems.org/
specs:
daemons (1.2.2)
eventmachine (1.0.7)
haml (4.0.6)
tilt
rack (1.6.0)
sass (3.4.13)
thin (1.6.3)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0)
rack (~> 1.0)
tilt (2.0.1)

PLATFORMS
ruby

DEPENDENCIES
haml
sass
thin
16 changes: 0 additions & 16 deletions Makefile.PL

This file was deleted.

29 changes: 29 additions & 0 deletions Rakefile
@@ -0,0 +1,29 @@
require 'bundler'
Bundler.require

require 'yaml'
require 'pp'

desc "Generate www.latentninja.com homepage"
task :default do
config = YAML.load(File.read('index.yml'))
column_count = config.count

snippet = "$column_count: #{column_count};\n"
sass_input = snippet + File.read('index.scss')
sass = Sass::Engine.new( sass_input, syntax: :scss, style: :compressed )
raw_css = sass.render

haml_input = File.read('index.haml')
haml = Haml::Engine.new( haml_input, ugly: true, remove_whitespace: true )
raw_html = haml.render( Object.new, { link_columns: config, raw_css: raw_css } )

File.open( 'public/index.html', 'w' ) do |f|
f.print raw_html
end
end

desc "Start local dev server"
task :server do
exec 'bundle exec rackup'
end
2 changes: 2 additions & 0 deletions config.ru
@@ -0,0 +1,2 @@
use Rack::Static, :urls => [""], :root => 'public', :index => 'index.html'
run ->{ [404, nil, nil] }
17 changes: 17 additions & 0 deletions index.haml
@@ -0,0 +1,17 @@
!!! 5
%html( lang="en" )
%head
%meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
%title Startup Links for Ryan D Johnson
:css
#{raw_css}
%body
- link_columns.each do |column|
.c
- column.each do |link_group|
.g
.l= link_group['group_name']
%ul
- link_group['links'].each do |link|
%li
%a{ href: link['uri'] }= link['name']
29 changes: 0 additions & 29 deletions index.html.tt

This file was deleted.

7 changes: 4 additions & 3 deletions index.css.tt → index.scss
@@ -1,9 +1,10 @@
[% SET column_width = ( 95 div column_count ) %]
$column_width: floor( 95 / $column_count );

.c {
float: left;
clear: none;
padding: 0 5px;
width: [% column_width %]%;
width: percentage( $column_width * 0.01 );
}

.g {
Expand Down Expand Up @@ -35,7 +36,7 @@ body {
margin: auto;
padding: 0;
padding-top: 1em;
width: [% column_width * column_count %]%;
width: percentage( $column_width * $column_count * 0.01 );
background-color: #334;
}

Expand Down
16 changes: 1 addition & 15 deletions index.yml
Expand Up @@ -220,24 +220,10 @@
- name: s3vars.sh
uri: https://gist.github.com/453419
-
# - group_name: ms
# links:
# - name: msmail
# uri: https://mail.windows.microsoft.com
# - name: ras
# uri: https://remote.team.partners.extranet.microsoft.com/ras.aspx
# - name: ts
# uri: https://redmondts.microsoft.com
# - name: im
# uri: https://im.microsoft.com/
# - name: store
# uri: https://shop.ecompanystore.com/microsoft/mic_adfs_login.aspx
- group_name: feeds
links:
- name: rss
uri: http://reader.google.com/
- name: lj
uri: http://www.livejournal.com/users/tekman/friends
uri: http://feedly.com
- name: facebook
uri: http://www.facebook.com
- name: twitter
Expand Down
36 changes: 0 additions & 36 deletions mkindex.pl

This file was deleted.

Empty file added public/.gitkeep
Empty file.
16 changes: 12 additions & 4 deletions publish.sh
@@ -1,9 +1,17 @@
#!/bin/bash

. $(dirname $0)/s3vars.sh
if [[ ! -x $(which aws) ]]; then
echo "Requires AWS cli (brew install aws)" 1>&2
exit 1
fi

SOURCE=$(dirname $0)/public/
BUCKET=www.latentninja.com
DEST=/
export AWS_DEFAULT_REGION=us-east-1

SRC=$(dirname $0)/public/
DST=/

source $(dirname $0)/s3vars.sh

aws s3 sync public s3://${BUCKET}/ --exclude .gitkeep

s3sync -p -r --expires="Mon, 09 Dec 2019 04:45:17 GMT" --cache-control="max-age=311040000" --progress ${SOURCE} ${BUCKET}:${DEST}

0 comments on commit 190e35b

Please sign in to comment.