utopia 1.9.2 → 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/.bowerrc +2 -2
  3. data/documentation/pages/_page.xnode +11 -0
  4. data/documentation/pages/wiki/controller/actions/content.md +76 -68
  5. data/documentation/pages/wiki/controller/rewrite/content.md +69 -64
  6. data/documentation/pages/wiki/controller.rb +6 -1
  7. data/documentation/pages/wiki/development-environment-setup/content.md +16 -14
  8. data/documentation/pages/wiki/server-setup/content.md +46 -40
  9. data/documentation/pages/wiki/show.xnode +1 -1
  10. data/documentation/pages/wiki/your-first-page/content.md +36 -31
  11. data/documentation/public/_components/jquery/core.js +482 -0
  12. data/documentation/public/_components/jquery/jquery.js +10220 -0
  13. data/documentation/public/_components/jquery/jquery.min.js +4 -0
  14. data/documentation/public/_components/jquery/jquery.min.map +1 -0
  15. data/documentation/public/_components/jquery/jquery.slim.js +8107 -0
  16. data/documentation/public/_components/jquery/jquery.slim.min.js +4 -0
  17. data/documentation/public/_components/jquery/jquery.slim.min.map +1 -0
  18. data/documentation/public/_components/jquery-syntax/.sass-cache/040afc1428b286fb3c50151378b349a6149698d3/jquery.syntax.core.sassc +0 -0
  19. data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.editor.sassc +0 -0
  20. data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.fixed.sassc +0 -0
  21. data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.inline.sassc +0 -0
  22. data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.list.sassc +0 -0
  23. data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.plain.sassc +0 -0
  24. data/documentation/public/_components/jquery-syntax/.sass-cache/098642d80a1682613dca2bba6fd0a3bc9fd2bf04/jquery.syntax.layout.table.sassc +0 -0
  25. data/documentation/public/_components/jquery-syntax/.sass-cache/10c58b30c53bf84f8360af8a864797092be26882/jquery.syntax.core.sassc +0 -0
  26. data/documentation/public/_components/jquery-syntax/.sass-cache/10c58b30c53bf84f8360af8a864797092be26882/jquery.syntax.layout.fixed.sassc +0 -0
  27. data/documentation/public/_components/jquery-syntax/.sass-cache/10c58b30c53bf84f8360af8a864797092be26882/jquery.syntax.layout.inline.sassc +0 -0
  28. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/_layout.scssc +0 -0
  29. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.apache.sassc +0 -0
  30. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.applescript.sassc +0 -0
  31. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.assembly.sassc +0 -0
  32. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.bash-script.sassc +0 -0
  33. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.bash.sassc +0 -0
  34. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.clang.sassc +0 -0
  35. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.css.sassc +0 -0
  36. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.diff.sassc +0 -0
  37. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.html.sassc +0 -0
  38. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.ocaml.sassc +0 -0
  39. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.protobuf.sassc +0 -0
  40. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.python.sassc +0 -0
  41. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.ruby.sassc +0 -0
  42. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.brush.xml.sassc +0 -0
  43. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.core.sassc +0 -0
  44. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.editor.sassc +0 -0
  45. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.editor.sassc +0 -0
  46. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.fixed.sassc +0 -0
  47. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.list.sassc +0 -0
  48. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.plain.sassc +0 -0
  49. data/documentation/public/_components/jquery-syntax/.sass-cache/3c69ad94149e2a6d9f4ffda01814fee3947b1389/jquery.syntax.layout.table.sassc +0 -0
  50. data/documentation/public/_components/jquery-syntax/.sass-cache/8638ad407c5ea29f6547cf8ac6983da587354889/master.sassc +0 -0
  51. data/documentation/public/_components/jquery-syntax/.sass-cache/b7ab87e6269b4fe89f9475b7a260077391d3567b/jquery.syntax.layout.editor.sassc +0 -0
  52. data/documentation/public/_components/jquery-syntax/.sass-cache/b7ab87e6269b4fe89f9475b7a260077391d3567b/jquery.syntax.layout.fixed.sassc +0 -0
  53. data/documentation/public/_components/jquery-syntax/.sass-cache/b7ab87e6269b4fe89f9475b7a260077391d3567b/jquery.syntax.layout.inline.sassc +0 -0
  54. data/documentation/public/_components/jquery-syntax/.sass-cache/b7ab87e6269b4fe89f9475b7a260077391d3567b/jquery.syntax.layout.plain.sassc +0 -0
  55. data/documentation/public/_components/jquery-syntax/.sass-cache/e82f8cf4c8436da086a4506e01ef78755ebab1ce/master.scssc +0 -0
  56. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.apache.css +6 -0
  57. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.applescript.css +5 -0
  58. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.assembly.css +8 -0
  59. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.bash-script.css +6 -0
  60. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.bash.css +10 -0
  61. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.clang.css +3 -0
  62. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.css.css +14 -0
  63. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.diff.css +16 -0
  64. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.html.css +5 -0
  65. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.ocaml.css +3 -0
  66. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.protobuf.css +2 -0
  67. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.python.css +6 -0
  68. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.ruby.css +2 -0
  69. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.brush.xml.css +18 -0
  70. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.core.css +59 -0
  71. data/documentation/public/_components/jquery-syntax/base/jquery.syntax.editor.css +6 -0
  72. data/documentation/public/_components/jquery-syntax/base/theme.js +1 -0
  73. data/documentation/public/_components/jquery-syntax/bright/jquery.syntax.core.css +27 -0
  74. data/documentation/public/_components/jquery-syntax/bright/theme.js +1 -0
  75. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.apache.js +41 -0
  76. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.applescript.js +57 -0
  77. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.assembly.js +37 -0
  78. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.bash-script.js +67 -0
  79. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.bash.js +33 -0
  80. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.basic.js +51 -0
  81. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.clang.js +89 -0
  82. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.csharp.js +47 -0
  83. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.css.js +80 -0
  84. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.diff.js +24 -0
  85. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.go.js +47 -0
  86. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.haskell.js +45 -0
  87. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.html.js +66 -0
  88. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.io.js +45 -0
  89. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.java.js +45 -0
  90. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.javascript.js +40 -0
  91. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.kai.js +29 -0
  92. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.lisp.js +34 -0
  93. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.lua.js +44 -0
  94. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.nginx.js +31 -0
  95. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.ocaml.js +73 -0
  96. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.ooc.js +46 -0
  97. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.pascal.js +51 -0
  98. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.perl5.js +52 -0
  99. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.php-script.js +48 -0
  100. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.php.js +15 -0
  101. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.plain.js +10 -0
  102. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.protobuf.js +43 -0
  103. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.python.js +44 -0
  104. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.ruby.js +77 -0
  105. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.scala.js +44 -0
  106. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.smalltalk.js +29 -0
  107. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.sql.js +31 -0
  108. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.super-collider.js +57 -0
  109. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.swift.js +55 -0
  110. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.trenni.js +35 -0
  111. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.xml.js +50 -0
  112. data/documentation/public/_components/jquery-syntax/jquery.syntax.brush.yaml.js +29 -0
  113. data/documentation/public/_components/jquery-syntax/jquery.syntax.cache.js +65 -0
  114. data/documentation/public/_components/jquery-syntax/jquery.syntax.core.js +1098 -0
  115. data/documentation/public/_components/jquery-syntax/jquery.syntax.editor.js +291 -0
  116. data/documentation/public/_components/jquery-syntax/jquery.syntax.js +258 -0
  117. data/documentation/public/_components/jquery-syntax/jquery.syntax.min.js +13 -0
  118. data/documentation/public/_components/jquery-syntax/paper/jquery.syntax.core.css +31 -0
  119. data/documentation/public/_components/jquery-syntax/paper/theme.js +1 -0
  120. data/documentation/public/_static +1 -0
  121. data/documentation/tasks +1 -0
  122. data/lib/utopia/command.rb +1 -1
  123. data/lib/utopia/controller/actions.rb +1 -2
  124. data/lib/utopia/controller/respond.rb +1 -1
  125. data/lib/utopia/version.rb +1 -1
  126. data/setup/site/.bowerrc +2 -2
  127. data/setup/site/config.ru +1 -1
  128. data/setup/site/public/_static/site.css +16 -1
  129. data/setup/site/tasks/bower.rake +48 -0
  130. metadata +114 -5
  131. data/documentation/public +0 -1
  132. data/documentation/tasks/test.rake +0 -10
  133. data/documentation/tasks/utopia.rake +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f08603b8fc77e5ffe85cf2f402be73c09502643
