utopia 1.9.2 → 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/documentation/.bowerrc +2 -2
- data/documentation/pages/_page.xnode +11 -0
- data/documentation/pages/wiki/controller/actions/content.md +76 -68
- data/documentation/pages/wiki/controller/rewrite/content.md +69 -64
- data/documentation/pages/wiki/controller.rb +6 -1
- data/documentation/pages/wiki/development-environment-setup/content.md +16 -14
- data/documentation/pages/wiki/server-setup/content.md +46 -40
- data/documentation/pages/wiki/show.xnode +1 -1
- data/documentation/pages/wiki/your-first-page/content.md +36 -31
- data/documentation/public/_components/jquery/core.js +482 -0
- data/documentation/public/_components/jquery/jquery.js +10220 -0
- data/documentation/public/_components/jquery/jquery.min.js +4 -0
- data/documentation/public/_components/jquery/jquery.min.map +1 -0
- data/documentation/public/_components/jquery/jquery.slim.js +8107 -0
- data/documentation/public/_components/jquery/jquery.slim.min.js +4 -0
- data/documentation/public/_components/jquery/jquery.slim.min.map +1 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/040afc1428b286fb3c50151378b349a6149698d3/jquery.syntax.core.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.editor.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.fixed.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.inline.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.list.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.plain.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.table.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/10c58b30c53bf84f8360af8a864797092be26882/jquery.syntax.core.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/10c58b30c53bf84f8360af8a864797092be26882/jquery.syntax.layout.fixed.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/10c58b30c53bf84f8360af8a864797092be26882/jquery.syntax.layout.inline.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/_layout.scssc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.apache.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.applescript.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.assembly.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.bash-script.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.bash.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.clang.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.css.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.diff.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.html.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.ocaml.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.protobuf.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.python.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.ruby.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.xml.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.core.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.editor.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.editor.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.fixed.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.list.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.plain.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.table.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/8638ad407c5ea29f6547cf8ac6983da587354889/master.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/b7ab87e6269b4fe89f9475b7a260077391d3567b/jquery.syntax.layout.editor.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/b7ab87e6269b4fe89f9475b7a260077391d3567b/jquery.syntax.layout.fixed.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/b7ab87e6269b4fe89f9475b7a260077391d3567b/jquery.syntax.layout.inline.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/b7ab87e6269b4fe89f9475b7a260077391d3567b/jquery.syntax.layout.plain.sassc +0 -0
- data/documentation/public/_components/jquery-syntax/.sass-cache/e82f8cf4c8436da086a4506e01ef78755ebab1ce/master.scssc +0 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.apache.css +6 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.applescript.css +5 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.assembly.css +8 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.bash-script.css +6 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.bash.css +10 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.clang.css +3 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.css.css +14 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.diff.css +16 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.html.css +5 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.ocaml.css +3 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.protobuf.css +2 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.python.css +6 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.ruby.css +2 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.xml.css +18 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.core.css +59 -0
- data/documentation/public/_components/jquery-syntax/base/jquery.syntax.editor.css +6 -0
- data/documentation/public/_components/jquery-syntax/base/theme.js +1 -0
- data/documentation/public/_components/jquery-syntax/bright/jquery.syntax.core.css +27 -0
- data/documentation/public/_components/jquery-syntax/bright/theme.js +1 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.apache.js +41 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.applescript.js +57 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.assembly.js +37 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.bash-script.js +67 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.bash.js +33 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.basic.js +51 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.clang.js +89 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.csharp.js +47 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.css.js +80 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.diff.js +24 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.go.js +47 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.haskell.js +45 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.html.js +66 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.io.js +45 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.java.js +45 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.javascript.js +40 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.kai.js +29 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.lisp.js +34 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.lua.js +44 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.nginx.js +31 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.ocaml.js +73 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.ooc.js +46 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.pascal.js +51 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.perl5.js +52 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.php-script.js +48 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.php.js +15 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.plain.js +10 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.protobuf.js +43 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.python.js +44 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.ruby.js +77 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.scala.js +44 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.smalltalk.js +29 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.sql.js +31 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.super-collider.js +57 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.swift.js +55 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.trenni.js +35 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.xml.js +50 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.yaml.js +29 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.cache.js +65 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.core.js +1098 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.editor.js +291 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.js +258 -0
- data/documentation/public/_components/jquery-syntax/jquery.syntax.min.js +13 -0
- data/documentation/public/_components/jquery-syntax/paper/jquery.syntax.core.css +31 -0
- data/documentation/public/_components/jquery-syntax/paper/theme.js +1 -0
- data/documentation/public/_static +1 -0
- data/documentation/tasks +1 -0
- data/lib/utopia/command.rb +1 -1
- data/lib/utopia/controller/actions.rb +1 -2
- data/lib/utopia/controller/respond.rb +1 -1
- data/lib/utopia/version.rb +1 -1
- data/setup/site/.bowerrc +2 -2
- data/setup/site/config.ru +1 -1
- data/setup/site/public/_static/site.css +16 -1
- data/setup/site/tasks/bower.rake +48 -0
- metadata +114 -5
- data/documentation/public +0 -1
- data/documentation/tasks/test.rake +0 -10
- data/documentation/tasks/utopia.rake +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1144177e365248c9b24dae032a7c40cb7d2d3397
|
4
|
+
data.tar.gz: 9255986187c7c87a7504e0c945fa258b82622dd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b57a7bec393a3980a1101e62508ce74e066bc2078df20f01084bcc2557615788e244827dd3d056feaf77624094a921e0b284eb7b0d5f02ed841a9d376e36fa0c
|
7
|
+
data.tar.gz: c4c81fa608bbbb2e487c2191d3bd03081f06b2bcebcbb28859d03b6fa7b0cc1e8e602f31575c23c00a447d32dc87d0ef37f09d016aa0e8de3decd0087f736339
|
data/documentation/.bowerrc
CHANGED
@@ -14,6 +14,17 @@
|
|
14
14
|
|
15
15
|
<link rel="icon" type="image/png" href="/_static/icon.png" />
|
16
16
|
<link rel="stylesheet" href="/_static/site.css" type="text/css" media="screen" />
|
17
|
+
|
18
|
+
<script src="/_components/jquery/jquery.min.js"></script>
|
19
|
+
<script src="/_components/jquery-syntax/jquery.syntax.min.js"></script>
|
20
|
+
|
21
|
+
<script type="text/javascript">
|
22
|
+
//<![CDATA[
|
23
|
+
jQuery(function($) {
|
24
|
+
$.syntax();
|
25
|
+
});
|
26
|
+
//]]>
|
27
|
+
</script>
|
17
28
|
</head>
|
18
29
|
|
19
30
|
<body class="#{attributes[:class]}">
|
@@ -1,68 +1,76 @@
|
|
1
|
-
# Controller::Actions
|
2
|
-
|
3
|
-
Actions let you match path patterns in your controller and execute code. In your `controller.rb` simply add:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<dt>
|
57
|
-
<dd>
|
58
|
-
</
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
If
|
1
|
+
# Controller::Actions
|
2
|
+
|
3
|
+
Actions let you match path patterns in your controller and execute code. In your `controller.rb` simply add:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
prepend Actions
|
7
|
+
```
|
8
|
+
|
9
|
+
If you are adding multiple things, like rewriting, they should come earlier in the chain, e.g:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
prepend Rewrite, Actions
|
13
|
+
```
|
14
|
+
|
15
|
+
A simple CRUD controller might look like:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
prepend Actions
|
19
|
+
|
20
|
+
on 'index' do
|
21
|
+
@users = User.all
|
22
|
+
end
|
23
|
+
|
24
|
+
on 'new' do |request|
|
25
|
+
@user = User.new
|
26
|
+
|
27
|
+
if request.post?
|
28
|
+
@user.update_attributes(request.params['user'])
|
29
|
+
|
30
|
+
redirect! "index"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
on 'edit' do |request|
|
35
|
+
@user = User.find(request.params['id'])
|
36
|
+
|
37
|
+
if request.post?
|
38
|
+
@user.update_attributes(request.params['user'])
|
39
|
+
|
40
|
+
redirect! "index"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
on 'delete' do |request|
|
45
|
+
User.find(request.params['id']).destroy
|
46
|
+
|
47
|
+
redirect! "index"
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
## Path Matching
|
52
|
+
|
53
|
+
Path matching works from right to left, and '**' is a greedy operator. Controllers are invoked with a path relative to the controller's `URI_PATH`, so all lookups are relative to the controller.
|
54
|
+
|
55
|
+
<dl>
|
56
|
+
<dt><code class="language-ruby">"*"</code></dt>
|
57
|
+
<dd>Match a single path element</dd>
|
58
|
+
<dt><code class="language-ruby">"**"</code></dt>
|
59
|
+
<dd>Match all remaining path elements</dd>
|
60
|
+
<dt><code class="language-ruby">String</code></dt>
|
61
|
+
<dd>Match a named path component, e.g. <code class="language-ruby">"edit"</code>.</dd>
|
62
|
+
<dt><code class="language-ruby">Symbol</code></dt>
|
63
|
+
<dd>Equivalent to <code class="language-ruby">["**", symbol.to_s]</code>, e.g. <code class="language-ruby">:logout</code>.</dd>
|
64
|
+
</dl>
|
65
|
+
|
66
|
+
## Otherwise Matching
|
67
|
+
|
68
|
+
If no action was matched, it is sometimes useful to perform some specific behaviour. You can specify this by using the otherwise handler:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
otherwise do |request, path|
|
72
|
+
fail! :teapot
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
If you are doing this to perform some kind of rewriting, it may be preferable to use the [Rewrite](rewrite/) controller layer.
|
@@ -1,64 +1,69 @@
|
|
1
|
-
# Controller::Rewrite
|
2
|
-
|
3
|
-
The
|
4
|
-
|
5
|
-
## Regular Expressions
|
6
|
-
|
7
|
-
In your `controller.rb`:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
</
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
1
|
+
# Controller::Rewrite
|
2
|
+
|
3
|
+
The <code class="language-ruby">Controller::Rewrite</code> layer can match and rewrite requests before they processed. This allows you to handle URLs like `/post/15/view` or `/blog/123-pictures-of-my-cat` easily. The basic rewrite operation is to extract some part of the path and optionally executes a block. That means that the path is modified before being passed on to the next layer in the controller, and controller instance variables may be set.
|
4
|
+
|
5
|
+
## Regular Expressions
|
6
|
+
|
7
|
+
In your `controller.rb`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
prepend Rewrite, Actions
|
11
|
+
|
12
|
+
rewrite.extract_prefix permalink: /(?<id>\d+)-(?<title>.*)/ do |request, path, match|
|
13
|
+
# The rewrite matched, but there was no valid post, so we fail:
|
14
|
+
fail! unless @post = Post.find(@permalink[:id])
|
15
|
+
|
16
|
+
# If the path matched, but there was no suffix, we make it default to the post action:
|
17
|
+
if match.post_match.empty?
|
18
|
+
match.post_match.components << "post"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
on 'post' do
|
23
|
+
# You can do further processing here.
|
24
|
+
fail! unless @post.published?
|
25
|
+
|
26
|
+
@comments = @post.comments.first(5)
|
27
|
+
end
|
28
|
+
|
29
|
+
on 'edit' do
|
30
|
+
# You can do further processing here.
|
31
|
+
fail! unless @current_user&.editor?
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
In your `post.xnode`, as an example:
|
36
|
+
|
37
|
+
```trenni
|
38
|
+
<page>
|
39
|
+
<heading>Post #{attributes[:permalink][:id]} about #{attributes[:permalink][:title]}</heading>
|
40
|
+
|
41
|
+
<p>#{attributes[:post].content}</p>
|
42
|
+
</page>
|
43
|
+
```
|
44
|
+
|
45
|
+
Keep in mind, that URLs like `/123-pictures-of-my-cat/edit` will work as expected, and hit the `edit` action of the controller.
|
46
|
+
|
47
|
+
## Restful Resources
|
48
|
+
|
49
|
+
Similar to the above, if we were solely interested in IDs, we could do the following:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
prepend Rewrite, Actions
|
53
|
+
|
54
|
+
rewrite.extract_prefix post_id: Integer do |request, path, match|
|
55
|
+
# The rewrite matched, but there was no valid post, so we fail:
|
56
|
+
fail! unless @post = Post.find(@post_id)
|
57
|
+
|
58
|
+
# If the path matched, but there was no suffix, we make it default to the post action:
|
59
|
+
if match.post_match.empty?
|
60
|
+
match.post_match.components << "post"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
This will only match complete integers. Assuming this code is in `/blog/controller.rb`, it would match something like `/blog/123/view` and assign <code class="language-ruby">Integer("123")</code> to <code class="language-ruby">@post_id</code>.
|
66
|
+
|
67
|
+
### Matching.. other things
|
68
|
+
|
69
|
+
It's possible to match using <code class="language-ruby">Integer</code>, <code class="language-ruby">Float</code>, <code class="language-ruby">String</code>, and you can provide your own class which will be instantiated. If it doesn't match, raise an exception and the rewrite rule will fail.
|
@@ -26,7 +26,12 @@ end
|
|
26
26
|
on '**/edit' do |request, path|
|
27
27
|
if request.post?
|
28
28
|
FileUtils.mkdir_p File.dirname(@page_file)
|
29
|
-
|
29
|
+
|
30
|
+
# Get the content and normalize newlines:
|
31
|
+
content = request.params['content'].gsub /\r\n?/, "\n"
|
32
|
+
File.write(@page_file, content)
|
33
|
+
|
34
|
+
# Redirect relative to controller.
|
30
35
|
goto! @page_path
|
31
36
|
else
|
32
37
|
@content = read_contents
|
@@ -1,14 +1,16 @@
|
|
1
|
-
# Development Environment Setup
|
2
|
-
|
3
|
-
Utopia is built on Ruby and Rack. Therefore, Ruby (suggested 2.0+) should be installed and working. Then, simply run:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
# Development Environment Setup
|
2
|
+
|
3
|
+
Utopia is built on Ruby and Rack. Therefore, Ruby (suggested 2.0+) should be installed and working. Then, simply run:
|
4
|
+
|
5
|
+
```bash
|
6
|
+
$ gem install utopia
|
7
|
+
```
|
8
|
+
|
9
|
+
To install all required dependencies.
|
10
|
+
|
11
|
+
Utopia and it's dependencies are built on Linux and Mac by default, and therefore compatibility with Windows is not guaranteed.
|
12
|
+
|
13
|
+
## Atom Integration
|
14
|
+
|
15
|
+
Utopia uses [Trenni](https://github.com/ioquatix/trenni) for templates and it has a syntax slightly different from ERB. However, there is a [package for Atom](https://atom.io/packages/language-trenni) which provides accurate syntax highlighting.
|
16
|
+
|
@@ -1,40 +1,46 @@
|
|
1
|
-
# Server Setup
|
2
|
-
|
3
|
-
The best deployment platform for Utopia is Linux. Specifically, [Arch Linux](https://www.archlinux.org/) with the following packages:
|
4
|
-
|
5
|
-
- [nginx-mainline-passenger](https://aur.archlinux.org/packages/nginx-mainline-passenger/)
|
6
|
-
- [passenger-nginx-module](https://aur.archlinux.org/packages/passenger-nginx-module/)
|
7
|
-
|
8
|
-
There have been issues with the official packages and thus these packages were developed and tested with Utopia deployment in mind.
|
9
|
-
|
10
|
-
## Sample Nginx Configuration
|
11
|
-
|
12
|
-
Create a configuration file for your site, e.g. `/etc/nginx/sites/www.example.com`:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
1
|
+
# Server Setup
|
2
|
+
|
3
|
+
The best deployment platform for Utopia is Linux. Specifically, [Arch Linux](https://www.archlinux.org/) with the following packages:
|
4
|
+
|
5
|
+
- [nginx-mainline-passenger](https://aur.archlinux.org/packages/nginx-mainline-passenger/)
|
6
|
+
- [passenger-nginx-module](https://aur.archlinux.org/packages/passenger-nginx-module/)
|
7
|
+
|
8
|
+
There have been issues with the official packages and thus these packages were developed and tested with Utopia deployment in mind.
|
9
|
+
|
10
|
+
## Sample Nginx Configuration
|
11
|
+
|
12
|
+
Create a configuration file for your site, e.g. `/etc/nginx/sites/www.example.com`:
|
13
|
+
|
14
|
+
```nginx
|
15
|
+
server {
|
16
|
+
listen 80;
|
17
|
+
server_name www.example.com;
|
18
|
+
root /srv/http/www.example.com/public;
|
19
|
+
passenger_enabled on;
|
20
|
+
}
|
21
|
+
|
22
|
+
server {
|
23
|
+
listen 80;
|
24
|
+
server_name example.com;
|
25
|
+
rewrite ^ http://www.example.com$uri permanent;
|
26
|
+
}
|
27
|
+
```
|
28
|
+
|
29
|
+
## Deployment via Git
|
30
|
+
|
31
|
+
The preferred method of deployment to a production server is via git. The `utopia` command assists with setup of a remote git repository on the server. It will setup a `git` `post-update` hook which will deploy the site correctly and restart passenger for that site.
|
32
|
+
|
33
|
+
To setup a server for deployment:
|
34
|
+
|
35
|
+
```bash
|
36
|
+
$ mkdir /srv/http/www.example.com
|
37
|
+
$ cd /srv/http/www.example.com
|
38
|
+
$ sudo -u http utopia server create
|
39
|
+
```
|
40
|
+
|
41
|
+
On your development machine, you should setup the git remote:
|
42
|
+
|
43
|
+
```bash
|
44
|
+
$ git remote add production ssh://remote/srv/http/www.example.com
|
45
|
+
$ git push --set-upstream production master
|
46
|
+
```
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
#{partial 'navigation', path: attributes[:full_path].dirname}
|
5
5
|
|
6
|
-
#{MarkupString.raw Kramdown::Document.new(self[:content]).to_html}
|
6
|
+
#{MarkupString.raw Kramdown::Document.new(self[:content], input: 'GFM', syntax_highlighter: nil).to_html}
|
7
7
|
|
8
8
|
<footer>
|
9
9
|
Last Modified: #{File.mtime(self[:page_file]) rescue "N/A"} —
|
@@ -1,31 +1,36 @@
|
|
1
|
-
# Your First Page
|
2
|
-
|
3
|
-
To setup the default site, simply create a directory and use the `utopia` command:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
1
|
+
# Your First Page
|
2
|
+
|
3
|
+
To setup the default site, simply create a directory and use the `utopia` command:
|
4
|
+
|
5
|
+
```bash
|
6
|
+
$ mkdir www.example.com
|
7
|
+
$ cd www.example.com
|
8
|
+
$ utopia site create
|
9
|
+
$ rake server
|
10
|
+
```
|
11
|
+
|
12
|
+
You will now have a basic template site running on http://localhost:9292.
|
13
|
+
|
14
|
+
## Welcome Page
|
15
|
+
|
16
|
+
Utopia includes a redirection middleware to redirect all root-level requests to a given URI. The default being `/welcome/index`:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
use Utopia::Redirection::Rewrite,
|
20
|
+
'/' => '/welcome/index'
|
21
|
+
```
|
22
|
+
|
23
|
+
This page includes a basic overview of Utopia. Most of it's standard HTML, except for the outer `<page>` tag. Utopia uses the name `page` to lookup the file-system hierarchy. First, it looks for `/welcome/_page.xnode`, and then it looks for `/_page.xnode` which it finds. This page template includes a tag `<content/>` which is replaced with the inner body of the `<page>` tag. This recursive lookup is the heart of Utopia.
|
24
|
+
|
25
|
+
## Links
|
26
|
+
|
27
|
+
Utopia is a content-centric web application platform. It leverages the file-system to provide a mapping between logical resources and files on disk. The primary mode of mapping incoming requests to specific nodes (content) is done using the `links.yaml` file.
|
28
|
+
|
29
|
+
The links file associates metadata with node names for a given directory. This can include things like redirects, titles, descriptions, etc. You can add any metadata you like, to support your specific use-case. The primary use of the links files is to provide site structure, e.g. menus. In addition, they can function as a rudimentary data-store for static information, e.g. a list of applications (each with it's own page), a list of features, etc.
|
30
|
+
|
31
|
+
You'll notice that there is a file `/links.yaml`. This file contains important metadata relating to the `errors` subdirectory. As we don't want these nodes showing up in a top level menu, we mark them as `display: false`
|
32
|
+
|
33
|
+
```yaml
|
34
|
+
errors:
|
35
|
+
display: false
|
36
|
+
```
|