geri 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afe4c3c38c97222fc7f0ad758241d3686dee8ee1
4
- data.tar.gz: 43935f0a966279c52f547458b93e44c762bbeb7b
3
+ metadata.gz: 25a454f644b7531546f5812327df98695da4ad51
4
+ data.tar.gz: 89ca8936b4d0140ab659849b5185c0c45ab22854
5
5
  SHA512:
6
- metadata.gz: ca6bb66b6ecb6032a9bb02be772f00b577887a53fa53c2d2d033c8833e4965c8993be518c2693182f8b02a959e2a29f43876efb88ed0c78974502b2224294b50
7
- data.tar.gz: b32ed03c47f5b9ca47218fdff083be047022e0c942ab5ba6b450ff6d01544ac5b1229f467198c1174c02bde367e346317ef86fe02c05650c25c56cf0a5fcbf94
6
+ metadata.gz: ecb4a4bb6c4b4ca7f6bebae8fa965e781ce1e20fc3b5003a308ababe3a09835f3f592928d57a639a16dcb4330668afca98c7f5cdba7dce5e9126720620b96bc3
7
+ data.tar.gz: 41d8425317b99fee0b023a2428d3fe1d2c9b98e3c0c5d0a155792cf8655c6c53c1ccf3657d38de777b9d5a6198d6f16a42f2a727b053bcf6667c6403b61193d4
@@ -13,6 +13,7 @@
13
13
  *= require twitter/bootstrap
14
14
  *= require ./admin/app
15
15
  *= require ./admin/skin-blue
16
+ *= require rails_bootstrap_forms
16
17
  *= require_self
17
18
  */
18
19
 
@@ -2,7 +2,7 @@ require_dependency "geri/application_controller"
2
2
 
3
3
  module Geri
4
4
  class Admin::EditorController < ApplicationController
5
- include Geri::Admin::PagesHelper
5
+ include Geri::PagesHelper
6
6
  skip_before_action :verify_authenticity_token, only: [:update_contents]
7
7
 
8
8
 
@@ -3,19 +3,13 @@ module Geri
3
3
  before_action :set_view_path
4
4
 
5
5
  def show
6
- render render_options_for_path(params[:path])
6
+ page = Page.find(params[:path])
7
+ @metadata = page.metadata
8
+ render(file: page.file, layout: 'layout.html.erb', locals: {foo: 'bar'})
7
9
  end
8
10
 
9
11
  private
10
12
 
11
- def render_options_for_path(path)
12
- return { file: 'index.html.erb', layout: 'layout.html.erb' } unless path
13
- if File.exists?(page_root.join("#{path.underscore}.html.erb"))
14
- { file: path.underscore, layout: 'layout.html.erb' }
15
- else
16
- { file: "#{path.underscore}/index", layout: 'layout.html.erb' }
17
- end
18
- end
19
13
 
20
14
  def _normalize_layout(name)
21
15
  name
@@ -1,5 +1,14 @@
1
1
  module Geri
2
- module Admin::PagesHelper
2
+ module PagesHelper
3
+
4
+ def title
5
+ @metadata[:title]
6
+ end
7
+
8
+ def link_to_with_active(name, options = {}, html_options = {}, &block)
9
+ html_options[:class] = html_options[:class] ? html_options[:class] + ' active' : 'active' if current_page?(options)
10
+ link_to name, options, html_options, &block
11
+ end
3
12
 
4
13
  def geri_sanitize(content)
5
14
  ActionController::Base.helpers.sanitize(content, {
@@ -8,6 +17,17 @@ module Geri
8
17
  })
9
18
  end
10
19
 
20
+ def meta_tags
21
+ concat(content_tag(:meta, '', name: :copyright, content: @metadata[:copyright])) if @metadata[:copyright]
22
+ concat(content_tag(:meta, '', name: :description, content: @metadata[:description])) if @metadata[:description]
23
+ concat(content_tag(:meta, '', name: :keywords, content: @metadata[:keywords].join(','))) if @metadata[:keywords]
24
+ concat(content_tag(:meta, '', name: :robots, content: @metadata[:robots])) if @metadata[:robots]
25
+ end
26
+
27
+ def site_name
28
+ Geri::Config.site_name
29
+ end
30
+
11
31
  def editable(name, &block)
12
32
  name = "#{current_page}_#{name}"