4
- data.tar.gz: 81540559da3ee6823a0a3f1754c7446b28228b5a
3
+ metadata.gz: 1144177e365248c9b24dae032a7c40cb7d2d3397
4
+ data.tar.gz: 9255986187c7c87a7504e0c945fa258b82622dd0
5
5
  SHA512:
6
- metadata.gz: caa96b4c7e561170b1bcfc4a1d783561d3e46b4e65f8c3ecadce76a3b43846f6d4fa2d26765d644aca197a77206b775ed30bed79f8e1c58bdc97459e90f815ce
7
- data.tar.gz: 8e000468cebb8b29e356269e83e3dd6f79cfd7d64f41ad4155ca79943f1e74a28f8b2e3fb3bd1df0da9c7e64da8595f8795c7e1b38bd0c398406716311a67a91
6
+ metadata.gz: b57a7bec393a3980a1101e62508ce74e066bc2078df20f01084bcc2557615788e244827dd3d056feaf77624094a921e0b284eb7b0d5f02ed841a9d376e36fa0c
7
+ data.tar.gz: c4c81fa608bbbb2e487c2191d3bd03081f06b2bcebcbb28859d03b6fa7b0cc1e8e602f31575c23c00a447d32dc87d0ef37f09d016aa0e8de3decd0087f736339
@@ -1,4 +1,4 @@
1
1
  {
2
- "directory" : "public/_static/components"
2
+ "directory": "lib/components",
3
+ "public": "public/_components"
3
4
  }
