| author | Tomas Zeman <tzeman@volny.cz> |
| Fri, 10 Feb 2012 09:53:07 +0100 | |
| changeset 11 | 43fa65f5072e |
| parent 5 | 993582ca8d2e |
| child 22 | 94ed9cfdb123 |
| permissions | -rw-r--r-- |
|
5
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
1 |
/* |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
2 |
* Copyright 2011 Tomas Zeman <tzeman@volny.cz> |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
3 |
* |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
5 |
* you may not use this file except in compliance with the License. |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
6 |
* You may obtain a copy of the License at |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
7 |
* |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
9 |
* |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
13 |
* See the License for the specific language governing permissions and |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
14 |
* limitations under the License. |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
15 |
*/ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
16 |
package net.tz.lift.boot |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
17 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
18 |
import net.liftweb.common._ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
19 |
import net.liftweb.http._ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
20 |
import net.liftweb.mapper._ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
21 |
import net.liftweb.sitemap._ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
22 |
import net.liftweb.sitemap.Loc._ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
23 |
import net.liftweb.util._ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
24 |
import net.liftweb.widgets.menu.MenuWidget |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
25 |
import net.tz.lift.snippet.ActionLinks |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
26 |
import net.tz.lift.util.YmdDateTimeConverter |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
27 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
28 |
/** |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
29 |
* Prototype boot class to be either extended or copied. |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
30 |
*/ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
31 |
class ProtoBoot extends Logger {
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
32 |
|
|
11
43fa65f5072e
8f749d3777e669ff Web UI skeleton
Tomas Zeman <tzeman@volny.cz>
parents:
5
diff
changeset
|
33 |
def boot: Unit = {
|
|
5
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
34 |
/* DB stuff */ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
35 |
/* |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
36 |
S.addAround(DB.buildLoanWrapper()) |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
37 |
*/ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
38 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
39 |
if (Props.mode == Props.RunModes.Development) |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
40 |
DB.addLogFunc { (dbLog, l) => dbLog.statementEntries.foreach { e =>
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
41 |
debug("Query: " + e.statement)
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
42 |
}} |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
43 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
44 |
/* Date format */ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
45 |
LiftRules.dateTimeConverter.default.set { () => YmdDateTimeConverter }
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
46 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
47 |
/* Handle end slash and drop it (except for home page) */ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
48 |
LiftRules.statelessRewrite.append {
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
49 |
case RewriteRequest(ParsePath(xs,_,_,true),_,_) if (xs.size > 1) && |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
50 |
(xs.lastOption == Some("index")) =>
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
51 |
RewriteResponse(xs dropRight 1) |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
52 |
} |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
53 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
54 |
/* Snippet dispatch */ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
55 |
LiftRules.snippetDispatch.append {
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
56 |
case "Menubar" => new AnyRef with DispatchSnippet {
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
57 |
def dispatch: DispatchIt = {
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
58 |
case _ => { xhtml => MenuWidget() }
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
59 |
} |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
60 |
} |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
61 |
case "action-links" => ActionLinks |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
62 |
} |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
63 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
64 |
/* Sitemap */ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
65 |
SiteMap.enforceUniqueLinks = false |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
66 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
67 |
/* |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
68 |
LiftRules.setSiteMap(SiteMap( |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
69 |
Menu.i("Home") / "index" >> Hidden
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
70 |
)) |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
71 |
*/ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
72 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
73 |
/* Menu widget */ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
74 |
MenuWidget.init() |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
75 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
76 |
/* Http conf */ |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
77 |
LiftRules.logServiceRequestTiming = false |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
78 |
LiftRules.early.append(_.setCharacterEncoding("UTF-8"))
|
|
11
43fa65f5072e
8f749d3777e669ff Web UI skeleton
Tomas Zeman <tzeman@volny.cz>
parents:
5
diff
changeset
|
79 |
|
|
43fa65f5072e
8f749d3777e669ff Web UI skeleton
Tomas Zeman <tzeman@volny.cz>
parents:
5
diff
changeset
|
80 |
() |
|
5
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
81 |
} |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
82 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
83 |
} |
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
84 |
|
|
993582ca8d2e
Import of tz-lift-misc@14a648a3676f
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
85 |
// vim: set ts=2 sw=2 et: |