This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pdfkit' | |
require 'nokogiri' | |
require 'haml' | |
# config/initializers/pdfkit.rb | |
PDFKit.configure do |config| | |
# Note: Often required for Windows OS configuration | |
# config.wkhtmltopdf = '/path/to/wkhtmltopdf' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pdfkit' | |
require 'nokogiri' | |
require 'haml' | |
# config/initializers/pdfkit.rb | |
PDFKit.configure do |config| | |
# Note: Often required for Windows OS configuration | |
# config.wkhtmltopdf = '/path/to/wkhtmltopdf' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/store_stylesheet.rb | |
class StoreStylesheet | |
def initialize(store) | |
@store = store | |
end | |
# The path of the compiled stylesheet, i.e. stores/id-timestamp.css | |
def stylesheet_file | |
filename = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PagesController < ApplicationController | |
before_filter :login_required, :except => [ :show ] | |
# GET /pages | |
# GET /pages.xml | |
def index | |
@pages = Page.find(:all) | |
respond_to do |format| | |
format.html # index.html.erb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DateHelper = { | |
timeAgoInWords: function(from) { | |
return this.distanceOfTimeInWords(new Date(), from); | |
}, | |
distanceOfTimeInWords: function(to, from) { | |
var distance_in_seconds = ((to - from) / 1000); | |
var distance_in_minutes = (distance_in_seconds / 60).floor(); | |
if (distance_in_minutes <= 0) return "less than a minute"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cf http://www.37signals.com/svn/posts/1557-javascript-makes-relative-times-compatible-with-caching | |
var DateHelper = { | |
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time | |
// Ruby strftime: %b %d, %Y %H:%M:%S GMT | |
time_ago_in_words_with_parsing: function(from) { | |
var date = new Date; | |
date.setTime(Date.parse(from)); | |
return this.time_ago_in_words(date); | |
}, |