Skip to content

Commit

Permalink
Local assets, code highlighting, better color management.
Browse files Browse the repository at this point in the history
All assets are now loaded locally (jQuery, font-awesome). They are kept in the `public` folder in each file's respective subdirectory.

Code highlighting is handled by Rouge (a Pygments compatible markdown codeblock renderer). Definitions for the highlights are defined in `_pygments.scss`.

All colors are now managed in `_variables.scss`. This includes shading and special definitions. For example, the colors for the navigation bar are defined at the end of `_variables.scss` with the prefix `$nav-`. This should help keep colors consistent across the entire site.
  • Loading branch information
faultyserver committed Apr 6, 2017
1 parent d610b32 commit c828c99
Show file tree
Hide file tree
Showing 20 changed files with 459 additions and 95 deletions.
18 changes: 16 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
source 'https://rubygems.org'

# Use HAML for markup
gem 'haml'
# Use the redcarpet and coderay for better Markdown and code prettifying.
gem 'redcarpet'
gem 'rouge'

# Use SASS for styles
gem 'sass'

# Use guard to compile static assets
gem 'guard'
gem 'guard-haml'
gem 'guard-sass'

gem 'pandoc-ruby'
# Guard sometimes has issues with readline.
gem 'rb-readline'

# Use Sinatra as a thin Rack wrapper
gem 'sinatra'

# Thin is a more eventful webserver than WEBrick
gem 'thin'

# Out-of-process auto-reloading when files change
gem 'rerun'
19 changes: 13 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ GEM
remote: https://rubygems.org/
specs:
coderay (1.1.1)
daemons (1.2.4)
eventmachine (1.2.3)
ffi (1.9.18)
formatador (0.2.5)
guard (2.14.1)
Expand All @@ -13,9 +15,6 @@ GEM
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-haml (1.1.2)
guard (~> 2.0)
haml (>= 3.0)
guard-sass (1.6.1)
guard (>= 2.8.0)
sass (>= 3.1)
Expand All @@ -31,7 +30,6 @@ GEM
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
pandoc-ruby (2.0.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand All @@ -43,8 +41,10 @@ GEM
rb-inotify (0.9.8)
ffi (>= 0.5.0)
rb-readline (0.5.4)
redcarpet (3.4.0)
rerun (0.11.0)
listen (~> 3.0)
rouge (2.0.7)
ruby_dep (1.5.0)
sass (3.4.23)
shellany (0.0.1)
Expand All @@ -53,6 +53,10 @@ GEM
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
slop (3.6.0)
thin (1.7.0)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (0.19.4)
tilt (2.0.7)

Expand All @@ -61,12 +65,15 @@ PLATFORMS

DEPENDENCIES
guard
guard-haml
guard-sass
pandoc-ruby
haml
rb-readline
redcarpet
rerun
rouge
sass
sinatra
thin

BUNDLED WITH
1.13.7
7 changes: 0 additions & 7 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
directories %w(src data) \
.select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}

guard :haml, input: 'src/views', output: 'docs', run_at_start: true do
watch(/^.+(\.html\.haml)$/)
end

