geri 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d797e72361923ed11722b43b8b3d546d5b14bb3f
4
- data.tar.gz: a88e4adad49a183ed1d987db3553d34fe2870a27
3
+ metadata.gz: 4bd21a0f527359b20935d17812b188c81a1e5039
4
+ data.tar.gz: c577ba2ef036e0f54f0b78e079cee048b4ef1759
5
5
  SHA512:
6
- metadata.gz: 5aa76f5e159d1d5feccb4b5377f9880af863cc4f380ed1bed4d06ed9f48325870008617917b36136b493427a3d9befed1dfa024c13deb7f2670681035412dd90
7
- data.tar.gz: 8dc30f7b9224ad0f25a147265286883da7e725c79aa3c587b6dced48d4d5de859eccdf27cc6e5b83f6698eebd90679928ed7dfc9ffefbacb3eda1e5de675ed74
6
+ metadata.gz: 5a354bff2653c2ee996060db23cce15fce4b7f797e513876715af2d291ab87436e72ad4f8b98543345abe4f3d6e2b3323a0dd2c9bd07bf7197e7002de77653f5
7
+ data.tar.gz: d8690125483c74f82ecf4190c478415e39867013369abe3ac1b1a41259dc8b2e6cc2b91c9d818929274d66cf33fb0f2af0845b838b0fad8fd7d5ea0f2dd375c0
@@ -1,7 +1,10 @@
1
1
  #geri-editor {
2
2
  @import 'twitter/bootstrap';
3
3
  @import './skin-blue';
