You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: context/getting-started.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This guide explains how to set up a `utopia` website for local development and d
4
4
5
5
## Installation
6
6
7
-
Utopia is built on Ruby and Rack. Therefore, Ruby (suggested 2.0+) should be installed and working. Then, to install `utopia` and all required dependencies, run:
7
+
Utopia is built on Ruby. Therefore, Ruby should be installed and working. Then, to install `utopia` and all required dependencies, run:
8
8
9
9
~~~bash
10
10
$ gem install utopia
@@ -32,10 +32,12 @@ You will now have a basic template site running on `https://localhost:9292`.
32
32
Utopia includes a redirection middleware to redirect all root-level requests to a given URI. The default being `/welcome/index`:
33
33
34
34
```ruby
35
-
# in config.ru
35
+
# in config/application.rb
36
36
37
-
use Utopia::Redirection::Rewrite,
38
-
"/" => "/welcome/index"
37
+
Application=Utopia::Application.build do
38
+
use Utopia::Redirection::Rewrite,
39
+
"/" => "/welcome/index"
40
+
end
39
41
```
40
42
41
43
The content for this page is stored in `pages/welcome/index.xnode`. The format of this page is a subset of HTML5 - open and close tags are strictly enforced.
Copy file name to clipboardExpand all lines: context/middleware.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# Middleware
2
2
3
-
This guide gives an overview of the different Rack middleware used by Utopia.
3
+
This guide gives an overview of the different middleware used by Utopia.
4
4
5
5
## Static
6
6
7
-
The {ruby Utopia::Static} middleware services static files efficiently. By default, it works with `Rack::Sendfile` and supports `ETag` based caching. Normally, you'd prefer to put static files into `public/_static` but it's also acceptable to put static content into `pages/` if it makes sense.
7
+
The {ruby Utopia::Static} middleware services static files efficiently and supports `ETag` based caching. Normally, you'd prefer to put static files into `public/_static` but it's also acceptable to put static content into `pages/` if it makes sense.
8
8
9
9
~~~ruby
10
10
use Utopia::Static,
@@ -36,7 +36,7 @@ use Utopia::Redirection::Errors,
36
36
37
37
## Localization
38
38
39
-
The {ruby Utopia::Localization} middleware provides non-intrusive localization on top of the controller and view layers. The middleware uses the `accept-language` header to guess the preferred locale out of the given options. If a request path maps to a resource, that resource is returned. Otherwise, a non-localized request is made.
39
+
The {ruby Utopia::Localization} middleware computes immutable localization preferences from the request path, host, and `accept-language` header. Localization-aware resource middleware, including {ruby Utopia::Static} and {ruby Utopia::Content}, resolves those preferences without invoking controllers more than once. Place the localization middleware before those resources in the middleware stack.
40
40
41
41
~~~ruby
42
42
use Utopia::Localization,
@@ -53,7 +53,7 @@ pages/index.ja.xnode
53
53
pages/index.zh.xnode
54
54
~~~
55
55
56
-
You can also access the current locale in the view via {ruby Utopia::Content::Node::Context#localization}.
56
+
You can access the selected locale in a view using `localization.locale`. Controllers can inspect the request preferences using `request.localization`.
All session data is stored on the client, but it's encrypted with a salt and the secret key. It is impossible for the client to decrypt the data without the secret stored on the server.
158
+
159
+
When the middleware is installed, the session is available on the request:
Copy file name to clipboardExpand all lines: guides/getting-started/readme.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This guide explains how to set up a `utopia` website for local development and d
4
4
5
5
## Installation
6
6
7
-
Utopia is built on Ruby and Rack. Therefore, Ruby (suggested 2.0+) should be installed and working. Then, to install `utopia` and all required dependencies, run:
7
+
Utopia is built on Ruby. Therefore, Ruby should be installed and working. Then, to install `utopia` and all required dependencies, run:
8
8
9
9
~~~bash
10
10
$ gem install utopia
@@ -32,10 +32,12 @@ You will now have a basic template site running on `https://localhost:9292`.
32
32
Utopia includes a redirection middleware to redirect all root-level requests to a given URI. The default being `/welcome/index`:
33
33
34
34
```ruby
35
-
# in config.ru
35
+
# in config/application.rb
36
36
37
-
use Utopia::Redirection::Rewrite,
38
-
"/" => "/welcome/index"
37
+
Application=Utopia::Application.build do
38
+
use Utopia::Redirection::Rewrite,
39
+
"/" => "/welcome/index"
40
+
end
39
41
```
40
42
41
43
The content for this page is stored in `pages/welcome/index.xnode`. The format of this page is a subset of HTML5 - open and close tags are strictly enforced.
0 commit comments