Skip to content

Commit

Permalink
Forem now defines its own layout
Browse files Browse the repository at this point in the history
This can be changed to use a different layout, but that other layout should require the forem assets.

Please see the updated documentation for more information: https://github.com/radar/forem/wiki/Theming
  • Loading branch information
radar committed Mar 15, 2014
1 parent f096ac9 commit ebaaa08
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/controllers/forem/admin/base_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Forem
module Admin
class BaseController < ApplicationController
layout Forem.layout

before_filter :authenticate_forem_admin

def index
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/forem/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'cancan'

class Forem::ApplicationController < ApplicationController
layout Forem.layout

rescue_from CanCan::AccessDenied do
redirect_to root_path, :alert => t("forem.access_denied")
end
Expand Down
15 changes: 15 additions & 0 deletions app/views/layouts/forem/default.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Forem</title>
<%= stylesheet_link_tag "forem", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "forem", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<% flash.each do |k,v| %>
<div class='flash <%= k %>'><%= v %></div>
<% end %>
<%= yield %>
</body>
</html>
8 changes: 6 additions & 2 deletions lib/forem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
require 'decorators'

module Forem
mattr_accessor :base_path, :user_class, :theme, :formatter,
mattr_accessor :base_path, :user_class, :formatter,
:default_gravatar, :default_gravatar_image, :avatar_user_method,
:user_profile_links, :email_from_address, :autocomplete_field,
:per_page, :sign_in_path, :moderate_first_post
:per_page, :sign_in_path, :moderate_first_post, :layout


class << self
Expand Down Expand Up @@ -73,5 +73,9 @@ def user_class
end
end
end

def layout
@@layout || "forem/default"
end
end
end
9 changes: 9 additions & 0 deletions lib/generators/forem/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ def mount_engine
end
end

def create_assets
create_file Rails.root + "vendor/assets/stylesheets/forem.css.scss"
create_file Rails.root + "vendor/assets/javascripts/forem.js.coffee" do
%Q{
#= require jquery
}
end
end

def finished
output = "\n\n" + ("*" * 53)
output += %Q{\nDone! Forem has been successfully installed. Yaaaaay!
Expand Down

0 comments on commit ebaaa08

Please sign in to comment.