4
-
@@ -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
- prepend Actions
6
-
7
- If you are adding multiple things, like rewriting, they should come earlier in the chain, e.g:
8
-
9
- prepend Rewrite, Actions
10
-
11
- A simple CRUD controller might look like:
12
-
13
- prepend Actions
14
-
15
- on 'index' do
16
- @users = User.all
17
- end
18
-
19
- on 'new' do |request|
20
- @user = User.new
21
-
22
- if request.post?
23
- @user.update_attributes(request.params['user'])
24
-
25
- redirect! "index"
26
- end
27
- end
28
-
29
- on 'edit' do |request|
30
- @user = User.find(request.params['id'])
31
-
32
- if request.post?
33
- @user.update_attributes(request.params['user'])
34
-
35
- redirect! "index"
36
- end
37
- end
38
-
39
- on 'delete' do |request|
40
- User.find(request.params['id']).destroy
41
-
42
- redirect! "index"
43
- end
44
-
45
- ## Path Matching
46
-
47
- 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.
48
-
49
- <dl>
50
- <dt>"*"</dt>
51
- <dd>Match a single path element</dd>
52
- <dt>"**"<dt>
53
- <dd>Match all remaining path elements</dd>
54
- <dt>String</dt>
55
- <dd>Match a named path component</dd>
56
- <dt>Symbol</dt>
57
- <dd>Equivalent to ["**", symbol.to_s]</dd>
58
- </dl>
59
-
60
- ## Otherwise Matching
61
-
62
- If no action was matched, it is sometimes useful to perform some specific behaviour. You can specify this by using the otherwise handler:
63
-
64
- otherwise do |request, path|
65
- fail! :teapot
66
- end
67
-
68
- If you are doing this to perform some kind of rewriting, it may be preferable to use the [Rewrite](rewrite/) controller layer.
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 `Controller::Rewrite` 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
- prepend Actions, Rewrite
10
-
11
- rewrite.extract_prefix permalink: /(?<id>\d+)-(?<title>.*)/ do |request, path, match|
12
- # The rewrite matched, but there was no valid post, so we fail:
13
- fail! unless @post = Post.find(@permalink[:id])
14
-
15
- # If the path matched, but there was no suffix, we make it default to the post action:
16
- if match.post_match.empty?
17
- match.post_match.components << "post"
18
- end
19
- end
20
-
21
- on 'post' do
22
- # You can do further processing here.
23
- fail! unless @post.published?
24
-
25
- @comments = @post.comments.first(5)
26
- end
27
-
28
- on 'edit' do
29
- # You can do further processing here.
30
- fail! unless @current_user&.editor?
31
- end
32
-
33
- In your `post.xnode`, as an example:
34
-
35
- <page>
36
- <heading>Post #{attributes[:permalink][:id]} about #{attributes[:permalink][:title]}</heading>
37
-
38
- <p>#{attributes[:post].content}</p>
39
- </page>
40
-
41
- Keep in mind, that URLs like `/123-pictures-of-my-cat/edit` will work as expected, and hit the `edit` action of the controller.
42
-
43
- ## Restful Resources
44
-
45
- Similar to the above, if we were solely interested in IDs, we could do the following:
46
-
47
- prepend Actions, Rewrite
48
-
49
- rewrite.extract_prefix post_id: Integer do |request, path, match|
50
- # The rewrite matched, but there was no valid post, so we fail:
51
- fail! unless @post = Post.find(@post_id)
52
-
53
- # If the path matched, but there was no suffix, we make it default to the post action:
54
- if match.post_match.empty?
55
- match.post_match.components << "post"
56
- end
57
- end
58
-
59
- This will only match complete integers. Assuming this code is in `/blog/controller.rb`, it would match something like `/blog/123/view` and assign Integer("123") to `@post_id`.
60
-
61
- ### Matching.. other things
62
-
63
- It's possible to match using `Integer`, `Float`, `String`, 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.
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
- File.write(@page_file, request.params['content'])
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
- $ gem install utopia
6
-
7
- To install all required dependencies.
8
-
9
- Utopia and it's dependencies are built on Linux and Mac by default, and therefore compatibility with Windows is not guaranteed.
10
-
11
- ## Atom Integration
12
-
13
- 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.
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
- server {
15
- listen 80;
16
- server_name www.example.com;
17
- root /srv/http/www.example.com/public;
18
- passenger_enabled on;
19
- }
20
-
21
- server {
22
- listen 80;
23
- server_name example.com;
24
- rewrite ^ http://www.example.com$uri permanent;
25
- }
26
-
27
- ## Deployment via Git
28
-
29
- 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.
30
-
31
- To setup a server for deployment:
32
-
33
- $ mkdir /srv/http/www.example.com
34
- $ cd /srv/http/www.example.com
35
- $ sudo -u http utopia server create
36
-
37
- On your development machine, you should setup the git remote:
38
-
39
- $ git remote add production ssh://remote/srv/http/www.example.com
40
- $ git push --set-upstream production master
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"} &mdash;
@@ -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
- $ mkdir www.example.com
6
- $ cd www.example.com
7
- $ utopia site create
8
- $ rake server
9
-
10
- You will now have a basic template site running on http://localhost:9292.
11
-
12
- ## Welcome Page
13
-
14
- Utopia includes a redirection middleware to redirect all root-level requests to a given URI. The default being `/welcome/index`:
15
-
16
- use Utopia::Redirection::Rewrite,
17
- '/' => '/welcome/index'
18
-
19
- 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.
20
-
21
- ## Links
22
-
23
- 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.
24
-
25
- 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.
26
-
27
- 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`
28
-
29
- errors:
30
- display: false
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
+ ```