guard 'sass', input: 'src', output: 'public', smart_partials: true do
watch(%r{^styles/(.+\.s[ac]ss)$})
end
64 changes: 32 additions & 32 deletions data/rpcs/timetable.service_times.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,59 +50,59 @@ samples:
call: |-
timetable.service_times('BUS123', '1B')
return: |-
// Array of service records.
// This array will always contain 7 entries, each one representing a day of the
// week. The first entry will always correspond to the current date according
// to the RPC provider.
// In this example, the first entry is a Saturday. The final entry would be the
// following Friday.
# Array of service records.
# This array will always contain 7 entries, each one representing a day of the
# week. The first entry will always correspond to the current date according
# to the RPC provider.
# In this example, the first entry is a Saturday. The final entry would be the
# following Friday.
[
// Service record
# Service record
(
// Date of service entry
20170325, // = Saturday
// Array of visit intervals
# Date of service entry
20170325, #=> Saturday
# Array of visit intervals
[
// Interval record
# Interval record
(
// time range of visit interval
# time range of visit interval
(06:45:00, 07:50:00),
// visit interval
# visit interval
00:00:10
),
// mid-day changes to a service's visit interval are represented as
// separate elements in the intervals array.
((08:00:00, 16:55:00), 00:00:05), // = 8am- 4:55pm, every 5 minutes
((17:00:00, 22:50:00), 00:00:10) // = 5pm-10:50pm, every 10 minutes
# mid-day changes to a service's visit interval are represented as
# separate elements in the intervals array.
((08:00:00, 16:55:00), 00:00:05), #=> 8am- 4:55pm, every 5 minutes
((17:00:00, 22:50:00), 00:00:10) #=> 5pm-10:50pm, every 10 minutes
]
),
// Dates with only one interval record will still contain that record in an
// array to maintain consistency.
# Dates with only one interval record will still contain that record in an
# array to maintain consistency.
(
20170326, // = Sunday
20170326, #=> Sunday
[
((00:00:00, 03:00:00), 00:00:30), // = 5pm-10:50pm, every 10 minutes
((00:00:00, 03:00:00), 00:00:30), #=> 5pm-10:50pm, every 10 minutes
((09:00:00, 22:00:00), 00:00:30),
// Intervals that wrap the midnight boundary represent the end of their
// time range as a duration since the most recent midnight. This *should*
// never be later than the start of the time range.
((22:00:00, 03:00:00), 00:00:30) // = 5pm-10:50pm, every 10 minutes
# Intervals that wrap the midnight boundary represent the end of their
# time range as a duration since the most recent midnight. This *should*
# never be later than the start of the time range.
((22:00:00, 03:00:00), 00:00:30) #=> 5pm-10:50pm, every 10 minutes
]
),
// For consistency, dates on which no service is provided will contain a blank
// array value.
# For consistency, dates on which no service is provided will contain a blank
# array value.
(
20170327, // = Monday
20170327, #=> Monday
[]
),
// Even if multiple dates contain the same interval records, they will be
// listed as distinct service records. It is the client's responsibility to
// group these records by date if desired.
# Even if multiple dates contain the same interval records, they will be
# listed as distinct service records. It is the client's responsibility to
# group these records by date if desired.
(
20170328, // = Tuesday
20170328, #=> Tuesday
[
((06:45:00, 07:50:00), 00:00:10),
((08:00:00, 16:55:00), 00:00:05),
Expand Down
57 changes: 57 additions & 0 deletions ext/haml/filters/markdown.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require 'haml'
require 'redcarpet'
require './ext/rouge.rb'


module Haml::Filters
remove_filter("Markdown") #remove the existing Markdown filter

module Markdown # the contents of this are as before, but without the lazy_require call
include Haml::Filters::Base


def render(text)
markdown.render(text)
end


private

def markdown
@markdown ||= Redcarpet::Markdown.new(renderer, extensions)
end

def renderer
@renderer ||= Ext::RougeRenderer.new(render_options)
end

def render_options
{
filter_html: true,
hard_wrap: true,
no_styles: true,
prettify: true,
safe_links_only: true,
with_toc_data: false
}
end

def extensions
{
autolink: true,
fenced_code_blocks: true,
disable_indented_code_blocks: true,
footnotes: false,
highlight: true,
no_images: true,
no_intra_emphasis: true,
quote: true,
space_after_headers: false,
strikethrough: true,
superscript: true,
tables: true,
underline: true
}
end
end
end
9 changes: 9 additions & 0 deletions ext/rouge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'redcarpet'
require 'rouge'
require 'rouge/plugins/redcarpet'

module Ext
class RougeRenderer < Redcarpet::Render::HTML
include Rouge::Plugins::Redcarpet # yep, that's it.
end
end
4 changes: 4 additions & 0 deletions proto.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require 'sinatra'
require 'yaml'

# Core extensions
Dir['./ext/**/*.rb'].each{ |f| require f }

# Controllers
Dir['./controllers/**/*.rb'].each{ |f| require f }
Binary file added public/fonts/fontawesome-webfont.woff2
Binary file not shown.
4 changes: 4 additions & 0 deletions public/js/jquery.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions public/styles/font-awesome.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit c828c99

Please sign in to comment.