laurynasl-sunflower-comments 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +170 -0
- data/Rakefile +65 -0
- data/TODO +15 -0
- data/app/controllers/application.rb +5 -0
- data/app/helpers/application_helper.rb +64 -0
- data/app/views/layout/sunflower_comments.html.erb +16 -0
- data/lib/sunflower-comments.rb +123 -0
- data/lib/sunflower-comments/merbtasks.rb +137 -0
- data/lib/sunflower-comments/slicetasks.rb +18 -0
- data/lib/sunflower-comments/spectasks.rb +65 -0
- data/public/javascripts/master.js +0 -0
- data/public/stylesheets/master.css +2 -0
- data/spec/controllers/main_spec.rb +71 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/sunflower-comments_spec.rb +19 -0
- data/stubs/app/controllers/application.rb +2 -0
- data/stubs/app/controllers/main.rb +2 -0
- metadata +94 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 laurynasl
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
SunflowerComments
|
2
|
+
=================
|
3
|
+
|
4
|
+
A slice for the Merb framework.
|
5
|
+
|
6
|
+
------------------------------------------------------------------------------
|
7
|
+
|
8
|
+
sunflower-comments
|
9
|
+
|-- LICENSE
|
10
|
+
|-- README
|
11
|
+
|-- Rakefile [1]
|
12
|
+
|-- TODO
|
13
|
+
|-- app [2]
|
14
|
+
| |-- controllers
|
15
|
+
| | |-- application.rb
|
16
|
+
| | `-- main.rb
|
17
|
+
| |-- helpers
|
18
|
+
| | `-- application_helper.rb
|
19
|
+
| `-- views
|
20
|
+
| |-- layout
|
21
|
+
| | `-- sunflower-comments.html.erb [3]
|
22
|
+
| `-- main
|
23
|
+
| `-- index.html.erb
|
24
|
+
|-- lib
|
25
|
+
| |-- sunflower-comments
|
26
|
+
| | |-- merbtasks.rb [4]
|
27
|
+
| | `-- slicetasks.rb [5]
|
28
|
+
| `-- sunflower-comments.rb [6]
|
29
|
+
|-- log
|
30
|
+
| `-- merb_test.log
|
31
|
+
|-- public [7]
|
32
|
+
| |-- javascripts
|
33
|
+
| | `-- master.js
|
34
|
+
| `-- stylesheets
|
35
|
+
| `-- master.css
|
36
|
+
|-- spec [8]
|
37
|
+
| |-- sunflower-comments_spec.rb
|
38
|
+
| |-- controllers
|
39
|
+
| | `-- main_spec.rb
|
40
|
+
| `-- spec_helper.rb
|
41
|
+
`-- stubs [9]
|
42
|
+
`-- app
|
43
|
+
`-- controllers
|
44
|
+
|-- application.rb
|
45
|
+
`-- main.rb
|
46
|
+
|
47
|
+
|
48
|
+
1. Rake tasks to package/install the gem - edit this to modify the manifest.
|
49
|
+
2. The slice application: controllers, models, helpers, views.
|
50
|
+
3. The default layout, as specified in Merb::Slices::config[:sunflower_comments][:layout]
|
51
|
+
change this to :application to use the app's layout.
|
52
|
+
4. Standard rake tasks available to your application.
|
53
|
+
5. Your custom application rake tasks.
|
54
|
+
6. The main slice file - contains all slice setup logic/config.
|
55
|
+
7. Public assets you (optionally) install using rake slices:sunflower_comments:install
|
56
|
+
8. Specs for basis slice behaviour - you usually adapt these for your slice.
|
57
|
+
9. Stubs of classes/views/files for the end-user to override - usually these
|
58
|
+
mimic the files in app/ and/or public/; use rake slices:sunflower_comments:stubs to
|
59
|
+
get started with the override stubs. Also, slices:sunflower_comments:patch will
|
60
|
+
copy over views to override in addition to the files found in /stubs.
|
61
|
+
|
62
|
+
|
63
|
+
To see all available tasks for SunflowerComments run:
|
64
|
+
|
65
|
+
rake -T slices:sunflower_comments
|
66
|
+
|
67
|
+
------------------------------------------------------------------------------
|
68
|
+
|
69
|
+
Instructions for installation:
|
70
|
+
|
71
|
+
file: config/init.rb
|
72
|
+
|
73
|
+
# add the slice as a regular dependency
|
74
|
+
|
75
|
+
dependency 'sunflower-comments'
|
76
|
+
|
77
|
+
# if needed, configure which slices to load and in which order
|
78
|
+
|
79
|
+
Merb::Plugins.config[:merb_slices] = { :queue => ["SunflowerComments", ...] }
|
80
|
+
|
81
|
+
# optionally configure the plugins in a before_app_loads callback
|
82
|
+
|
83
|
+
Merb::BootLoader.before_app_loads do
|
84
|
+
|
85
|
+
Merb::Slices::config[:sunflower_comments][:option] = value
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
file: config/router.rb
|
90
|
+
|
91
|
+
# example: /sunflower_comments/:controller/:action/:id
|
92
|
+
|
93
|
+
add_slice(:SunflowerComments)
|
94
|
+
|
95
|
+
# example: /foo/:controller/:action/:id
|
96
|
+
|
97
|
+
add_slice(:SunflowerComments, 'foo') # same as :path => 'foo'
|
98
|
+
|
99
|
+
# example: /:lang/:controller/:action/:id
|
100
|
+
|
101
|
+
add_slice(:SunflowerComments, :path => ':lang')
|
102
|
+
|
103
|
+
# example: /:controller/:action/:id
|
104
|
+
|
105
|
+
slice(:SunflowerComments)
|
106
|
+
|
107
|
+
Normally you should also run the following rake task:
|
108
|
+
|
109
|
+
rake slices:sunflower_comments:install
|
110
|
+
|
111
|
+
------------------------------------------------------------------------------
|
112
|
+
|
113
|
+
You can put your application-level overrides in:
|
114
|
+
|
115
|
+
host-app/slices/sunflower-comments/app - controllers, models, views ...
|
116
|
+
|
117
|
+
Templates are located in this order:
|
118
|
+
|
119
|
+
1. host-app/slices/sunflower-comments/app/views/*
|
120
|
+
2. gems/sunflower-comments/app/views/*
|
121
|
+
3. host-app/app/views/*
|
122
|
+
|
123
|
+
You can use the host application's layout by configuring the
|
124
|
+
sunflower-comments slice in a before_app_loads block:
|
125
|
+
|
126
|
+
Merb::Slices.config[:sunflower_comments] = { :layout => :application }
|
127
|
+
|
128
|
+
By default :sunflower_comments is used. If you need to override
|
129
|
+
stylesheets or javascripts, just specify your own files in your layout
|
130
|
+
instead/in addition to the ones supplied (if any) in
|
131
|
+
host-app/public/slices/sunflower-comments.
|
132
|
+
|
133
|
+
In any case don't edit those files directly as they may be clobbered any time
|
134
|
+
rake sunflower_comments:install is run.
|
135
|
+
|
136
|
+
------------------------------------------------------------------------------
|
137
|
+
|
138
|
+
About Slices
|
139
|
+
============
|
140
|
+
|
141
|
+
Merb-Slices is a Merb plugin for using and creating application 'slices' which
|
142
|
+
help you modularize your application. Usually these are reuseable extractions
|
143
|
+
from your main app. In effect, a Slice is just like a regular Merb MVC
|
144
|
+
application, both in functionality as well as in structure.
|
145
|
+
|
146
|
+
When you generate a Slice stub structure, a module is setup to serve as a
|
147
|
+
namespace for your controller, models, helpers etc. This ensures maximum
|
148
|
+
encapsulation. You could say a Slice is a mixture between a Merb plugin (a
|
149
|
+
Gem) and a Merb application, reaping the benefits of both.
|
150
|
+
|
151
|
+
A host application can 'mount' a Slice inside the router, which means you have
|
152
|
+
full over control how it integrates. By default a Slice's routes are prefixed
|
153
|
+
by its name (a router :namespace), but you can easily provide your own prefix
|
154
|
+
or leave it out, mounting it at the root of your url-schema. You can even
|
155
|
+
mount a Slice multiple times and give extra parameters to customize an
|
156
|
+
instance's behaviour.
|
157
|
+
|
158
|
+
A Slice's Application controller uses controller_for_slice to setup slice
|
159
|
+
specific behaviour, which mainly affects cascaded view handling. Additionaly,
|
160
|
+
this method is available to any kind of controller, so it can be used for
|
161
|
+
Merb Mailer too for example.
|
162
|
+
|
163
|
+
There are many ways which let you customize a Slice's functionality and
|
164
|
+
appearance without ever touching the Gem-level code itself. It's not only easy
|
165
|
+
to add template/layout overrides, you can also add/modify controllers, models
|
166
|
+
and other runtime code from within the host application.
|
167
|
+
|
168
|
+
To create your own Slice run this (somewhere outside of your merb app):
|
169
|
+
|
170
|
+
$ merb-gen slice <your-lowercase-slice-name>
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
require 'merb-core'
|
5
|
+
require 'merb-core/tasks/merb'
|
6
|
+
|
7
|
+
GEM_NAME = "sunflower-comments"
|
8
|
+
AUTHOR = "Laurynas Liutkus"
|
9
|
+
EMAIL = "laurynasl@gmail.com"
|
10
|
+
HOMEPAGE = "http://github.com/laurynasl/sunflower-comments/"
|
11
|
+
SUMMARY = "Merb Slice that provides sequel + postgres + comments = comment anything (polymorphic, with database triggers)"
|
12
|
+
GEM_VERSION = "0.0.1"
|
13
|
+
|
14
|
+
spec = Gem::Specification.new do |s|
|
15
|
+
s.rubyforge_project = 'merb'
|
16
|
+
s.name = GEM_NAME
|
17
|
+
s.version = GEM_VERSION
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.has_rdoc = true
|
20
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
21
|
+
s.summary = SUMMARY
|
22
|
+
s.description = s.summary
|
23
|
+
s.author = AUTHOR
|
24
|
+
s.email = EMAIL
|
25
|
+
s.homepage = HOMEPAGE
|
26
|
+
s.add_dependency('merb-slices', '>= 1.0.3')
|
27
|
+
s.require_path = 'lib'
|
28
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec,app,public,stubs}/**/*")
|
29
|
+
end
|
30
|
+
|
31
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
32
|
+
pkg.gem_spec = spec
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Install the gem"
|
36
|
+
task :install do
|
37
|
+
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Uninstall the gem"
|
41
|
+
task :uninstall do
|
42
|
+
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Create a gemspec file"
|
46
|
+
task :gemspec do
|
47
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
48
|
+
file.puts spec.to_ruby
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
require 'spec/rake/spectask'
|
53
|
+
require 'merb-core/test/tasks/spectasks'
|
54
|
+
desc 'Default: run spec examples'
|
55
|
+
task :default => 'spec'
|
56
|
+
|
57
|
+
desc 'Forces gem rebuild and reinstalls without dependencies nor documentation'
|
58
|
+
task :debug_reinstall => [:repackage] do
|
59
|
+
s = "sudo gem uninstall #{GEM_NAME}"
|
60
|
+
puts s
|
61
|
+
system s
|
62
|
+
s = "sudo gem install pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-ri --no-rdoc --ignore-dependencies"
|
63
|
+
puts s
|
64
|
+
system s
|
65
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
TODO:
|
2
|
+
|
3
|
+
- Fix SunflowerComments.description and SunflowerComments.version
|
4
|
+
- Fix LICENSE with your name
|
5
|
+
- Fix Rakefile with your name and contact info
|
6
|
+
- Add your code to lib/sunflower-comments.rb
|
7
|
+
- Add your Merb rake tasks to lib/sunflower-comments/merbtasks.rb
|
8
|
+
|
9
|
+
Remove anything that you don't need:
|
10
|
+
|
11
|
+
- app/controllers/main.rb SunflowerComments::Main controller
|
12
|
+
- app/views/layout/sunflower-comments.html.erb
|
13
|
+
- spec/controllers/main_spec.rb controller specs
|
14
|
+
- public/* any public files
|
15
|
+
- stubs/* any stub files
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Merb
|
2
|
+
module SunflowerComments
|
3
|
+
module ApplicationHelper
|
4
|
+
|
5
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
6
|
+
#
|
7
|
+
# @return <String>
|
8
|
+
# A path relative to the public directory, with added segments.
|
9
|
+
def image_path(*segments)
|
10
|
+
public_path_for(:image, *segments)
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
14
|
+
#
|
15
|
+
# @return <String>
|
16
|
+
# A path relative to the public directory, with added segments.
|
17
|
+
def javascript_path(*segments)
|
18
|
+
public_path_for(:javascript, *segments)
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
22
|
+
#
|
23
|
+
# @return <String>
|
24
|
+
# A path relative to the public directory, with added segments.
|
25
|
+
def stylesheet_path(*segments)
|
26
|
+
public_path_for(:stylesheet, *segments)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Construct a path relative to the public directory
|
30
|
+
#
|
31
|
+
# @param <Symbol> The type of component.
|
32
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
33
|
+
#
|
34
|
+
# @return <String>
|
35
|
+
# A path relative to the public directory, with added segments.
|
36
|
+
def public_path_for(type, *segments)
|
37
|
+
::SunflowerComments.public_path_for(type, *segments)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Construct an app-level path.
|
41
|
+
#
|
42
|
+
# @param <Symbol> The type of component.
|
43
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
44
|
+
#
|
45
|
+
# @return <String>
|
46
|
+
# A path within the host application, with added segments.
|
47
|
+
def app_path_for(type, *segments)
|
48
|
+
::SunflowerComments.app_path_for(type, *segments)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Construct a slice-level path.
|
52
|
+
#
|
53
|
+
# @param <Symbol> The type of component.
|
54
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
55
|
+
#
|
56
|
+
# @return <String>
|
57
|
+
# A path within the slice source (Gem), with added segments.
|
58
|
+
def slice_path_for(type, *segments)
|
59
|
+
::SunflowerComments.slice_path_for(type, *segments)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
5
|
+
<title>Fresh SunflowerComments Slice</title>
|
6
|
+
<link href="<%= public_path_for :stylesheet, 'master.css' %>" type="text/css" charset="utf-8" rel="stylesheet" media="all" />
|
7
|
+
<script src="<%= public_path_for :javascript, 'master.js' %>" type="text/javascript" charset="utf-8"></script>
|
8
|
+
</head>
|
9
|
+
<!-- you can override this layout at slices/sunflower-comments/app/views/layout/sunflower-comments.html.erb -->
|
10
|
+
<body class="sunflower-comments-slice">
|
11
|
+
<div id="container">
|
12
|
+
<h1>SunflowerComments Slice</h1>
|
13
|
+
<div id="main"><%= catch_content :for_layout %></div>
|
14
|
+
</div>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,123 @@
|
|
1
|
+
if defined?(Merb::Plugins)
|
2
|
+
|
3
|
+
$:.unshift File.dirname(__FILE__)
|
4
|
+
|
5
|
+
load_dependency 'merb-slices'
|
6
|
+
Merb::Plugins.add_rakefiles "sunflower-comments/merbtasks", "sunflower-comments/slicetasks", "sunflower-comments/spectasks"
|
7
|
+
|
8
|
+
# Register the Slice for the current host application
|
9
|
+
Merb::Slices::register(__FILE__)
|
10
|
+
|
11
|
+
# Slice configuration - set this in a before_app_loads callback.
|
12
|
+
# By default a Slice uses its own layout, so you can swicht to
|
13
|
+
# the main application layout or no layout at all if needed.
|
14
|
+
#
|
15
|
+
# Configuration options:
|
16
|
+
# :layout - the layout to use; defaults to :sunflower-comments
|
17
|
+
# :mirror - which path component types to use on copy operations; defaults to all
|
18
|
+
Merb::Slices::config[:sunflower_comments][:layout] ||= :sunflower_comments
|
19
|
+
|
20
|
+
# All Slice code is expected to be namespaced inside a module
|
21
|
+
module SunflowerComments
|
22
|
+
|
23
|
+
# Slice metadata
|
24
|
+
self.description = "SunflowerComments is a chunky Merb slice!"
|
25
|
+
self.version = "0.0.1"
|
26
|
+
self.author = "Laurynas Liutkus"
|
27
|
+
|
28
|
+
# Stub classes loaded hook - runs before LoadClasses BootLoader
|
29
|
+
# right after a slice's classes have been loaded internally.
|
30
|
+
def self.loaded
|
31
|
+
end
|
32
|
+
|
33
|
+
# Initialization hook - runs before AfterAppLoads BootLoader
|
34
|
+
def self.init
|
35
|
+
end
|
36
|
+
|
37
|
+
# Activation hook - runs after AfterAppLoads BootLoader
|
38
|
+
def self.activate
|
39
|
+
end
|
40
|
+
|
41
|
+
# Deactivation hook - triggered by Merb::Slices.deactivate(SunflowerComments)
|
42
|
+
def self.deactivate
|
43
|
+
end
|
44
|
+
|
45
|
+
# Setup routes inside the host application
|
46
|
+
#
|
47
|
+
# @param scope<Merb::Router::Behaviour>
|
48
|
+
# Routes will be added within this scope (namespace). In fact, any
|
49
|
+
# router behaviour is a valid namespace, so you can attach
|
50
|
+
# routes at any level of your router setup.
|
51
|
+
#
|
52
|
+
# @note prefix your named routes with :sunflower_comments_
|
53
|
+
# to avoid potential conflicts with global named routes.
|
54
|
+
def self.setup_router(scope)
|
55
|
+
# example of a named route
|
56
|
+
# scope.match('/index(.:format)').to(:controller => 'main', :action => 'index').name(:index)
|
57
|
+
# the slice is mounted at /sunflower-comments - note that it comes before default_routes
|
58
|
+
# scope.match('/').to(:controller => 'main', :action => 'index').name(:home)
|
59
|
+
# enable slice-level default routes by default
|
60
|
+
# scope.default_routes
|
61
|
+
|
62
|
+
SunflowerComments.classes.each do |klass|
|
63
|
+
parent_table = klass.table_name.to_s
|
64
|
+
prefix = "/#{parent_table}/:parent_id"
|
65
|
+
singular = klass.name.underscore
|
66
|
+
hash = {:controller => 'comments', :parent_table => parent_table}
|
67
|
+
|
68
|
+
scope.match(prefix+"/comments", :method => :get).to(hash.merge(:action => 'index')).name(:"#{singular}_comments")
|
69
|
+
scope.match(prefix+"/comments", :method => :post).to(hash.merge(:action => 'create')).name(:"#{singular}_comments")
|
70
|
+
scope.match(prefix+"/comments/new", :method => :get).to(hash.merge(:action => 'new')).name(:"new_#{singular}_comment")
|
71
|
+
scope.match(prefix+"/comments/:id", :method => :get).to(hash.merge(:action => 'show')).name(:"#{singular}_comment")
|
72
|
+
scope.match(prefix+"/comments/:id", :method => :put).to(hash.merge(:action => 'update')).name(:"#{singular}_comment")
|
73
|
+
scope.match(prefix+"/comments/:id", :method => :delete).to(hash.merge(:action => 'destroy')).name(:"#{singular}_comment")
|
74
|
+
|
75
|
+
scope.match(prefix+"/comments/:id/report", :method => :get).to(hash.merge(:action => 'report')).name(:"report_#{singular}_comment")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.classes
|
80
|
+
@@classes ||= []
|
81
|
+
end
|
82
|
+
def self.classes_hash
|
83
|
+
@@classes_hash ||= {}
|
84
|
+
end
|
85
|
+
|
86
|
+
module Commentable
|
87
|
+
def self.included(other)
|
88
|
+
SunflowerComments.classes << other
|
89
|
+
SunflowerComments.classes_hash[other.table_name.to_s] = other
|
90
|
+
other.has_many :comments, :key => :parent_id, :conditions => {:parent_table => other.table_name.to_s}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
module Comment
|
95
|
+
def self.included(other)
|
96
|
+
other.validates_presence_of :body, :parent_id, :parent_table
|
97
|
+
end
|
98
|
+
|
99
|
+
def parent
|
100
|
+
parent_table.camelcase.singular.constantize.filter(:id => parent_id).first
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
# Setup the slice layout for SunflowerComments
|
107
|
+
#
|
108
|
+
# Use SunflowerComments.push_path and SunflowerComments.push_app_path
|
109
|
+
# to set paths to sunflower-comments-level and app-level paths. Example:
|
110
|
+
#
|
111
|
+
# SunflowerComments.push_path(:application, SunflowerComments.root)
|
112
|
+
# SunflowerComments.push_app_path(:application, Merb.root / 'slices' / 'sunflower-comments')
|
113
|
+
# ...
|
114
|
+
#
|
115
|
+
# Any component path that hasn't been set will default to SunflowerComments.root
|
116
|
+
#
|
117
|
+
# Or just call setup_default_structure! to setup a basic Merb MVC structure.
|
118
|
+
SunflowerComments.setup_default_structure!
|
119
|
+
|
120
|
+
# Add dependencies for other SunflowerComments classes below. Example:
|
121
|
+
# dependency "sunflower-comments/other"
|
122
|
+
|
123
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
namespace :slices do
|
2
|
+
namespace :sunflower_comments do
|
3
|
+
|
4
|
+
desc 'Loads triggers (only for Sequel adapter and PostgreSQL dabase)'
|
5
|
+
task :load_triggers => :merb_env do
|
6
|
+
def try_drop_trigger(table, trigger)
|
7
|
+
if Sequel::Model.db.select('count(*)'.lit => 'count').from(:pg_trigger).filter(:tgname => trigger).first[:count] == 1
|
8
|
+
Sequel::Model.db.execute "DROP TRIGGER \"#{trigger}\" ON \"#{table}\""
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# "create" language
|
13
|
+
if Sequel::Model.db.select('count(*)'.lit => 'count').from(:pg_language).filter(:lanname => 'plpgsql').first[:count] == 0
|
14
|
+
Sequel::Model.db.execute "CREATE LANGUAGE plpgsql"
|
15
|
+
end
|
16
|
+
|
17
|
+
# comments INSERT/UPDATE trigger
|
18
|
+
try_drop_trigger 'comments', 'comments_insert_trigger'
|
19
|
+
Sequel::Model.db.execute File.read(SunflowerComments.root_path / 'lib' / 'sunflower-comments' / 'sql' / 'trigger.sql')
|
20
|
+
|
21
|
+
|
22
|
+
# parent(s) DELETE triggers
|
23
|
+
dynamic = File.read(SunflowerComments.root_path / 'lib' / 'sunflower-comments' / 'sql' / 'dynamic.sql')
|
24
|
+
|
25
|
+
SunflowerComments.classes.each do |klass|
|
26
|
+
table_name = klass.table_name.to_s
|
27
|
+
puts
|
28
|
+
puts "-- Dynamically loading triggers for #{klass} (table \"#{table_name}\")"
|
29
|
+
|
30
|
+
trigger_name = "#{table_name}_delete_bc_trigger"
|
31
|
+
try_drop_trigger table_name, trigger_name
|
32
|
+
|
33
|
+
script = dynamic.gsub('#{table}', table_name)
|
34
|
+
Sequel::Model.db.execute script
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Install SunflowerComments"
|
39
|
+
task :install => [:preflight, :setup_directories, :copy_assets, :migrate]
|
40
|
+
|
41
|
+
desc "Test for any dependencies"
|
42
|
+
task :preflight do # see slicetasks.rb
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Setup directories"
|
46
|
+
task :setup_directories do
|
47
|
+
puts "Creating directories for host application"
|
48
|
+
SunflowerComments.mirrored_components.each do |type|
|
49
|
+
if File.directory?(SunflowerComments.dir_for(type))
|
50
|
+
if !File.directory?(dst_path = SunflowerComments.app_dir_for(type))
|
51
|
+
relative_path = dst_path.relative_path_from(Merb.root)
|
52
|
+
puts "- creating directory :#{type} #{File.basename(Merb.root) / relative_path}"
|
53
|
+
mkdir_p(dst_path)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Copy stub files to host application"
|
60
|
+
task :stubs do
|
61
|
+
puts "Copying stubs for SunflowerComments - resolves any collisions"
|
62
|
+
copied, preserved = SunflowerComments.mirror_stubs!
|
63
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
64
|
+
copied.each { |f| puts "- copied #{f}" }
|
65
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Copy stub files and views to host application"
|
69
|
+
task :patch => [ "stubs", "freeze:views" ]
|
70
|
+
|
71
|
+
desc "Copy public assets to host application"
|
72
|
+
task :copy_assets do
|
73
|
+
puts "Copying assets for SunflowerComments - resolves any collisions"
|
74
|
+
copied, preserved = SunflowerComments.mirror_public!
|
75
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
76
|
+
copied.each { |f| puts "- copied #{f}" }
|
77
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Migrate the database"
|
81
|
+
task :migrate do # see slicetasks.rb
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "Freeze SunflowerComments into your app (only sunflower-comments/app)"
|
85
|
+
task :freeze => [ "freeze:app" ]
|
86
|
+
|
87
|
+
namespace :freeze do
|
88
|
+
|
89
|
+
desc "Freezes SunflowerComments by installing the gem into application/gems"
|
90
|
+
task :gem do
|
91
|
+
ENV["GEM"] ||= "sunflower-comments"
|
92
|
+
Rake::Task['slices:install_as_gem'].invoke
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "Freezes SunflowerComments by copying all files from sunflower-comments/app to your application"
|
96
|
+
task :app do
|
97
|
+
puts "Copying all sunflower-comments/app files to your application - resolves any collisions"
|
98
|
+
copied, preserved = SunflowerComments.mirror_app!
|
99
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
100
|
+
copied.each { |f| puts "- copied #{f}" }
|
101
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
102
|
+
end
|
103
|
+
|
104
|
+
desc "Freeze all views into your application for easy modification"
|
105
|
+
task :views do
|
106
|
+
puts "Copying all view templates to your application - resolves any collisions"
|
107
|
+
copied, preserved = SunflowerComments.mirror_files_for :view
|
108
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
109
|
+
copied.each { |f| puts "- copied #{f}" }
|
110
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "Freeze all models into your application for easy modification"
|
114
|
+
task :models do
|
115
|
+
puts "Copying all models to your application - resolves any collisions"
|
116
|
+
copied, preserved = SunflowerComments.mirror_files_for :model
|
117
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
118
|
+
copied.each { |f| puts "- copied #{f}" }
|
119
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
120
|
+
end
|
121
|
+
|
122
|
+
desc "Freezes SunflowerComments as a gem and copies over sunflower-comments/app"
|
123
|
+
task :app_with_gem => [:gem, :app]
|
124
|
+
|
125
|
+
desc "Freezes SunflowerComments by unpacking all files into your application"
|
126
|
+
task :unpack do
|
127
|
+
puts "Unpacking SunflowerComments files to your application - resolves any collisions"
|
128
|
+
copied, preserved = SunflowerComments.unpack_slice!
|
129
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
130
|
+
copied.each { |f| puts "- copied #{f}" }
|
131
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
namespace :slices do
|
2
|
+
namespace :sunflower_comments do
|
3
|
+
|
4
|
+
# add your own sunflower-comments tasks here
|
5
|
+
|
6
|
+
# implement this to test for structural/code dependencies
|
7
|
+
# like certain directories or availability of other files
|
8
|
+
desc "Test for any dependencies"
|
9
|
+
task :preflight do
|
10
|
+
end
|
11
|
+
|
12
|
+
# implement this to perform any database related setup steps
|
13
|
+
desc "Migrate the database"
|
14
|
+
task :migrate do
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
namespace :slices do
|
2
|
+
namespace :sunflower_comments do
|
3
|
+
|
4
|
+
desc "Run slice specs within the host application context"
|
5
|
+
task :spec => [ "spec:explain", "spec:default" ]
|
6
|
+
|
7
|
+
namespace :spec do
|
8
|
+
|
9
|
+
slice_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
10
|
+
|
11
|
+
task :explain do
|
12
|
+
puts "\nNote: By running SunflowerComments specs inside the application context any\n" +
|
13
|
+
"overrides could break existing specs. This isn't always a problem,\n" +
|
14
|
+
"especially in the case of views. Use these spec tasks to check how\n" +
|
15
|
+
"well your application conforms to the original slice implementation."
|
16
|
+
end
|
17
|
+
|
18
|
+
Spec::Rake::SpecTask.new('default') do |t|
|
19
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
20
|
+
t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Run all model specs, run a spec for a specific Model with MODEL=MyModel"
|
24
|
+
Spec::Rake::SpecTask.new('model') do |t|
|
25
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
26
|
+
if(ENV['MODEL'])
|
27
|
+
t.spec_files = Dir["#{slice_root}/spec/models/**/#{ENV['MODEL']}_spec.rb"].sort
|
28
|
+
else
|
29
|
+
t.spec_files = Dir["#{slice_root}/spec/models/**/*_spec.rb"].sort
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Run all controller specs, run a spec for a specific Controller with CONTROLLER=MyController"
|
34
|
+
Spec::Rake::SpecTask.new('controller') do |t|
|
35
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
36
|
+
if(ENV['CONTROLLER'])
|
37
|
+
t.spec_files = Dir["#{slice_root}/spec/controllers/**/#{ENV['CONTROLLER']}_spec.rb"].sort
|
38
|
+
else
|
39
|
+
t.spec_files = Dir["#{slice_root}/spec/controllers/**/*_spec.rb"].sort
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Run all view specs, run specs for a specific controller (and view) with CONTROLLER=MyController (VIEW=MyView)"
|
44
|
+
Spec::Rake::SpecTask.new('view') do |t|
|
45
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
46
|
+
if(ENV['CONTROLLER'] and ENV['VIEW'])
|
47
|
+
t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/#{ENV['VIEW']}*_spec.rb"].sort
|
48
|
+
elsif(ENV['CONTROLLER'])
|
49
|
+
t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/*_spec.rb"].sort
|
50
|
+
else
|
51
|
+
t.spec_files = Dir["#{slice_root}/spec/views/**/*_spec.rb"].sort
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Run all specs and output the result in html"
|
56
|
+
Spec::Rake::SpecTask.new('html') do |t|
|
57
|
+
t.spec_opts = ["--format", "html"]
|
58
|
+
t.libs = ['lib', 'server/lib' ]
|
59
|
+
t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
File without changes
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "SunflowerComments::Main (controller)" do
|
4
|
+
|
5
|
+
# Feel free to remove the specs below
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
Merb::Router.prepare { add_slice(:SunflowerComments) } if standalone?
|
9
|
+
end
|
10
|
+
|
11
|
+
after :all do
|
12
|
+
Merb::Router.reset! if standalone?
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have access to the slice module" do
|
16
|
+
controller = dispatch_to(SunflowerComments::Main, :index)
|
17
|
+
controller.slice.should == SunflowerComments
|
18
|
+
controller.slice.should == SunflowerComments::Main.slice
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have an index action" do
|
22
|
+
controller = dispatch_to(SunflowerComments::Main, :index)
|
23
|
+
controller.status.should == 200
|
24
|
+
controller.body.should contain('SunflowerComments')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should work with the default route" do
|
28
|
+
controller = get("/sunflower-comments/main/index")
|
29
|
+
controller.should be_kind_of(SunflowerComments::Main)
|
30
|
+
controller.action_name.should == 'index'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should work with the example named route" do
|
34
|
+
controller = get("/sunflower-comments/index.html")
|
35
|
+
controller.should be_kind_of(SunflowerComments::Main)
|
36
|
+
controller.action_name.should == 'index'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have a slice_url helper method for slice-specific routes" do
|
40
|
+
controller = dispatch_to(SunflowerComments::Main, 'index')
|
41
|
+
|
42
|
+
url = controller.url(:sunflower_comments_default, :controller => 'main', :action => 'show', :format => 'html')
|
43
|
+
url.should == "/sunflower-comments/main/show.html"
|
44
|
+
controller.slice_url(:controller => 'main', :action => 'show', :format => 'html').should == url
|
45
|
+
|
46
|
+
url = controller.url(:sunflower_comments_index, :format => 'html')
|
47
|
+
url.should == "/sunflower-comments/index.html"
|
48
|
+
controller.slice_url(:index, :format => 'html').should == url
|
49
|
+
|
50
|
+
url = controller.url(:sunflower_comments_home)
|
51
|
+
url.should == "/sunflower-comments/"
|
52
|
+
controller.slice_url(:home).should == url
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have helper methods for dealing with public paths" do
|
56
|
+
controller = dispatch_to(SunflowerComments::Main, :index)
|
57
|
+
controller.public_path_for(:image).should == "/slices/sunflower-comments/images"
|
58
|
+
controller.public_path_for(:javascript).should == "/slices/sunflower-comments/javascripts"
|
59
|
+
controller.public_path_for(:stylesheet).should == "/slices/sunflower-comments/stylesheets"
|
60
|
+
|
61
|
+
controller.image_path.should == "/slices/sunflower-comments/images"
|
62
|
+
controller.javascript_path.should == "/slices/sunflower-comments/javascripts"
|
63
|
+
controller.stylesheet_path.should == "/slices/sunflower-comments/stylesheets"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should have a slice-specific _template_root" do
|
67
|
+
SunflowerComments::Main._template_root.should == SunflowerComments.dir_for(:view)
|
68
|
+
SunflowerComments::Main._template_root.should == SunflowerComments::Application._template_root
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'merb-core'
|
3
|
+
require 'merb-slices'
|
4
|
+
require 'spec'
|
5
|
+
|
6
|
+
# Add sunflower-comments.rb to the search path
|
7
|
+
Merb::Plugins.config[:merb_slices][:auto_register] = true
|
8
|
+
Merb::Plugins.config[:merb_slices][:search_path] = File.join(File.dirname(__FILE__), '..', 'lib', 'sunflower-comments.rb')
|
9
|
+
|
10
|
+
# Require sunflower-comments.rb explicitly so any dependencies are loaded
|
11
|
+
require Merb::Plugins.config[:merb_slices][:search_path]
|
12
|
+
|
13
|
+
# Using Merb.root below makes sure that the correct root is set for
|
14
|
+
# - testing standalone, without being installed as a gem and no host application
|
15
|
+
# - testing from within the host application; its root will be used
|
16
|
+
Merb.start_environment(
|
17
|
+
:testing => true,
|
18
|
+
:adapter => 'runner',
|
19
|
+
:environment => ENV['MERB_ENV'] || 'test',
|
20
|
+
:session_store => 'memory'
|
21
|
+
)
|
22
|
+
|
23
|
+
module Merb
|
24
|
+
module Test
|
25
|
+
module SliceHelper
|
26
|
+
|
27
|
+
# The absolute path to the current slice
|
28
|
+
def current_slice_root
|
29
|
+
@current_slice_root ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
30
|
+
end
|
31
|
+
|
32
|
+
# Whether the specs are being run from a host application or standalone
|
33
|
+
def standalone?
|
34
|
+
Merb.root == ::SunflowerComments.root
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Spec::Runner.configure do |config|
|
42
|
+
config.include(Merb::Test::ViewHelper)
|
43
|
+
config.include(Merb::Test::RouteHelper)
|
44
|
+
config.include(Merb::Test::ControllerHelper)
|
45
|
+
config.include(Merb::Test::SliceHelper)
|
46
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "SunflowerComments (module)" do
|
4
|
+
|
5
|
+
# Implement your SunflowerComments specs here
|
6
|
+
|
7
|
+
it "should have proper specs"
|
8
|
+
|
9
|
+
# To spec SunflowerComments you need to hook it up to the router like this:
|
10
|
+
|
11
|
+
# before :all do
|
12
|
+
# Merb::Router.prepare { add_slice(:SunflowerComments) } if standalone?
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# after :all do
|
16
|
+
# Merb::Router.reset! if standalone?
|
17
|
+
# end
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: laurynasl-sunflower-comments
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Laurynas Liutkus
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-28 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-slices
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.3
|
24
|
+
version:
|
25
|
+
description: Merb Slice that provides sequel + postgres + comments = comment anything (polymorphic, with database triggers)
|
26
|
+
email: laurynasl@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README
|
33
|
+
- LICENSE
|
34
|
+
- TODO
|
35
|
+
files:
|
36
|
+
- LICENSE
|
37
|
+
- README
|
38
|
+
- Rakefile
|
39
|
+
- TODO
|
40
|
+
- lib/sunflower-comments.rb
|
41
|
+
- lib/sunflower-comments
|
42
|
+
- lib/sunflower-comments/slicetasks.rb
|
43
|
+
- lib/sunflower-comments/merbtasks.rb
|
44
|
+
- lib/sunflower-comments/spectasks.rb
|
45
|
+
- spec/sunflower-comments_spec.rb
|
46
|
+
- spec/spec_helper.rb
|
47
|
+
- spec/controllers
|
48
|
+
- spec/controllers/main_spec.rb
|
49
|
+
- app/views
|
50
|
+
- app/views/main
|
51
|
+
- app/views/main/index.html.erb
|
52
|
+
- app/views/layout
|
53
|
+
- app/views/layout/sunflower_comments.html.erb
|
54
|
+
- app/controllers
|
55
|
+
- app/controllers/main.rb
|
56
|
+
- app/controllers/application.rb
|
57
|
+
- app/helpers
|
58
|
+
- app/helpers/application_helper.rb
|
59
|
+
- public/stylesheets
|
60
|
+
- public/stylesheets/master.css
|
61
|
+
- public/javascripts
|
62
|
+
- public/javascripts/master.js
|
63
|
+
- stubs/app
|
64
|
+
- stubs/app/controllers
|
65
|
+
- stubs/app/controllers/main.rb
|
66
|
+
- stubs/app/controllers/application.rb
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: http://github.com/laurynasl/sunflower-comments/
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project: merb
|
89
|
+
rubygems_version: 1.2.0
|
90
|
+
signing_key:
|
91
|
+
specification_version: 2
|
92
|
+
summary: Merb Slice that provides sequel + postgres + comments = comment anything (polymorphic, with database triggers)
|
93
|
+
test_files: []
|
94
|
+
|