Skip to content

Instantly share code, notes, and snippets.

@airios
Created April 13, 2011 18:56
Show Gist options
  • Save airios/918143 to your computer and use it in GitHub Desktop.
Save airios/918143 to your computer and use it in GitHub Desktop.
sample nesta app.rb
# Use the app.rb file to load Ruby code, modify or extend the models, or
# do whatever else you fancy when the theme is loaded.
require 'rubygems'
require 'sinatra'
module Nesta
class App
helpers do
# Add new helpers here.
def set_common_variables
@menu_items = Nesta::Menu.for_path('/')
@site_title = Nesta::Config.title
set_from_config(:title, :subtitle, :google_analytics_code)
@heading = @title
end
def get_article_categories
@page.find_articles_with_categories
end
end
# Add new routes here.
end
class Page
def find_articles_with_categories
Page.find_articles.select{ |a| !a.categories.empty? }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment