adva-markup 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bundler/repository.rb +118 -0
- metadata +5 -16
- data/app/models/content_slice.rb +0 -5
- data/app/models/section_slice.rb +0 -6
- data/app/views/admin/blogs/_form_slice.html.rb +0 -14
- data/app/views/admin/posts/_form_slice.html.rb +0 -10
- data/config/locales/en.yml +0 -2
- data/config/redirects.rb +0 -3
- data/config/routes.rb +0 -3
- data/lib/adva-markup.rb +0 -1
- data/lib/adva/markup.rb +0 -48
- data/lib/adva/markup/action_controller.rb +0 -38
- data/lib/adva/markup/active_record.rb +0 -41
- data/lib/adva_markup/version.rb +0 -3
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
# Bundler gemfile support for local/remote workspaces/repositories for work in
|
4
|
+
# development teams.
|
5
|
+
#
|
6
|
+
# Usage:
|
7
|
+
#
|
8
|
+
# # define paths to be searched for repositories:
|
9
|
+
# workspace '~/.projects ~/Development/{projects,work}'
|
10
|
+
#
|
11
|
+
# # define developer preferences for using local or remote repositories (uses ENV['user']):
|
12
|
+
# developer :sven, :prefer => :local
|
13
|
+
#
|
14
|
+
# # define repositories to be used for particular gems:
|
15
|
+
# adva_cms = repository('adva-cms2', :git => 'git@github.com:svenfuchs/adva-cms2.git', :ref => 'c2af0de')
|
16
|
+
# adva_shop = repository('adva-shop', :source => :local)
|
17
|
+
#
|
18
|
+
# # now use repositories to define gems:
|
19
|
+
# adva_cms.gem 'adva-core'
|
20
|
+
# adva_shop.gem 'adva-catalog'
|
21
|
+
#
|
22
|
+
# # The gem definition will now be proxied to Bundler with arguments according
|
23
|
+
# # to the setup defined earlier. E.g. as:
|
24
|
+
#
|
25
|
+
# gem 'adva-core', :path => 'Development/projects/adva-cms2/adva-core' # for developer 'sven'
|
26
|
+
# gem 'adva-core', :git => 'git@github.com:svenfuchs/adva-cms2.git', :ref => 'c2af0de' # for other developers
|
27
|
+
# gem 'adva-catalog', :path => 'Development/projects/adva-shop/adva-catalog' # for all developers
|
28
|
+
#
|
29
|
+
# One can also set an environment variable FORCE_REMOTE which will force remote
|
30
|
+
# repositories to be used *except* when a repository was defined with :source => :local
|
31
|
+
# which always forces the local repository to be used.
|
32
|
+
#
|
33
|
+
class Repository
|
34
|
+
class << self
|
35
|
+
def paths
|
36
|
+
@paths ||= []
|
37
|
+
end
|
38
|
+
|
39
|
+
def path(*paths)
|
40
|
+
paths.join(' ').split(' ').each do |path|
|
41
|
+
self.paths.concat(Pathname.glob(File.expand_path(path)))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def developer(name, preferences)
|
46
|
+
developers[name] = preferences
|
47
|
+
workspaces(preferences[:workspace])
|
48
|
+
end
|
49
|
+
|
50
|
+
def current_developer
|
51
|
+
developers[ENV['USER'].to_sym] || {}
|
52
|
+
end
|
53
|
+
|
54
|
+
def developers(developers = nil)
|
55
|
+
@developers ||= {}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Gem < Array
|
60
|
+
def initialize(name, repository)
|
61
|
+
if repository.local?
|
62
|
+
sub_path = repository.path.join(name)
|
63
|
+
super([name, { :path => sub_path.exist? ? sub_path.to_s : repository.path.to_s }])
|
64
|
+
else
|
65
|
+
super([name, repository.options.dup])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
attr_reader :bundler, :name, :options, :source
|
71
|
+
|
72
|
+
def initialize(bundler, name, options)
|
73
|
+
@bundler = bundler
|
74
|
+
@name = name
|
75
|
+
@source = options.delete(:source)
|
76
|
+
@options = options
|
77
|
+
end
|
78
|
+
|
79
|
+
def gem(name)
|
80
|
+
bundler.gem(*Gem.new(name, self))
|
81
|
+
end
|
82
|
+
|
83
|
+
def local?
|
84
|
+
source == :local # && path
|
85
|
+
end
|
86
|
+
|
87
|
+
def source
|
88
|
+
@source ||= forced_source || preferred_source || :remote
|
89
|
+
end
|
90
|
+
|
91
|
+
def forced_source
|
92
|
+
:remote if ENV['FORCE_REMOTE']
|
93
|
+
end
|
94
|
+
|
95
|
+
def preferred_source
|
96
|
+
self.class.current_developer[:prefer] || self.class.current_developer[name.to_sym]
|
97
|
+
end
|
98
|
+
|
99
|
+
def path
|
100
|
+
@path ||= begin
|
101
|
+
path = self.class.paths.detect { |path| path.join(name).exist? }
|
102
|
+
path ? path.join(name) : Pathname.new('.')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def workspace(*paths)
|
108
|
+
Repository.path(*paths)
|
109
|
+
end
|
110
|
+
alias :workspaces :workspace
|
111
|
+
|
112
|
+
def developer(name, preferences)
|
113
|
+
Repository.developer(name, preferences)
|
114
|
+
end
|
115
|
+
|
116
|
+
def repository(*args)
|
117
|
+
Repository.new(self, *args)
|
118
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adva-markup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sven Fuchs
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-19 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -69,18 +69,7 @@ extensions: []
|
|
69
69
|
extra_rdoc_files: []
|
70
70
|
|
71
71
|
files:
|
72
|
-
-
|
73
|
-
- app/views/admin/posts/_form_slice.html.rb
|
74
|
-
- app/models/content_slice.rb
|
75
|
-
- app/models/section_slice.rb
|
76
|
-
- config/redirects.rb
|
77
|
-
- config/routes.rb
|
78
|
-
- config/locales/en.yml
|
79
|
-
- lib/adva_markup/version.rb
|
80
|
-
- lib/adva/markup.rb
|
81
|
-
- lib/adva/markup/action_controller.rb
|
82
|
-
- lib/adva/markup/active_record.rb
|
83
|
-
- lib/adva-markup.rb
|
72
|
+
- lib/bundler/repository.rb
|
84
73
|
has_rdoc: true
|
85
74
|
homepage: http://github.com/svenfuchs/adva-cms2
|
86
75
|
licenses: []
|
data/app/models/content_slice.rb
DELETED
data/app/models/section_slice.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require_dependency 'admin/blogs/_form.html'
|
2
|
-
|
3
|
-
Admin::Blogs::Form.class_eval do
|
4
|
-
include do
|
5
|
-
def fields
|
6
|
-
super
|
7
|
-
fieldset do
|
8
|
-
column do
|
9
|
-
form.input :default_filter, :as => :select, :collection => Adva::Markup.options
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/config/locales/en.yml
DELETED
data/config/redirects.rb
DELETED
data/config/routes.rb
DELETED
data/lib/adva-markup.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'adva/markup'
|
data/lib/adva/markup.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'adva'
|
2
|
-
require 'RedCloth'
|
3
|
-
require 'rdiscount'
|
4
|
-
|
5
|
-
ERB::Util.send(:undef_method, :t) # wtf, redcloth!
|
6
|
-
|
7
|
-
module Adva
|
8
|
-
class Markup < ::Rails::Engine
|
9
|
-
include Adva::Engine
|
10
|
-
|
11
|
-
autoload :ActionController, 'adva/markup/action_controller'
|
12
|
-
autoload :ActiveRecord, 'adva/markup/active_record'
|
13
|
-
|
14
|
-
mattr_accessor :filters
|
15
|
-
self.filters = {
|
16
|
-
:markdown => 'RDiscount',
|
17
|
-
:textile => 'RedCloth'
|
18
|
-
}
|
19
|
-
|
20
|
-
class << self
|
21
|
-
def apply(name, markup)
|
22
|
-
if filter = self.filter(name)
|
23
|
-
filter.new(markup).to_html
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def filter(name)
|
28
|
-
filters[name.to_sym].constantize if name.present? && filters[name.to_sym]
|
29
|
-
end
|
30
|
-
|
31
|
-
def keys
|
32
|
-
@keys ||= filters.keys.map(&:to_s).sort
|
33
|
-
end
|
34
|
-
|
35
|
-
def names
|
36
|
-
@names ||= keys.map { |key| key.titleize }
|
37
|
-
end
|
38
|
-
|
39
|
-
def options
|
40
|
-
@options ||= Hash[*names.zip(keys).flatten]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
ActionController::Base.extend(Adva::Markup::ActionController::ActMacro)
|
47
|
-
ActiveRecord::Base.extend(Adva::Markup::ActiveRecord::ActMacro)
|
48
|
-
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Adva
|
2
|
-
class Markup
|
3
|
-
module ActionController
|
4
|
-
module ActMacro
|
5
|
-
def filtered_attributes(*models)
|
6
|
-
options = models.extract_options!
|
7
|
-
options[:models] = models.map(&:to_s).map(&:camelize)
|
8
|
-
options[:only] = Array(options[:only]).map(&:to_sym)
|
9
|
-
options[:except] = Array(options[:except]).map(&:to_sym)
|
10
|
-
|
11
|
-
class_inheritable_accessor :filtered_attribute_options
|
12
|
-
self.filtered_attribute_options = options
|
13
|
-
|
14
|
-
include InstanceMethods
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module InstanceMethods
|
19
|
-
def render(*args)
|
20
|
-
options = filtered_attribute_options
|
21
|
-
excluded = options[:except].include?(params[:action].to_sym)
|
22
|
-
included = options[:only].empty? || options[:only].include?(params[:action].to_sym)
|
23
|
-
|
24
|
-
!excluded && included ? with_filtered_attributes { super } : super
|
25
|
-
end
|
26
|
-
|
27
|
-
def with_filtered_attributes
|
28
|
-
models = filtered_attribute_options[:models].map(&:constantize)
|
29
|
-
models.each { |model| model.read_filtered_attributes = true }
|
30
|
-
yield.tap do
|
31
|
-
models.each { |model| model.read_filtered_attributes = false }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# TODO make sure this can be called multiple times
|
2
|
-
#
|
3
|
-
module Adva
|
4
|
-
class Markup
|
5
|
-
module ActiveRecord
|
6
|
-
module ActMacro
|
7
|
-
def filters(*attributes)
|
8
|
-
class_inheritable_accessor :filtered_attributes
|
9
|
-
class_inheritable_accessor :read_filtered_attributes
|
10
|
-
|
11
|
-
self.filtered_attributes = attributes
|
12
|
-
self.read_filtered_attributes = false
|
13
|
-
|
14
|
-
before_save :filter_attributes!
|
15
|
-
include InstanceMethods
|
16
|
-
include attribute_readers_module
|
17
|
-
end
|
18
|
-
|
19
|
-
def attribute_readers_module
|
20
|
-
Module.new.tap do |readers|
|
21
|
-
filtered_attributes.each do |name|
|
22
|
-
readers.module_eval <<-rb
|
23
|
-
def #{name}; read_filtered_attributes ? send(:#{name}_html) : super; end
|
24
|
-
rb
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
module InstanceMethods
|
31
|
-
def filter_attributes!
|
32
|
-
filtered_attributes.each do |name|
|
33
|
-
value = self.send(name)
|
34
|
-
value = Adva::Markup.apply(filter, value) if respond_to?(:filter) && filter
|
35
|
-
write_attribute(:"#{name}_html", value)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/lib/adva_markup/version.rb
DELETED