13
33
  content = Content.find_by(name: name) && geri_sanitize(Content.find_by(name: name).body)
@@ -0,0 +1,54 @@
1
+ module Geri
2
+
3
+ # Page encapsulates a site page and it's metadata
4
+ class Page
5
+ attr_reader :page_index, :file
6
+
7
+ META_CAPTURE = /\A---(.*)\n---\B/m
8
+
9
+ # Finds a page within the site and returns a new Page instance
10
+ #
11
+ # @param path[string|NilClass] the url path for which to look for the page
12
+ # @return [Page] a page object
13
+ def self.find(path)
14
+ path = '/' unless path
15
+ new(path)
16
+ end
17
+
18
+ # @private
19
+ def initialize(path)
20
+ @path = path
21
+ @file = index_or_name
22
+ end
23
+
24
+ # Returns the metadata found in the metadata section of the page as a symbolized hash
25
+ #
26
+ # @return [Hash] the page metadata
27
+ def metadata
28
+ unless @metadata && capture_metadata
29
+ @metadata ||= YAML.load(capture_metadata)
30
+ end
31
+ @metadata.symbolize_keys!
32
+ end
33
+
34
+ private
35
+
36
+ def capture_metadata
37
+ @captured_metadata ||= META_CAPTURE.match(raw)[1]
38
+ end
39
+
40
+ def raw
41
+ @raw ||= File.read(file)
42
+ end
43
+
44
+ def index_or_name
45
+ return site_root + @path + '/index.html.erb' unless File.exists?(site_root + @path + '.html.erb')
46
+ site_root + @path + '.html.erb'
47
+ end
48
+
49
+ def site_root
50
+ Rails.root.join('site').to_s
51
+ end
52
+
53
+ end
54
+ end
@@ -9,7 +9,7 @@
9
9
  </div>
10
10
  <ul class="sidebar-menu">
11
11
  <li class="header"><%= t('admin.aside.main_navigation') %></li>
12
- <%= render @menu_items %>
12
+ <%= render partial: 'geri/admin/shared/menu_item', collection: @menu_items %>
13
13
  </ul>
14
14
  </section>
15
15
  <!-- /.sidebar -->
@@ -0,0 +1,14 @@
1
+ class GeriTemplateHandler
2
+ def self.call(template)
3
+ options = {
4
+ locals: template.locals,
5
+ virtual_path: template.virtual_path,
6
+ updated_at: template.updated_at
7
+ }
8
+ source = template.source.gsub(Geri::Page::META_CAPTURE, '')
9
+ template = ActionView::Template.new(source, template.identifier, template.handler, options)
10
+ ActionView::Template::Handlers::ERB.call(template)
11
+ end
12
+ end
13
+
14
+ ActionView::Template.register_template_handler(:erb, GeriTemplateHandler)
@@ -9,7 +9,7 @@ class Geri::InstallGenerator < Rails::Generators::Base
9
9
  gsub_file('config/routes.rb', 'Rails.application.routes.draw do', <<-EOF
10
10
  Rails.application.routes.draw do
11
11
  # Sets the mounted location of the Geri CMS, if you wish to mount this elsewhere simply update this line.
12
- mount Geri::Engine => '/'
12
+ mount Geri::Engine => /
13
13
  EOF
14
14
  )
15
15
  end
@@ -1,9 +1,15 @@
1
- <%# METADATA %>
2
- <% title 'GeriCMS' %>
3
- <% keywords 'cms', 'gericms', 'rails cms', 'ruby cms' %>
4
- <% description 'GeriCMS is a powerful Rails based CMS designed from the ground up for developers.' %>
5
-
6
- <%# CONTENT %>
1
+ ---
2
+ title: GeriCMS
3
+ keywords:
4
+ - cms
5
+ - geri cms
6
+ - geri digital
7
+ - rails cms
8
+ - ruby on rails cms
9
+ - ruby cms
10
+ description: GeriCMS is an estensible open source content managment system built from the ground up with developers and
11
+ extensibility in mind.
12
+ ---
7
13
  <nav class="navbar navbar-default">
8
14
  <div class="container">
9
15
  <div class="navbar-header">
@@ -4,9 +4,7 @@ Geri::Config.configure do |c|
4
4
  # c.admin_path = 'admin'
5
5
 
6
6
  #Set the website name
7
- c.site_name = 'GeriCMS'
7
+ # c.site_name = 'GeriCMS'
8
8
 