4
-
4
+ z-index: 9999999;
5
+ .container {
6
+ border: none;
7
+ }
5
8
  .navbar, .navbar > .container, .navbar .navbar-brand {
6
9
  height: 32px;
7
10
  min-height: 32px;
@@ -1,26 +1,42 @@
1
1
  module Geri
2
2
  class PagesController < ApplicationController
3
3
  before_action :set_view_path
4
+ helper_method :current_site
4
5
 
5
6
  def show
6
- page = Page.find(params[:path])
7
+ page = Page.find(params[:path], current_site, lookup_context)
7
8
  @metadata = page.metadata
8
- render(file: page.file, layout: 'layout.html.erb', locals: {foo: 'bar'})
9
+ render inline: page.content, layout: 'layout.html.erb'
9
10
  end
10
11
 
11
12
  private
12
13
 
14
+ def current_site
15
+ Geri::Config.sites[request.host] || Geri::Config.sites[:default]
16
+ end
17
+
13
18
 
14
19
  def _normalize_layout(name)
15
20
  name
16
21
  end
17
22
 
18
- def page_root
19
- Rails.root.join('app', 'site')
23
+ def site_root
24
+ current_site.root
20
25
  end
21
26
 
22
27
  def set_view_path
23
- prepend_view_path(page_root.to_s)
28
+ prepend_view_path(Rails.root.join('app', 'site').to_s)
29
+ prepend_view_path(site_root.to_s) # base path
30
+ if params[:path]
31
+ parts = params[:path].split('/')
32
+ parts.each_index do |index|
33
+ if index == 0
34
+ prepend_view_path(site_root.join(parts[index]).to_s)
35
+ else
36
+ prepend_view_path(site_root.join(*parts[0..index]).to_s)
37
+ end
38
+ end
39
+ end
24
40
  end
25
41
 
26
42
  end
@@ -5,6 +5,14 @@ module Geri
5
5
  @metadata[:title]
6
6
  end
7
7
 
8
+ def site_name
9
+ current_site.name
10
+ end
11
+
12
+ def current_site
13
+ Geri::Config.sites[request.host] || Geri::Config.sites[:default]
14
+ end
15
+
8
16
  def link_to_with_active(name, options = {}, html_options = {}, &block)
9
17
  html_options[:class] = html_options[:class] ? html_options[:class] + ' active' : 'active' if current_page?(options)
10
18
  link_to name, options, html_options, &block
@@ -24,10 +32,6 @@ module Geri
24
32
  concat(content_tag(:meta, '', name: :robots, content: @metadata[:robots])) if @metadata[:robots]
25
33
  end
26
34
 
27
- def site_name
28
- Geri::Config.site_name
29
- end
30
-
31
35
  def editable(name, &block)
32
36
  name = "#{current_page}_#{name}"
33
37
  content = Content.find_by(name: name) && geri_sanitize(Content.find_by(name: name).body)
@@ -2,7 +2,10 @@ module Geri
2
2
 
3
3
  # Page encapsulates a site page and it's metadata
4
4
  class Page
5
- attr_reader :page_index, :file
5
+
6
+ class PageNotFoundError < ActionController::RoutingError;
7
+ end
8
+ attr_reader :page_index
6
9
 
7
10
  META_CAPTURE = /\A---(.*)\n---\B/m
8
11
 
@@ -10,44 +13,57 @@ module Geri
10
13
  #
11
14
  # @param path[string|NilClass] the url path for which to look for the page
12
15
  # @return [Page] a page object
13
- def self.find(path)
14
- path = '/' unless path
15
- new(path)
16
+ def self.find(path, current_site, lookup_context)
17
+ path = '' unless path
18
+ new(path, current_site, lookup_context)
16
19
  end
17
20
 
18
21
  # @private
19
- def initialize(path)
20
- @path = path
21
- @file = index_or_name
22
+ def initialize(path, current_site, lookup_context)
23
+ @path = path
24
+ @current_site = current_site
25
+ @lookup_context = lookup_context
22
26
  end
23
27
 
24
28
  # Returns the metadata found in the metadata section of the page as a symbolized hash
25
29
  #
26
30
  # @return [Hash] the page metadata
27
31
  def metadata
28
- unless @metadata && capture_metadata
29
- @metadata ||= YAML.load(capture_metadata)
32
+ if !@metadata && captured_metadata
33
+ @metadata ||= YAML.load(captured_metadata)
34
+ @metadata.symbolize_keys!
30
35
  end
31
- @metadata.symbolize_keys!
36
+ @metadata || {}
32
37
  end
33
38
 
34
- private
39
+ def content
40
+ @content ||= raw.gsub(META_CAPTURE, '')
41
+ end
35
42
 
36
- def capture_metadata
37
- @captured_metadata ||= META_CAPTURE.match(raw)[1]
43
+ def file
44
+ @file ||=
45
+ (@lookup_context.find(@path + '.html.erb') rescue false) ||
46
+ (@lookup_context.find(@path + '/' + 'index.html.erb') rescue false)
47
+ raise PageNotFoundError.new "Page not found '/#{@path}'" unless @file
48
+ @file
38
49
  end
39
50
 
40
- def raw
41
- @raw ||= File.read(file)
51
+ private
52
+
53
+ def captured_metadata
54
+ unless @captured_metadata
55
+ capture = META_CAPTURE.match(raw)
56
+ @captured_metadata = capture ? capture[1] : nil
57
+ end
58
+ @captured_metadata
42
59
  end
43
60
 
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'
61
+ def raw
62
+ file.source
47
63
  end
48
64
 
49
65
  def site_root
50
- Rails.root.join('site').to_s
66
+ @current_site.root
51
67
  end
52
68
 
53
69
  end
@@ -9,6 +9,8 @@
9
9
  <ul class="nav navbar-nav navbar-right">
10
10
  <li><a id="geri-editor-save" class="btn btn-success disabled navbar-btn editor-link" href="">Save Changes</a></li>
11
11
  <li><a id="geri-editor-revert" class="btn btn-danger disabled navbar-btn editor-link" href="">Revert</a></li>
12
+ <li><%= link_to 'Admin', '/admin', class: 'btn btn-warning navbar-btn editor-link', data: {
13
+ confirm: 'All unsaved progress will be lost. Are you sure?' } %></li>
12
14
  </ul>
13
15
  </div>
14
16
  </nav>
@@ -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
@@ -29,6 +29,7 @@ Rails.application.routes.draw do
29
29
  def create_assets_directory
30
30
  empty_directory('app/site/assets')
31
31
  empty_directory('app/site/assets/vendor')
32
+ empty_directory('app/site/assets/images')
32
33
  end
33
34
 
34
35
  def setup_bower
@@ -7,8 +7,7 @@ keywords:
7
7
  - rails cms
8
8
  - ruby on rails cms
9
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.
10
+ description: GeriCMS is an estensible open source content managment system built from the ground up with developers and extensibility in mind.
12
11
  ---
13
12
  <nav class="navbar navbar-default">
14
13
  <div class="container">
@@ -1 +1,2 @@
1
- //= require jquery/dist/jquery
1
+ //= require jquery/dist/jquery
2
+ //= require bootstrap/dist/js/bootstrap::
@@ -1,15 +1,16 @@
1
1
  require_relative './config/menu_item'
2
+ require_relative './config/site'
2
3
  module Geri
3
4
  module Config
4
5
  include ActiveSupport::Configurable
5
- config_accessor :admin_path # route to the administrative backend
6
- config_accessor :menu_items # menu item registry
7
- config_accessor :site_name # name of the site
6
+ config_accessor :admin_path # route to the administrative backend
7
+ config_accessor :menu_items # menu item registry
8
+ config_accessor :sites
8
9
 
9
10
  # Defaults
10
11
  self.admin_path = '/admin'
11
12
  self.menu_items = []
12
- self.site_name = 'GeriCMS'
13
+ self.sites = {}
13
14
 
14
15
  def self.register_menu_item(title, path_or_options=nil, options={})
15
16
  self.menu_items << item = MenuItem.new(title, path_or_options, options)
@@ -17,12 +18,27 @@ module Geri
17
18
  self.menu_items.sort! { |a,b| a.priority <=> b.priority }
18
19
  end
19
20
 
21
+ def self.register_site(domain, mount_point, &block)
22
+ site = Site.new(domain, mount_point)
23
+ yield site
24
+ sites[domain] = site
25
+ end
26
+
20
27
  # configure override
21
28
  def self.configure(&block)
29
+ register_default_site
22
30
  begin
23
31
  yield self
24
32
  end
25
33
  end
26
34
 
35
+ private
36
+
37
+ def self.register_default_site
38
+ register_site :default, '/' do |site|
39
+ site.name = 'GeriCMS'
40
+ end
41
+ end
42
+
27
43
  end
28
44
  end
@@ -0,0 +1,19 @@
1
+ module Geri
2
+ module Config
3
+ class Site
4
+ attr_reader :domain, :mount_point, :root
5
+ attr_accessor :name
6
+
7
+ def initialize(domain, mount_point)
8
+ @domain = domain
9
+ @mount_point = mount_point
10
+ if @mount_point == '/'
11
+ @root = Rails.root.join('app', 'site')
12
+ else
13
+ @root = Rails.root.join('app', 'site', *@mount_point.split('/'))
14
+ end
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Geri
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.3'
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.1.1
4
+ version: 0.1.3
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-21 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -419,6 +419,7 @@ files:
419
419
  - lib/geri/cli/extension.rb
420
420
  - lib/geri/config.rb
421
421
  - lib/geri/config/menu_item.rb
422
+ - lib/geri/config/site.rb
422
423
  - lib/geri/engine.rb
423
424
  - lib/geri/tasks.rb
424
425
  - lib/geri/tasks/create_admin_user.rb