Top Level Namespace

Defined Under Namespace

Modules: CmsUtils, Kernel, Padrino Classes: Uploader

Constant Summary collapse

TEMPLATE_FILE_PATHS =
%w( lib/cms_utils.rb 
  lib/uploader.rb
  app/views/layouts/application.erb 
  app/views/main.erb
  app/views/sitemap.erb
  app/views/sitemap.xml.erb
  app/views/contents/show.erb
  app/views/contents/index.erb
  admin/views/layouts/application.erb
  admin/controllers/images.rb
  public/stylesheets/application.css
  public/admin/stylesheets/base.css
  public/admin/javascripts
  public/admin/images
)
PADRINO_ROOT =
File.dirname(__FILE__)
SESSION_KEY_SETTING =
"set :session_id, :_padrino_cms_session_id"
APP_INIT =

Set up the session key, the cms filter and a couple of basic routes

TODO: Might be simpler to copy the whole app.rb into place.

<<-APP

  #{SESSION_KEY_SETTING}

  before do
    @current_account = CmsUtils.current_account(session[settings.session_id])
    @contents = Content.where(:path => CmsUtils.default_path(request))
  end

  get "/sitemap", :provides => [:html, :xml] do
    @title = "Sitemap"
    @pages = Content.where("path LIKE '/%'")
    render "sitemap"
  end
  
  # IMPORTANT That this route is the last in the app as :priority => :low does not seem to do what I expected.
  # Maybe I just need to RTFM again.
  #
  get "/*path", :priority => :low do
    render "main"
  end

APP
DATE_FORMAT =

Set a default date format

<<-DATE_FORMAT
  Time::DATE_FORMATS.merge!(:default => "%Y-%m-%d %H:%M")
DATE_FORMAT
LOREM_IPSUM =
<<-END
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mauris diam, vulputate ac vulputate non, iaculis ut dui. Aliquam consequat posuere tincidunt. Nunc tincidunt varius velit eu egestas. Ut sagittis nulla ac arcu fringilla vitae congue est tincidunt. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vivamus id purus in eros adipiscing lacinia. Morbi sed justo dui, viverra pretium nunc. Morbi tristique leo in urna lacinia ac gravida eros tincidunt. Vivamus lobortis facilisis elit in tristique. Vivamus laoreet euismod dui quis iaculis.</p>
<p>This is default text generated by the cms project template, you probably want to start by <a href="/admin/contens/edit/1">editing this</a>.</p>
END
DEFAULT_CONTENT =
<<-END
    Content.create(
      :path => '/', :title => 'Lorem Ipsum',
      :body => '#{LOREM_IPSUM}'
    )

END
CONTENT_INDEX_ROUTE =
<<-CONTENT
      @contents = Content.all(:order => 'created_at desc')
      render 'contents/index'
CONTENT
CONTENT_SHOW_ROUTE =
<<-CONTENT
      @content = Content.find_by_id(params[:id])
      render 'contents/show'
CONTENT
CONTENT_MODEL =
<<-CONTENT
  belongs_to :account
  validates_presence_of :path
  validates_presence_of :title
  validates_presence_of :body
CONTENT
IMAGE_UPLOAD_GEMS =
<<-GEMS

# Gems needed for image upload
gem 'carrierwave'
gem 'mini_magick'
gem 'fog'

GEMS
HELPER_METHODS =
<<-HELPER
 include CmsUtils
HELPER