utopia 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +1 -0
- data/.travis.yml +3 -1
- data/Gemfile +2 -0
- data/README.md +2 -2
- data/Rakefile +19 -7
- data/docs/.nojekyll +0 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.apache.css +6 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.applescript.css +5 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.assembly.css +8 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.bash-script.css +6 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.bash.css +10 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.clang.css +3 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.css.css +14 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.diff.css +16 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.html.css +5 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.ocaml.css +3 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.protobuf.css +2 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.python.css +6 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.ruby.css +2 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.brush.xml.css +18 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.core.css +62 -0
- data/docs/_components/jquery-syntax/base/jquery.syntax.editor.css +6 -0
- data/docs/_components/jquery-syntax/base/theme.js +1 -0
- data/docs/_components/jquery-syntax/bright/jquery.syntax.core.css +27 -0
- data/docs/_components/jquery-syntax/bright/theme.js +1 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.apache.js +41 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.applescript.js +57 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.assembly.js +37 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.bash-script.js +67 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.bash.js +33 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.basic.js +51 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.clang.js +89 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.csharp.js +47 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.css.js +80 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.diff.js +24 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.go.js +47 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.haskell.js +45 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.html.js +66 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.io.js +45 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.java.js +45 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.javascript.js +40 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.kai.js +29 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.lisp.js +34 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.lua.js +44 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.nginx.js +31 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.ocaml.js +73 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.ooc.js +46 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.pascal.js +51 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.perl5.js +52 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.php-script.js +48 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.php.js +15 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.plain.js +10 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.protobuf.js +43 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.python.js +44 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.ruby.js +77 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.scala.js +44 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.smalltalk.js +29 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.sql.js +31 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.super-collider.js +57 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.swift.js +55 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.trenni.js +35 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.xml.js +50 -0
- data/docs/_components/jquery-syntax/jquery.syntax.brush.yaml.js +29 -0
- data/docs/_components/jquery-syntax/jquery.syntax.cache.js +65 -0
- data/docs/_components/jquery-syntax/jquery.syntax.core.js +1098 -0
- data/docs/_components/jquery-syntax/jquery.syntax.editor.js +291 -0
- data/docs/_components/jquery-syntax/jquery.syntax.js +258 -0
- data/docs/_components/jquery-syntax/jquery.syntax.min.js +13 -0
- data/docs/_components/jquery-syntax/paper/jquery.syntax.core.css +31 -0
- data/docs/_components/jquery-syntax/paper/theme.js +1 -0
- data/docs/_components/jquery/core.js +482 -0
- data/docs/_components/jquery/jquery.js +10220 -0
- data/docs/_components/jquery/jquery.min.js +4 -0
- data/docs/_components/jquery/jquery.min.map +1 -0
- data/docs/_components/jquery/jquery.slim.js +8107 -0
- data/docs/_components/jquery/jquery.slim.min.js +4 -0
- data/docs/_components/jquery/jquery.slim.min.map +1 -0
- data/docs/_static/icon.png +0 -0
- data/docs/_static/site.css +205 -0
- data/docs/_static/utopia-background.svg +1 -0
- data/docs/_static/utopia.svg +1 -0
- data/docs/code/Utopia.html +511 -0
- data/docs/code/Utopia/Basename.html +654 -0
- data/docs/code/Utopia/Bootstrap.html +538 -0
- data/docs/code/Utopia/Command.html +207 -0
- data/docs/code/Utopia/Command/Environment.html +321 -0
- data/docs/code/Utopia/Command/Server.html +214 -0
- data/docs/code/Utopia/Command/Server/Create.html +222 -0
- data/docs/code/Utopia/Command/Server/Environment.html +236 -0
- data/docs/code/Utopia/Command/Server/Update.html +317 -0
- data/docs/code/Utopia/Command/Setup.html +145 -0
- data/docs/code/Utopia/Command/Setup/Server.html +298 -0
- data/docs/code/Utopia/Command/Setup/Site.html +180 -0
- data/docs/code/Utopia/Command/Site.html +279 -0
- data/docs/code/Utopia/Command/Site/Create.html +324 -0
- data/docs/code/Utopia/Command/Site/Update.html +407 -0
- data/docs/code/Utopia/Command/Top.html +279 -0
- data/docs/code/Utopia/Content.html +826 -0
- data/docs/code/Utopia/Content/Document.html +1818 -0
- data/docs/code/Utopia/Content/Document/State.html +1220 -0
- data/docs/code/Utopia/Content/Link.html +1286 -0
- data/docs/code/Utopia/Content/Links.html +841 -0
- data/docs/code/Utopia/Content/MarkupParser.html +881 -0
- data/docs/code/Utopia/Content/MarkupParser/ParsedTag.html +422 -0
- data/docs/code/Utopia/Content/MarkupParser/UnbalancedTagError.html +615 -0
- data/docs/code/Utopia/Content/Namespace.html +485 -0
- data/docs/code/Utopia/Content/Node.html +1188 -0
- data/docs/code/Utopia/Content/Node/Context.html +938 -0
- data/docs/code/Utopia/Content/Response.html +813 -0
- data/docs/code/Utopia/Content/SymbolicHash.html +419 -0
- data/docs/code/Utopia/Content/Tag.html +399 -0
- data/docs/code/Utopia/Content/Tags.html +136 -0
- data/docs/code/Utopia/Content/Tags/ContentTag.html +187 -0
- data/docs/code/Utopia/Content/Tags/DeferredTag.html +193 -0
- data/docs/code/Utopia/Content/Tags/Library.html +333 -0
- data/docs/code/Utopia/Content/Tags/NodeTag.html +193 -0
- data/docs/code/Utopia/Content/UnbalancedTagError.html +298 -0
- data/docs/code/Utopia/ContentLength.html +339 -0
- data/docs/code/Utopia/Controller.html +901 -0
- data/docs/code/Utopia/Controller/Actions.html +289 -0
- data/docs/code/Utopia/Controller/Actions/Action.html +978 -0
- data/docs/code/Utopia/Controller/Actions/ClassMethods.html +442 -0
- data/docs/code/Utopia/Controller/Base.html +1216 -0
- data/docs/code/Utopia/Controller/Respond.html +283 -0
- data/docs/code/Utopia/Controller/Respond/ClassMethods.html +236 -0
- data/docs/code/Utopia/Controller/Respond/Converter.html +256 -0
- data/docs/code/Utopia/Controller/Respond/Converter/Callback.html +484 -0
- data/docs/code/Utopia/Controller/Respond/Converter/ToJSON.html +375 -0
- data/docs/code/Utopia/Controller/Respond/Passthrough.html +291 -0
- data/docs/code/Utopia/Controller/Respond/Responder.html +529 -0
- data/docs/code/Utopia/Controller/Rewrite.html +290 -0
- data/docs/code/Utopia/Controller/Rewrite/ClassMethods.html +242 -0
- data/docs/code/Utopia/Controller/Rewrite/ExtractPrefixRule.html +364 -0
- data/docs/code/Utopia/Controller/Rewrite/Rewriter.html +464 -0
- data/docs/code/Utopia/Controller/Rewrite/Rule.html +209 -0
- data/docs/code/Utopia/Controller/Variables.html +550 -0
- data/docs/code/Utopia/Controllers.html +244 -0
- data/docs/code/Utopia/Exceptions.html +127 -0
- data/docs/code/Utopia/Exceptions/Handler.html +526 -0
- data/docs/code/Utopia/Exceptions/Mailer.html +476 -0
- data/docs/code/Utopia/Extensions.html +117 -0
- data/docs/code/Utopia/Extensions/ArraySplit.html +183 -0
- data/docs/code/Utopia/Extensions/DateTimeComparison.html +193 -0
- data/docs/code/Utopia/Extensions/TimeDateComparison.html +193 -0
- data/docs/code/Utopia/HTTP.html +244 -0
- data/docs/code/Utopia/HTTP/Status.html +415 -0
- data/docs/code/Utopia/Locale.html +606 -0
- data/docs/code/Utopia/Localization.html +1235 -0
- data/docs/code/Utopia/Localization/Wrapper.html +459 -0
- data/docs/code/Utopia/Logger.html +205 -0
- data/docs/code/Utopia/Logger/CompactFormatter.html +335 -0
- data/docs/code/Utopia/Path.html +3304 -0
- data/docs/code/Utopia/Path/Matcher.html +518 -0
- data/docs/code/Utopia/Path/Matcher/MatchData.html +475 -0
- data/docs/code/Utopia/Redirection.html +145 -0
- data/docs/code/Utopia/Redirection/ClientRedirect.html +717 -0
- data/docs/code/Utopia/Redirection/DirectoryIndex.html +298 -0
- data/docs/code/Utopia/Redirection/Errors.html +470 -0
- data/docs/code/Utopia/Redirection/Moved.html +312 -0
- data/docs/code/Utopia/Redirection/RequestFailure.html +226 -0
- data/docs/code/Utopia/Redirection/Rewrite.html +296 -0
- data/docs/code/Utopia/Session.html +883 -0
- data/docs/code/Utopia/Session/LazyHash.html +859 -0
- data/docs/code/Utopia/Setup.html +964 -0
- data/docs/code/Utopia/Static.html +690 -0
- data/docs/code/Utopia/Static/LocalFile.html +1098 -0
- data/docs/code/Utopia/Static/MimeTypeLoader.html +541 -0
- data/docs/code/Utopia/Static/MimeTypeLoader/ExpansionError.html +124 -0
- data/docs/code/Utopia/Tags.html +115 -0
- data/docs/code/Utopia/Tags/Environment.html +314 -0
- data/docs/code/Utopia/Tags/EnvironmentTag.html +314 -0
- data/docs/code/Utopia/Tags/Library.html +340 -0
- data/docs/code/_index.html +758 -0
- data/docs/code/class_list.html +51 -0
- data/docs/code/css/common.css +1 -0
- data/docs/code/css/full_list.css +58 -0
- data/docs/code/css/style.css +499 -0
- data/docs/code/file.README.html +169 -0
- data/docs/code/file_list.html +56 -0
- data/docs/code/frames.html +17 -0
- data/docs/code/index.html +169 -0
- data/docs/code/js/app.js +248 -0
- data/docs/code/js/full_list.js +216 -0
- data/docs/code/js/jquery.js +4 -0
- data/docs/code/materials/utopia.png +0 -0
- data/docs/code/materials/utopia.svg +1 -0
- data/docs/code/method_list.html +3443 -0
- data/docs/code/top-level-namespace.html +110 -0
- data/docs/index.html +92 -0
- data/docs/wiki.html +92 -0
- data/docs/wiki/bower-integration.html +74 -0
- data/docs/wiki/bower-integration/index.html +74 -0
- data/docs/wiki/development-environment-setup.html +60 -0
- data/docs/wiki/development-environment-setup/index.html +60 -0
- data/docs/wiki/edit.html +103 -0
- data/docs/wiki/faq/what-is-xnode.html +79 -0
- data/docs/wiki/faq/what-is-xnode/index.html +79 -0
- data/docs/wiki/middleware/content.html +64 -0
- data/docs/wiki/middleware/content/index.html +64 -0
- data/docs/wiki/middleware/controller.html +104 -0
- data/docs/wiki/middleware/controller/actions.html +117 -0
- data/docs/wiki/middleware/controller/actions/index.html +117 -0
- data/docs/wiki/middleware/controller/actions/rewrite/index.html +48 -0
- data/docs/wiki/middleware/controller/index.html +104 -0
- data/docs/wiki/middleware/controller/rewrite.html +111 -0
- data/docs/wiki/middleware/controller/rewrite/index.html +111 -0
- data/docs/wiki/middleware/localization.html +59 -0
- data/docs/wiki/middleware/localization/index.html +59 -0
- data/docs/wiki/middleware/redirection.html +61 -0
- data/docs/wiki/middleware/redirection/index.html +61 -0
- data/docs/wiki/middleware/session.html +71 -0
- data/docs/wiki/middleware/session/index.html +71 -0
- data/docs/wiki/middleware/static.html +57 -0
- data/docs/wiki/middleware/static/index.html +57 -0
- data/docs/wiki/server-setup.html +118 -0
- data/docs/wiki/server-setup/index.html +118 -0
- data/docs/wiki/testing.html +59 -0
- data/docs/wiki/testing/index.html +59 -0
- data/docs/wiki/updating-utopia.html +108 -0
- data/docs/wiki/updating-utopia/index.html +108 -0
- data/docs/wiki/your-first-page.html +80 -0
- data/docs/wiki/your-first-page/index.html +80 -0
- data/documentation/Guardfile +0 -12
- data/documentation/Rakefile +3 -0
- data/documentation/pages/_page.xnode +2 -0
- data/documentation/pages/wiki/content.md +1 -0
- data/documentation/pages/wiki/faq/what-is-xnode/content.md +37 -0
- data/documentation/pages/wiki/links.yaml +3 -1
- data/documentation/pages/wiki/server-setup/content.md +1 -1
- data/documentation/pages/wiki/show.xnode +2 -0
- data/documentation/pages/wiki/your-first-page/content.md +1 -1
- data/lib/utopia/command.rb +4 -4
- data/lib/utopia/command/environment.rb +73 -0
- data/lib/utopia/command/server.rb +19 -32
- data/lib/utopia/command/site.rb +26 -9
- data/lib/utopia/content/markup.rb +1 -1
- data/lib/utopia/setup.rb +49 -20
- data/lib/utopia/version.rb +1 -1
- data/setup/site/README.md +6 -7
- data/setup/site/Rakefile +3 -0
- data/setup/site/pages/_page.xnode +1 -1
- data/setup/site/public/_static/site.css +1 -1
- data/setup/site/tasks/bower.rake +3 -6
- data/setup/site/tasks/deploy.rake +1 -1
- data/setup/site/tasks/development.rake +1 -1
- data/setup/site/tasks/environment.rake +2 -2
- data/setup/site/tasks/static.rake +43 -0
- data/spec/utopia/command_spec.rb +170 -0
- data/spec/utopia/setup_spec.rb +20 -142
- metadata +225 -42
- 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/lib/utopia/command/setup.rb +0 -78
@@ -0,0 +1,1235 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Utopia::Localization
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.12
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Utopia::Localization";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (L)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Utopia.html" title="Utopia (module)">Utopia</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Localization</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Utopia::Localization
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">Utopia::Localization</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/utopia/localization.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
<p>A middleware which attempts to find localized content.</p>
|
105
|
+
|
106
|
+
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
<div class="tags">
|
110
|
+
|
111
|
+
|
112
|
+
</div><h2>Defined Under Namespace</h2>
|
113
|
+
<p class="children">
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Localization/Wrapper.html" title="Utopia::Localization::Wrapper (class)">Wrapper</a></span>
|
119
|
+
|
120
|
+
|
121
|
+
</p>
|
122
|
+
|
123
|
+
<h2>Constant Summary</h2>
|
124
|
+
<dl class="constants">
|
125
|
+
|
126
|
+
<dt id="RESOURCE_NOT_FOUND-constant" class="">RESOURCE_NOT_FOUND =
|
127
|
+
|
128
|
+
</dt>
|
129
|
+
<dd><pre class="code"><span class='lbracket'>[</span><span class='int'>400</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
130
|
+
|
131
|
+
<dt id="HTTP_ACCEPT_LANGUAGE-constant" class="">HTTP_ACCEPT_LANGUAGE =
|
132
|
+
|
133
|
+
</dt>
|
134
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>HTTP_ACCEPT_LANGUAGE</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
135
|
+
|
136
|
+
<dt id="LOCALIZATION_KEY-constant" class="">LOCALIZATION_KEY =
|
137
|
+
|
138
|
+
</dt>
|
139
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>utopia.localization</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
140
|
+
|
141
|
+
<dt id="CURRENT_LOCALE_KEY-constant" class="">CURRENT_LOCALE_KEY =
|
142
|
+
|
143
|
+
</dt>
|
144
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>utopia.localization.current_locale</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
145
|
+
|
146
|
+
<dt id="SAFE_METHODS-constant" class="">SAFE_METHODS =
|
147
|
+
|
148
|
+
</dt>
|
149
|
+
<dd><pre class="code"><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>GET</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>HEAD</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span></pre></dd>
|
150
|
+
|
151
|
+
</dl>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
157
|
+
<ul class="summary">
|
158
|
+
|
159
|
+
<li class="public ">
|
160
|
+
<span class="summary_signature">
|
161
|
+
|
162
|
+
<a href="#all_locales-instance_method" title="#all_locales (instance method)">#<strong>all_locales</strong> ⇒ Object </a>
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
</span>
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
<span class="note title readonly">readonly</span>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute all_locales.</p>
|
182
|
+
</div></span>
|
183
|
+
|
184
|
+
</li>
|
185
|
+
|
186
|
+
|
187
|
+
<li class="public ">
|
188
|
+
<span class="summary_signature">
|
189
|
+
|
190
|
+
<a href="#default_locale-instance_method" title="#default_locale (instance method)">#<strong>default_locale</strong> ⇒ Object </a>
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
</span>
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<span class="note title readonly">readonly</span>
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute default_locale.</p>
|
210
|
+
</div></span>
|
211
|
+
|
212
|
+
</li>
|
213
|
+
|
214
|
+
|
215
|
+
</ul>
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<h2>
|
222
|
+
Class Method Summary
|
223
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
224
|
+
</h2>
|
225
|
+
|
226
|
+
<ul class="summary">
|
227
|
+
|
228
|
+
<li class="public ">
|
229
|
+
<span class="summary_signature">
|
230
|
+
|
231
|
+
<a href="#[]-class_method" title="[] (class method)">.<strong>[]</strong>(request) ⇒ Object </a>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
</span>
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
<span class="summary_desc"><div class='inline'>
|
246
|
+
</div></span>
|
247
|
+
|
248
|
+
</li>
|
249
|
+
|
250
|
+
|
251
|
+
</ul>
|
252
|
+
|
253
|
+
<h2>
|
254
|
+
Instance Method Summary
|
255
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
256
|
+
</h2>
|
257
|
+
|
258
|
+
<ul class="summary">
|
259
|
+
|
260
|
+
<li class="public ">
|
261
|
+
<span class="summary_signature">
|
262
|
+
|
263
|
+
<a href="#browser_preferred_locales-instance_method" title="#browser_preferred_locales (instance method)">#<strong>browser_preferred_locales</strong>(env) ⇒ Object </a>
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
</span>
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
<span class="summary_desc"><div class='inline'>
|
278
|
+
</div></span>
|
279
|
+
|
280
|
+
</li>
|
281
|
+
|
282
|
+
|
283
|
+
<li class="public ">
|
284
|
+
<span class="summary_signature">
|
285
|
+
|
286
|
+
<a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong>(env) ⇒ Object </a>
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
</span>
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
<span class="summary_desc"><div class='inline'>
|
301
|
+
</div></span>
|
302
|
+
|
303
|
+
</li>
|
304
|
+
|
305
|
+
|
306
|
+
<li class="public ">
|
307
|
+
<span class="summary_signature">
|
308
|
+
|
309
|
+
<a href="#freeze-instance_method" title="#freeze (instance method)">#<strong>freeze</strong> ⇒ Object </a>
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
</span>
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
<span class="summary_desc"><div class='inline'>
|
324
|
+
</div></span>
|
325
|
+
|
326
|
+
</li>
|
327
|
+
|
328
|
+
|
329
|
+
<li class="public ">
|
330
|
+
<span class="summary_signature">
|
331
|
+
|
332
|
+
<a href="#host_preferred_locales-instance_method" title="#host_preferred_locales (instance method)">#<strong>host_preferred_locales</strong>(env) ⇒ Object </a>
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
</span>
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
<span class="summary_desc"><div class='inline'>
|
347
|
+
</div></span>
|
348
|
+
|
349
|
+
</li>
|
350
|
+
|
351
|
+
|
352
|
+
<li class="public ">
|
353
|
+
<span class="summary_signature">
|
354
|
+
|
355
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(app, locales:, default_locale: nil, default_locales: nil, hosts: {}, ignore: [], **options) ⇒ Localization </a>
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
</span>
|
360
|
+
|
361
|
+
|
362
|
+
<span class="note title constructor">constructor</span>
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
<span class="summary_desc"><div class='inline'><p>A new instance of Localization.</p>
|
372
|
+
</div></span>
|
373
|
+
|
374
|
+
</li>
|
375
|
+
|
376
|
+
|
377
|
+
<li class="public ">
|
378
|
+
<span class="summary_signature">
|
379
|
+
|
380
|
+
<a href="#localized%3F-instance_method" title="#localized? (instance method)">#<strong>localized?</strong>(env) ⇒ Boolean </a>
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
</span>
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
<span class="summary_desc"><div class='inline'>
|
395
|
+
</div></span>
|
396
|
+
|
397
|
+
</li>
|
398
|
+
|
399
|
+
|
400
|
+
<li class="public ">
|
401
|
+
<span class="summary_signature">
|
402
|
+
|
403
|
+
<a href="#preferred_locales-instance_method" title="#preferred_locales (instance method)">#<strong>preferred_locales</strong>(env) ⇒ Object </a>
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
</span>
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
<span class="summary_desc"><div class='inline'>
|
418
|
+
</div></span>
|
419
|
+
|
420
|
+
</li>
|
421
|
+
|
422
|
+
|
423
|
+
<li class="public ">
|
424
|
+
<span class="summary_signature">
|
425
|
+
|
426
|
+
<a href="#request_preferred_locale-instance_method" title="#request_preferred_locale (instance method)">#<strong>request_preferred_locale</strong>(env) ⇒ Object </a>
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
</span>
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
<span class="summary_desc"><div class='inline'>
|
441
|
+
</div></span>
|
442
|
+
|
443
|
+
</li>
|
444
|
+
|
445
|
+
|
446
|
+
<li class="public ">
|
447
|
+
<span class="summary_signature">
|
448
|
+
|
449
|
+
<a href="#vary-instance_method" title="#vary (instance method)">#<strong>vary</strong>(env, response) ⇒ Object </a>
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
</span>
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
<span class="summary_desc"><div class='inline'><p>Set the Vary: header on the response to indicate that this response should include the header in the cache key.</p>
|
464
|
+
</div></span>
|
465
|
+
|
466
|
+
</li>
|
467
|
+
|
468
|
+
|
469
|
+
</ul>
|
470
|
+
|
471
|
+
|
472
|
+
<div id="constructor_details" class="method_details_list">
|
473
|
+
<h2>Constructor Details</h2>
|
474
|
+
|
475
|
+
<div class="method_details first">
|
476
|
+
<h3 class="signature first" id="initialize-instance_method">
|
477
|
+
|
478
|
+
#<strong>initialize</strong>(app, locales:, default_locale: nil, default_locales: nil, hosts: {}, ignore: [], **options) ⇒ <tt><span class='object_link'><a href="" title="Utopia::Localization (class)">Localization</a></span></tt>
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
</h3><div class="docstring">
|
485
|
+
<div class="discussion">
|
486
|
+
<p>Returns a new instance of Localization</p>
|
487
|
+
|
488
|
+
|
489
|
+
</div>
|
490
|
+
</div>
|
491
|
+
<div class="tags">
|
492
|
+
<p class="tag_title">Parameters:</p>
|
493
|
+
<ul class="param">
|
494
|
+
|
495
|
+
<li>
|
496
|
+
|
497
|
+
<span class='name'>locales</span>
|
498
|
+
|
499
|
+
|
500
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
—
|
505
|
+
<div class='inline'><p>An array of all supported locales.</p>
|
506
|
+
</div>
|
507
|
+
|
508
|
+
</li>
|
509
|
+
|
510
|
+
<li>
|
511
|
+
|
512
|
+
<span class='name'>default_locale</span>
|
513
|
+
|
514
|
+
|
515
|
+
<span class='type'>(<tt>String</tt>)</span>
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
—
|
520
|
+
<div class='inline'><p>The default locale if none is provided.</p>
|
521
|
+
</div>
|
522
|
+
|
523
|
+
</li>
|
524
|
+
|
525
|
+
<li>
|
526
|
+
|
527
|
+
<span class='name'>default_locales</span>
|
528
|
+
|
529
|
+
|
530
|
+
<span class='type'>(<tt>String</tt>)</span>
|
531
|
+
|
532
|
+
|
533
|
+
|
534
|
+
—
|
535
|
+
<div class='inline'><p>The locales to try in order if none is provided.</p>
|
536
|
+
</div>
|
537
|
+
|
538
|
+
</li>
|
539
|
+
|
540
|
+
<li>
|
541
|
+
|
542
|
+
<span class='name'>hosts</span>
|
543
|
+
|
544
|
+
|
545
|
+
<span class='type'>(<tt>Hash<Pattern, String></tt>)</span>
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
—
|
550
|
+
<div class='inline'><p>Specify a mapping of the HTTP_HOST header to a given locale.</p>
|
551
|
+
</div>
|
552
|
+
|
553
|
+
</li>
|
554
|
+
|
555
|
+
<li>
|
556
|
+
|
557
|
+
<span class='name'>ignore</span>
|
558
|
+
|
559
|
+
|
560
|
+
<span class='type'>(<tt>Array<Pattern></tt>)</span>
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
—
|
565
|
+
<div class='inline'><p>A list of patterns matched against PATH_INFO which will not be localized.</p>
|
566
|
+
</div>
|
567
|
+
|
568
|
+
</li>
|
569
|
+
|
570
|
+
</ul>
|
571
|
+
|
572
|
+
|
573
|
+
</div><table class="source_code">
|
574
|
+
<tr>
|
575
|
+
<td>
|
576
|
+
<pre class="lines">
|
577
|
+
|
578
|
+
|
579
|
+
67
|
580
|
+
68
|
581
|
+
69
|
582
|
+
70
|
583
|
+
71
|
584
|
+
72
|
585
|
+
73
|
586
|
+
74
|
587
|
+
75
|
588
|
+
76
|
589
|
+
77
|
590
|
+
78
|
591
|
+
79
|
592
|
+
80
|
593
|
+
81
|
594
|
+
82
|
595
|
+
83
|
596
|
+
84
|
597
|
+
85
|
598
|
+
86
|
599
|
+
87
|
600
|
+
88</pre>
|
601
|
+
</td>
|
602
|
+
<td>
|
603
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 67</span>
|
604
|
+
|
605
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_app'>app</span><span class='comma'>,</span> <span class='label'>locales:</span><span class='comma'>,</span> <span class='label'>default_locale:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>default_locales:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>hosts:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>ignore:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
606
|
+
<span class='ivar'>@app</span> <span class='op'>=</span> <span class='id identifier rubyid_app'>app</span>
|
607
|
+
|
608
|
+
<span class='ivar'>@all_locales</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="HTTP.html" title="Utopia::HTTP (module)">HTTP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="HTTP.html#Accept-constant" title="Utopia::HTTP::Accept (constant)">Accept</a></span></span><span class='op'>::</span><span class='const'>Languages</span><span class='op'>::</span><span class='const'>Locales</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
|
609
|
+
|
610
|
+
<span class='comment'># Locales here are represented as an array of strings, e.g. ['en', 'ja', 'cn', 'de'] and are used in order if no locale is specified by the user.
|
611
|
+
</span> <span class='kw'>unless</span> <span class='ivar'>@default_locales</span> <span class='op'>=</span> <span class='id identifier rubyid_default_locales'>default_locales</span>
|
612
|
+
<span class='comment'># We append nil, i.e. no localization.
|
613
|
+
</span> <span class='ivar'>@default_locales</span> <span class='op'>=</span> <span class='ivar'>@all_locales</span><span class='period'>.</span><span class='id identifier rubyid_names'>names</span> <span class='op'>+</span> <span class='lbracket'>[</span><span class='kw'>nil</span><span class='rbracket'>]</span>
|
614
|
+
<span class='kw'>end</span>
|
615
|
+
|
616
|
+
<span class='ivar'>@default_locale</span> <span class='op'>=</span> <span class='id identifier rubyid_default_locale'>default_locale</span> <span class='op'>||</span> <span class='ivar'>@default_locales</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
617
|
+
|
618
|
+
<span class='kw'>unless</span> <span class='ivar'>@default_locales</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='ivar'>@default_locale</span>
|
619
|
+
<span class='ivar'>@default_locales</span><span class='period'>.</span><span class='id identifier rubyid_unshift'>unshift</span><span class='lparen'>(</span><span class='ivar'>@default_locale</span><span class='rparen'>)</span>
|
620
|
+
<span class='kw'>end</span>
|
621
|
+
|
622
|
+
<span class='comment'># Select a localization based on a request host name:
|
623
|
+
</span> <span class='ivar'>@hosts</span> <span class='op'>=</span> <span class='id identifier rubyid_hosts'>hosts</span>
|
624
|
+
|
625
|
+
<span class='ivar'>@ignore</span> <span class='op'>=</span> <span class='id identifier rubyid_ignore'>ignore</span> <span class='op'>||</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:nonlocalized</span><span class='rbracket'>]</span>
|
626
|
+
<span class='kw'>end</span></pre>
|
627
|
+
</td>
|
628
|
+
</tr>
|
629
|
+
</table>
|
630
|
+
</div>
|
631
|
+
|
632
|
+
</div>
|
633
|
+
|
634
|
+
<div id="instance_attr_details" class="attr_details">
|
635
|
+
<h2>Instance Attribute Details</h2>
|
636
|
+
|
637
|
+
|
638
|
+
<span id=""></span>
|
639
|
+
<div class="method_details first">
|
640
|
+
<h3 class="signature first" id="all_locales-instance_method">
|
641
|
+
|
642
|
+
#<strong>all_locales</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
643
|
+
|
644
|
+
|
645
|
+
|
646
|
+
|
647
|
+
|
648
|
+
</h3><div class="docstring">
|
649
|
+
<div class="discussion">
|
650
|
+
<p>Returns the value of attribute all_locales</p>
|
651
|
+
|
652
|
+
|
653
|
+
</div>
|
654
|
+
</div>
|
655
|
+
<div class="tags">
|
656
|
+
|
657
|
+
|
658
|
+
</div><table class="source_code">
|
659
|
+
<tr>
|
660
|
+
<td>
|
661
|
+
<pre class="lines">
|
662
|
+
|
663
|
+
|
664
|
+
102
|
665
|
+
103
|
666
|
+
104</pre>
|
667
|
+
</td>
|
668
|
+
<td>
|
669
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 102</span>
|
670
|
+
|
671
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_all_locales'>all_locales</span>
|
672
|
+
<span class='ivar'>@all_locales</span>
|
673
|
+
<span class='kw'>end</span></pre>
|
674
|
+
</td>
|
675
|
+
</tr>
|
676
|
+
</table>
|
677
|
+
</div>
|
678
|
+
|
679
|
+
|
680
|
+
<span id=""></span>
|
681
|
+
<div class="method_details ">
|
682
|
+
<h3 class="signature " id="default_locale-instance_method">
|
683
|
+
|
684
|
+
#<strong>default_locale</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
|
690
|
+
</h3><div class="docstring">
|
691
|
+
<div class="discussion">
|
692
|
+
<p>Returns the value of attribute default_locale</p>
|
693
|
+
|
694
|
+
|
695
|
+
</div>
|
696
|
+
</div>
|
697
|
+
<div class="tags">
|
698
|
+
|
699
|
+
|
700
|
+
</div><table class="source_code">
|
701
|
+
<tr>
|
702
|
+
<td>
|
703
|
+
<pre class="lines">
|
704
|
+
|
705
|
+
|
706
|
+
103
|
707
|
+
104
|
708
|
+
105</pre>
|
709
|
+
</td>
|
710
|
+
<td>
|
711
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 103</span>
|
712
|
+
|
713
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_default_locale'>default_locale</span>
|
714
|
+
<span class='ivar'>@default_locale</span>
|
715
|
+
<span class='kw'>end</span></pre>
|
716
|
+
</td>
|
717
|
+
</tr>
|
718
|
+
</table>
|
719
|
+
</div>
|
720
|
+
|
721
|
+
</div>
|
722
|
+
|
723
|
+
|
724
|
+
<div id="class_method_details" class="method_details_list">
|
725
|
+
<h2>Class Method Details</h2>
|
726
|
+
|
727
|
+
|
728
|
+
<div class="method_details first">
|
729
|
+
<h3 class="signature first" id="[]-class_method">
|
730
|
+
|
731
|
+
.<strong>[]</strong>(request) ⇒ <tt>Object</tt>
|
732
|
+
|
733
|
+
|
734
|
+
|
735
|
+
|
736
|
+
|
737
|
+
</h3><table class="source_code">
|
738
|
+
<tr>
|
739
|
+
<td>
|
740
|
+
<pre class="lines">
|
741
|
+
|
742
|
+
|
743
|
+
52
|
744
|
+
53
|
745
|
+
54</pre>
|
746
|
+
</td>
|
747
|
+
<td>
|
748
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 52</span>
|
749
|
+
|
750
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='op'>[]</span> <span class='id identifier rubyid_request'>request</span>
|
751
|
+
<span class='const'><span class='object_link'><a href="Localization/Wrapper.html" title="Utopia::Localization::Wrapper (class)">Wrapper</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Localization/Wrapper.html#initialize-instance_method" title="Utopia::Localization::Wrapper#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
752
|
+
<span class='kw'>end</span></pre>
|
753
|
+
</td>
|
754
|
+
</tr>
|
755
|
+
</table>
|
756
|
+
</div>
|
757
|
+
|
758
|
+
</div>
|
759
|
+
|
760
|
+
<div id="instance_method_details" class="method_details_list">
|
761
|
+
<h2>Instance Method Details</h2>
|
762
|
+
|
763
|
+
|
764
|
+
<div class="method_details first">
|
765
|
+
<h3 class="signature first" id="browser_preferred_locales-instance_method">
|
766
|
+
|
767
|
+
#<strong>browser_preferred_locales</strong>(env) ⇒ <tt>Object</tt>
|
768
|
+
|
769
|
+
|
770
|
+
|
771
|
+
|
772
|
+
|
773
|
+
</h3><table class="source_code">
|
774
|
+
<tr>
|
775
|
+
<td>
|
776
|
+
<pre class="lines">
|
777
|
+
|
778
|
+
|
779
|
+
151
|
780
|
+
152
|
781
|
+
153
|
782
|
+
154
|
783
|
+
155
|
784
|
+
156
|
785
|
+
157
|
786
|
+
158
|
787
|
+
159
|
788
|
+
160
|
789
|
+
161
|
790
|
+
162
|
791
|
+
163
|
792
|
+
164
|
793
|
+
165</pre>
|
794
|
+
</td>
|
795
|
+
<td>
|
796
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 151</span>
|
797
|
+
|
798
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_browser_preferred_locales'>browser_preferred_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
799
|
+
<span class='id identifier rubyid_accept_languages'>accept_languages</span> <span class='op'>=</span> <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="#HTTP_ACCEPT_LANGUAGE-constant" title="Utopia::Localization::HTTP_ACCEPT_LANGUAGE (constant)">HTTP_ACCEPT_LANGUAGE</a></span></span><span class='rbracket'>]</span>
|
800
|
+
|
801
|
+
<span class='comment'># No user prefered languages:
|
802
|
+
</span> <span class='kw'>return</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_accept_languages'>accept_languages</span>
|
803
|
+
|
804
|
+
<span class='comment'># Extract the ordered list of languages:
|
805
|
+
</span> <span class='id identifier rubyid_languages'>languages</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="HTTP.html" title="Utopia::HTTP (module)">HTTP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="HTTP.html#Accept-constant" title="Utopia::HTTP::Accept (constant)">Accept</a></span></span><span class='op'>::</span><span class='const'>Languages</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_accept_languages'>accept_languages</span><span class='rparen'>)</span>
|
806
|
+
|
807
|
+
<span class='comment'># Returns available languages based on the order languages:
|
808
|
+
</span> <span class='kw'>return</span> <span class='ivar'>@all_locales</span> <span class='op'>&</span> <span class='id identifier rubyid_languages'>languages</span>
|
809
|
+
<span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="HTTP.html" title="Utopia::HTTP (module)">HTTP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="HTTP.html#Accept-constant" title="Utopia::HTTP::Accept (constant)">Accept</a></span></span><span class='op'>::</span><span class='const'>ParseError</span>
|
810
|
+
<span class='comment'># If we fail to parse the browser Accept-Language header, we ignore it (silently).
|
811
|
+
</span> <span class='kw'>return</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
812
|
+
<span class='kw'>end</span></pre>
|
813
|
+
</td>
|
814
|
+
</tr>
|
815
|
+
</table>
|
816
|
+
</div>
|
817
|
+
|
818
|
+
<div class="method_details ">
|
819
|
+
<h3 class="signature " id="call-instance_method">
|
820
|
+
|
821
|
+
#<strong>call</strong>(env) ⇒ <tt>Object</tt>
|
822
|
+
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
|
827
|
+
</h3><table class="source_code">
|
828
|
+
<tr>
|
829
|
+
<td>
|
830
|
+
<pre class="lines">
|
831
|
+
|
832
|
+
|
833
|
+
201
|
834
|
+
202
|
835
|
+
203
|
836
|
+
204
|
837
|
+
205
|
838
|
+
206
|
839
|
+
207
|
840
|
+
208
|
841
|
+
209
|
842
|
+
210
|
843
|
+
211
|
844
|
+
212
|
845
|
+
213
|
846
|
+
214
|
847
|
+
215
|
848
|
+
216
|
849
|
+
217
|
850
|
+
218
|
851
|
+
219</pre>
|
852
|
+
</td>
|
853
|
+
<td>
|
854
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 201</span>
|
855
|
+
|
856
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
857
|
+
<span class='comment'># Pass the request through if it shouldn't be localized:
|
858
|
+
</span> <span class='kw'>return</span> <span class='ivar'>@app</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_localized?'>localized?</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
859
|
+
|
860
|
+
<span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="#LOCALIZATION_KEY-constant" title="Utopia::Localization::LOCALIZATION_KEY (constant)">LOCALIZATION_KEY</a></span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span>
|
861
|
+
|
862
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
863
|
+
|
864
|
+
<span class='comment'># We have a non-localized request, but there might be a localized resource. We return the best localization possible:
|
865
|
+
</span> <span class='id identifier rubyid_preferred_locales'>preferred_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_localized_env'>localized_env</span><span class='op'>|</span>
|
866
|
+
<span class='comment'># puts "Trying locale: #{env[CURRENT_LOCALE_KEY]}: #{env[Rack::PATH_INFO]}..."
|
867
|
+
</span>
|
868
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='ivar'>@app</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_localized_env'>localized_env</span><span class='rparen'>)</span>
|
869
|
+
|
870
|
+
<span class='kw'>break</span> <span class='kw'>unless</span> <span class='id identifier rubyid_response'>response</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>>=</span> <span class='int'>400</span>
|
871
|
+
<span class='kw'>end</span>
|
872
|
+
|
873
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_vary'>vary</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='comma'>,</span> <span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
|
874
|
+
<span class='kw'>end</span></pre>
|
875
|
+
</td>
|
876
|
+
</tr>
|
877
|
+
</table>
|
878
|
+
</div>
|
879
|
+
|
880
|
+
<div class="method_details ">
|
881
|
+
<h3 class="signature " id="freeze-instance_method">
|
882
|
+
|
883
|
+
#<strong>freeze</strong> ⇒ <tt>Object</tt>
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
|
888
|
+
|
889
|
+
</h3><table class="source_code">
|
890
|
+
<tr>
|
891
|
+
<td>
|
892
|
+
<pre class="lines">
|
893
|
+
|
894
|
+
|
895
|
+
90
|
896
|
+
91
|
897
|
+
92
|
898
|
+
93
|
899
|
+
94
|
900
|
+
95
|
901
|
+
96
|
902
|
+
97
|
903
|
+
98
|
904
|
+
99
|
905
|
+
100</pre>
|
906
|
+
</td>
|
907
|
+
<td>
|
908
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 90</span>
|
909
|
+
|
910
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_freeze'>freeze</span>
|
911
|
+
<span class='kw'>return</span> <span class='kw'>self</span> <span class='kw'>if</span> <span class='id identifier rubyid_frozen?'>frozen?</span>
|
912
|
+
|
913
|
+
<span class='ivar'>@all_locales</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
914
|
+
<span class='ivar'>@default_locales</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
915
|
+
<span class='ivar'>@default_locale</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
916
|
+
<span class='ivar'>@hosts</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
917
|
+
<span class='ivar'>@ignore</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
918
|
+
|
919
|
+
<span class='kw'>super</span>
|
920
|
+
<span class='kw'>end</span></pre>
|
921
|
+
</td>
|
922
|
+
</tr>
|
923
|
+
</table>
|
924
|
+
</div>
|
925
|
+
|
926
|
+
<div class="method_details ">
|
927
|
+
<h3 class="signature " id="host_preferred_locales-instance_method">
|
928
|
+
|
929
|
+
#<strong>host_preferred_locales</strong>(env) ⇒ <tt>Object</tt>
|
930
|
+
|
931
|
+
|
932
|
+
|
933
|
+
|
934
|
+
|
935
|
+
</h3><table class="source_code">
|
936
|
+
<tr>
|
937
|
+
<td>
|
938
|
+
<pre class="lines">
|
939
|
+
|
940
|
+
|
941
|
+
131
|
942
|
+
132
|
943
|
+
133
|
944
|
+
134
|
945
|
+
135
|
946
|
+
136
|
947
|
+
137
|
948
|
+
138</pre>
|
949
|
+
</td>
|
950
|
+
<td>
|
951
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 131</span>
|
952
|
+
|
953
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_host_preferred_locales'>host_preferred_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
954
|
+
<span class='id identifier rubyid_http_host'>http_host</span> <span class='op'>=</span> <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='const'>Rack</span><span class='op'>::</span><span class='const'>HTTP_HOST</span><span class='rbracket'>]</span>
|
955
|
+
|
956
|
+
<span class='comment'># Yield all hosts which match the incoming http_host:
|
957
|
+
</span> <span class='ivar'>@hosts</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_pattern'>pattern</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='op'>|</span>
|
958
|
+
<span class='kw'>yield</span> <span class='id identifier rubyid_locale'>locale</span> <span class='kw'>if</span> <span class='id identifier rubyid_http_host'>http_host</span><span class='lbracket'>[</span><span class='id identifier rubyid_pattern'>pattern</span><span class='rbracket'>]</span>
|
959
|
+
<span class='kw'>end</span>
|
960
|
+
<span class='kw'>end</span></pre>
|
961
|
+
</td>
|
962
|
+
</tr>
|
963
|
+
</table>
|
964
|
+
</div>
|
965
|
+
|
966
|
+
<div class="method_details ">
|
967
|
+
<h3 class="signature " id="localized?-instance_method">
|
968
|
+
|
969
|
+
#<strong>localized?</strong>(env) ⇒ <tt>Boolean</tt>
|
970
|
+
|
971
|
+
|
972
|
+
|
973
|
+
|
974
|
+
|
975
|
+
</h3><div class="docstring">
|
976
|
+
<div class="discussion">
|
977
|
+
|
978
|
+
|
979
|
+
|
980
|
+
</div>
|
981
|
+
</div>
|
982
|
+
<div class="tags">
|
983
|
+
|
984
|
+
<p class="tag_title">Returns:</p>
|
985
|
+
<ul class="return">
|
986
|
+
|
987
|
+
<li>
|
988
|
+
|
989
|
+
|
990
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
991
|
+
|
992
|
+
|
993
|
+
|
994
|
+
</li>
|
995
|
+
|
996
|
+
</ul>
|
997
|
+
|
998
|
+
</div><table class="source_code">
|
999
|
+
<tr>
|
1000
|
+
<td>
|
1001
|
+
<pre class="lines">
|
1002
|
+
|
1003
|
+
|
1004
|
+
169
|
1005
|
+
170
|
1006
|
+
171
|
1007
|
+
172
|
1008
|
+
173
|
1009
|
+
174
|
1010
|
+
175
|
1011
|
+
176
|
1012
|
+
177
|
1013
|
+
178
|
1014
|
+
179</pre>
|
1015
|
+
</td>
|
1016
|
+
<td>
|
1017
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 169</span>
|
1018
|
+
|
1019
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_localized?'>localized?</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
1020
|
+
<span class='comment'># Only SAFE_METHODS can be localized:
|
1021
|
+
</span> <span class='id identifier rubyid_request_method'>request_method</span> <span class='op'>=</span> <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='const'>Rack</span><span class='op'>::</span><span class='const'>REQUEST_METHOD</span><span class='rbracket'>]</span>
|
1022
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='const'><span class='object_link'><a href="#SAFE_METHODS-constant" title="Utopia::Localization::SAFE_METHODS (constant)">SAFE_METHODS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_request_method'>request_method</span><span class='rparen'>)</span>
|
1023
|
+
|
1024
|
+
<span class='comment'># Ignore requests which match the ignored paths:
|
1025
|
+
</span> <span class='id identifier rubyid_path_info'>path_info</span> <span class='op'>=</span> <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='const'>Rack</span><span class='op'>::</span><span class='const'>PATH_INFO</span><span class='rbracket'>]</span>
|
1026
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='ivar'>@ignore</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_pattern'>pattern</span><span class='op'>|</span> <span class='id identifier rubyid_path_info'>path_info</span><span class='lbracket'>[</span><span class='id identifier rubyid_pattern'>pattern</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='kw'>nil</span> <span class='rbrace'>}</span>
|
1027
|
+
|
1028
|
+
<span class='kw'>return</span> <span class='kw'>true</span>
|
1029
|
+
<span class='kw'>end</span></pre>
|
1030
|
+
</td>
|
1031
|
+
</tr>
|
1032
|
+
</table>
|
1033
|
+
</div>
|
1034
|
+
|
1035
|
+
<div class="method_details ">
|
1036
|
+
<h3 class="signature " id="preferred_locales-instance_method">
|
1037
|
+
|
1038
|
+
#<strong>preferred_locales</strong>(env) ⇒ <tt>Object</tt>
|
1039
|
+
|
1040
|
+
|
1041
|
+
|
1042
|
+
|
1043
|
+
|
1044
|
+
</h3><table class="source_code">
|
1045
|
+
<tr>
|
1046
|
+
<td>
|
1047
|
+
<pre class="lines">
|
1048
|
+
|
1049
|
+
|
1050
|
+
105
|
1051
|
+
106
|
1052
|
+
107
|
1053
|
+
108
|
1054
|
+
109
|
1055
|
+
110
|
1056
|
+
111
|
1057
|
+
112
|
1058
|
+
113
|
1059
|
+
114
|
1060
|
+
115
|
1061
|
+
116
|
1062
|
+
117
|
1063
|
+
118
|
1064
|
+
119
|
1065
|
+
120
|
1066
|
+
121
|
1067
|
+
122
|
1068
|
+
123
|
1069
|
+
124
|
1070
|
+
125
|
1071
|
+
126
|
1072
|
+
127
|
1073
|
+
128
|
1074
|
+
129</pre>
|
1075
|
+
</td>
|
1076
|
+
<td>
|
1077
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 105</span>
|
1078
|
+
|
1079
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_preferred_locales'>preferred_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
1080
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_to_enum'>to_enum</span><span class='lparen'>(</span><span class='symbol'>:preferred_locales</span><span class='comma'>,</span> <span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
1081
|
+
|
1082
|
+
<span class='comment'># Keep track of what locales have been tried:
|
1083
|
+
</span> <span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='const'>Set</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
1084
|
+
|
1085
|
+
<span class='id identifier rubyid_host_preferred_locales'>host_preferred_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_locale'>locale</span><span class='op'>|</span>
|
1086
|
+
<span class='kw'>yield</span> <span class='id identifier rubyid_env'>env</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="#CURRENT_LOCALE_KEY-constant" title="Utopia::Localization::CURRENT_LOCALE_KEY (constant)">CURRENT_LOCALE_KEY</a></span></span> <span class='op'>=></span> <span class='id identifier rubyid_locale'>locale</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_add?'>add?</span> <span class='id identifier rubyid_locale'>locale</span>
|
1087
|
+
<span class='kw'>end</span>
|
1088
|
+
|
1089
|
+
<span class='id identifier rubyid_request_preferred_locale'>request_preferred_locale</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='op'>|</span>
|
1090
|
+
<span class='comment'># We have extracted a locale from the path, so from this point on we should use the updated path:
|
1091
|
+
</span> <span class='id identifier rubyid_env'>env</span> <span class='op'>=</span> <span class='id identifier rubyid_env'>env</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='const'>Rack</span><span class='op'>::</span><span class='const'>PATH_INFO</span> <span class='op'>=></span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
|
1092
|
+
|
1093
|
+
<span class='kw'>yield</span> <span class='id identifier rubyid_env'>env</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="#CURRENT_LOCALE_KEY-constant" title="Utopia::Localization::CURRENT_LOCALE_KEY (constant)">CURRENT_LOCALE_KEY</a></span></span> <span class='op'>=></span> <span class='id identifier rubyid_locale'>locale</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_add?'>add?</span> <span class='id identifier rubyid_locale'>locale</span>
|
1094
|
+
<span class='kw'>end</span>
|
1095
|
+
|
1096
|
+
<span class='id identifier rubyid_browser_preferred_locales'>browser_preferred_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_locale'>locale</span><span class='op'>|</span>
|
1097
|
+
<span class='kw'>yield</span> <span class='id identifier rubyid_env'>env</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="#CURRENT_LOCALE_KEY-constant" title="Utopia::Localization::CURRENT_LOCALE_KEY (constant)">CURRENT_LOCALE_KEY</a></span></span> <span class='op'>=></span> <span class='id identifier rubyid_locale'>locale</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_add?'>add?</span> <span class='id identifier rubyid_locale'>locale</span>
|
1098
|
+
<span class='kw'>end</span>
|
1099
|
+
|
1100
|
+
<span class='ivar'>@default_locales</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_locale'>locale</span><span class='op'>|</span>
|
1101
|
+
<span class='kw'>yield</span> <span class='id identifier rubyid_env'>env</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="#CURRENT_LOCALE_KEY-constant" title="Utopia::Localization::CURRENT_LOCALE_KEY (constant)">CURRENT_LOCALE_KEY</a></span></span> <span class='op'>=></span> <span class='id identifier rubyid_locale'>locale</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_add?'>add?</span> <span class='id identifier rubyid_locale'>locale</span>
|
1102
|
+
<span class='kw'>end</span>
|
1103
|
+
<span class='kw'>end</span></pre>
|
1104
|
+
</td>
|
1105
|
+
</tr>
|
1106
|
+
</table>
|
1107
|
+
</div>
|
1108
|
+
|
1109
|
+
<div class="method_details ">
|
1110
|
+
<h3 class="signature " id="request_preferred_locale-instance_method">
|
1111
|
+
|
1112
|
+
#<strong>request_preferred_locale</strong>(env) ⇒ <tt>Object</tt>
|
1113
|
+
|
1114
|
+
|
1115
|
+
|
1116
|
+
|
1117
|
+
|
1118
|
+
</h3><table class="source_code">
|
1119
|
+
<tr>
|
1120
|
+
<td>
|
1121
|
+
<pre class="lines">
|
1122
|
+
|
1123
|
+
|
1124
|
+
140
|
1125
|
+
141
|
1126
|
+
142
|
1127
|
+
143
|
1128
|
+
144
|
1129
|
+
145
|
1130
|
+
146
|
1131
|
+
147
|
1132
|
+
148
|
1133
|
+
149</pre>
|
1134
|
+
</td>
|
1135
|
+
<td>
|
1136
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 140</span>
|
1137
|
+
|
1138
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_request_preferred_locale'>request_preferred_locale</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
1139
|
+
<span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Path.html" title="Utopia::Path (class)">Path</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='const'>Rack</span><span class='op'>::</span><span class='const'>PATH_INFO</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
|
1140
|
+
|
1141
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_request_locale'>request_locale</span> <span class='op'>=</span> <span class='ivar'>@all_locales</span><span class='period'>.</span><span class='id identifier rubyid_patterns'>patterns</span><span class='lbracket'>[</span><span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rbracket'>]</span>
|
1142
|
+
<span class='comment'># Remove the localization prefix:
|
1143
|
+
</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_delete_at'>delete_at</span><span class='lparen'>(</span><span class='int'>0</span><span class='rparen'>)</span>
|
1144
|
+
|
1145
|
+
<span class='kw'>yield</span> <span class='id identifier rubyid_request_locale'>request_locale</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span>
|
1146
|
+
<span class='kw'>end</span>
|
1147
|
+
<span class='kw'>end</span></pre>
|
1148
|
+
</td>
|
1149
|
+
</tr>
|
1150
|
+
</table>
|
1151
|
+
</div>
|
1152
|
+
|
1153
|
+
<div class="method_details ">
|
1154
|
+
<h3 class="signature " id="vary-instance_method">
|
1155
|
+
|
1156
|
+
#<strong>vary</strong>(env, response) ⇒ <tt>Object</tt>
|
1157
|
+
|
1158
|
+
|
1159
|
+
|
1160
|
+
|
1161
|
+
|
1162
|
+
</h3><div class="docstring">
|
1163
|
+
<div class="discussion">
|
1164
|
+
<p>Set the Vary: header on the response to indicate that this response should include the header in the cache key.</p>
|
1165
|
+
|
1166
|
+
|
1167
|
+
</div>
|
1168
|
+
</div>
|
1169
|
+
<div class="tags">
|
1170
|
+
|
1171
|
+
|
1172
|
+
</div><table class="source_code">
|
1173
|
+
<tr>
|
1174
|
+
<td>
|
1175
|
+
<pre class="lines">
|
1176
|
+
|
1177
|
+
|
1178
|
+
182
|
1179
|
+
183
|
1180
|
+
184
|
1181
|
+
185
|
1182
|
+
186
|
1183
|
+
187
|
1184
|
+
188
|
1185
|
+
189
|
1186
|
+
190
|
1187
|
+
191
|
1188
|
+
192
|
1189
|
+
193
|
1190
|
+
194
|
1191
|
+
195
|
1192
|
+
196
|
1193
|
+
197
|
1194
|
+
198
|
1195
|
+
199</pre>
|
1196
|
+
</td>
|
1197
|
+
<td>
|
1198
|
+
<pre class="code"><span class="info file"># File 'lib/utopia/localization.rb', line 182</span>
|
1199
|
+
|
1200
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_vary'>vary</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='comma'>,</span> <span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
|
1201
|
+
<span class='id identifier rubyid_headers'>headers</span> <span class='op'>=</span> <span class='id identifier rubyid_response'>response</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
1202
|
+
|
1203
|
+
<span class='comment'># This response was based on the Accept-Language header:
|
1204
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Vary</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
1205
|
+
<span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Vary</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,Accept-Language</span><span class='tstring_end'>'</span></span>
|
1206
|
+
<span class='kw'>else</span>
|
1207
|
+
<span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Vary</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Accept-Language</span><span class='tstring_end'>'</span></span>
|
1208
|
+
<span class='kw'>end</span>
|
1209
|
+
|
1210
|
+
<span class='comment'># Althought this header is generally not supported, we supply it anyway as it is useful for debugging:
|
1211
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="#CURRENT_LOCALE_KEY-constant" title="Utopia::Localization::CURRENT_LOCALE_KEY (constant)">CURRENT_LOCALE_KEY</a></span></span><span class='rbracket'>]</span>
|
1212
|
+
<span class='comment'># Set the Content-Location to point to the localized URI as requested:
|
1213
|
+
</span> <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Content-Location</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_locale'>locale</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='const'>Rack</span><span class='op'>::</span><span class='const'>PATH_INFO</span><span class='rbracket'>]</span>
|
1214
|
+
<span class='kw'>end</span>
|
1215
|
+
|
1216
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_response'>response</span>
|
1217
|
+
<span class='kw'>end</span></pre>
|
1218
|
+
</td>
|
1219
|
+
</tr>
|
1220
|
+
</table>
|
1221
|
+
</div>
|
1222
|
+
|
1223
|
+
</div>
|
1224
|
+
|
1225
|
+
</div>
|
1226
|
+
|
1227
|
+
<div id="footer">
|
1228
|
+
Generated on Sat Mar 24 21:17:20 2018 by
|
1229
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1230
|
+
0.9.12 (ruby-2.5.0).
|
1231
|
+
</div>
|
1232
|
+
|
1233
|
+
</div>
|
1234
|
+
</body>
|
1235
|
+
</html>
|