9
- # Sets the mount point for the engine
10
- # c.mount_point =
11
9
 
12
10
  end
@@ -1,6 +1,6 @@
1
1
  <html>
2
2
  <head>
3
- <title>GeriCMS | <%= page_title %></title>
3
+ <title>GeriCMS | <%= title %></title>
4
4
  <%= meta_tags %>
5
5
  <%= stylesheet_link_tag 'site', media: 'all' %>
6
6
  </head>
@@ -3,14 +3,13 @@ module Geri
3
3
  module Config
4
4
  include ActiveSupport::Configurable
5
5
  config_accessor :admin_path # route to the administrative backend
6
- config_accessor :menu_items, instance_reader: false # menu item registry
6
+ config_accessor :menu_items # menu item registry
7
7
  config_accessor :site_name # name of the site
8
- config_accessor :mount_point # sets the mount point for the Geri::Engine
9
8
 
10
9
  # Defaults
11
10
  self.admin_path = '/admin'
12
11
  self.menu_items = []
13
- self.mount_point = '/'
12
+ self.site_name = 'GeriCMS'
14
13
 
15
14
  def self.register_menu_item(title, path_or_options=nil, options={})
16
15
  self.menu_items << item = MenuItem.new(title, path_or_options, options)
@@ -29,6 +29,12 @@ module Geri
29
29
  %w{ geri/admin/editor.css geri/admin/editor.js }
30
30
  end
31
31
 
32
+ initializer :add_all_site_images_to_assets do
33
+ Dir.glob(Rails.root.join('app', 'site', 'assets', 'images', '**').to_s).each do |asset|
34
+ config.assets.precompile << File.basename(asset)
35
+ end
36
+ end
32
37
 
33
38
  end
39
+
34
40
  end
@@ -1,3 +1,3 @@
1
1
  module Geri
2
- VERSION = "0.0.1"
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - fugufish
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -366,18 +366,18 @@ files:
366
366
  - app/controllers/geri/pages_controller.rb
367
367
  - app/helpers/geri/admin/dashboard_helper.rb
368
368
  - app/helpers/geri/admin/editor_helper.rb
369
- - app/helpers/geri/admin/pages_helper.rb
370
369
  - app/helpers/geri/admin/partials_helper.rb
371
370
  - app/helpers/geri/admin/password_resets_helper.rb
372
371
  - app/helpers/geri/admin/sessions_helper.rb
373
372
  - app/helpers/geri/admin_helper.rb
374
373
  - app/helpers/geri/admin_users_helper.rb
375
374
  - app/helpers/geri/application_helper.rb
376
- - app/helpers/geri/meta_helper.rb
375
+ - app/helpers/geri/pages_helper.rb
377
376
  - app/mailers/application_mailer.rb
378
377
  - app/mailers/geri/admin_user_mailer.rb
379
378
  - app/models/geri/admin_user.rb
380
379
  - app/models/geri/content.rb
380
+ - app/models/geri/page.rb
381
381
  - app/models/geri/password_reset.rb
382
382
  - app/models/geri/session.rb
383
383
  - app/views/geri/admin/admin_users/_form.html.erb
@@ -397,6 +397,7 @@ files:
397
397
  - app/views/layouts/mailer.html.erb
398
398
  - app/views/layouts/mailer.text.erb
399
399
  - config/initializers/geri.rb
400
+ - config/initializers/geri_template_handler.rb
400
401
  - config/initializers/sorcery.rb
401
402
  - config/locales/devise.en.yml
402
403
  - config/locales/en.yml
@@ -1,32 +0,0 @@
1
- module Geri
2
- module MetaHelper
3
- attr_reader :page_title
4
-
5
- def title(text)
6
- @page_title = text
7
- end
8
-
9
- def description(text)
10
- meta description: text
11
- end
12
-
13
- def keywords(*keywords)
14
- meta keywords: keywords
15
- end
16
-
17
- def meta(options=nil)
18
- @meta ||= {}
19
- @meta.reverse_merge!(options) if options
20
- @meta
21
- end
22
-
23
- def meta_tags
24
- html = ''.html_safe
25
- meta.each do |name, content|
26
- html << content_tag(:meta, '', name: name, content: (content.is_a?(Array) ? content.join(', ') : content))
27
- end
28
- html
29
- end
30
-
31
- end
32
- end