hobo_bootstrap 2.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ <include src="*"/>
@@ -0,0 +1,38 @@
1
+ <%# displays the pencil and trash can icons used by the bootstrap index page. %>
2
+ <def tag="bootstrap-table-actions">
3
+ <a with="&this_parent" action="edit">
4
+ <i class="icon icon-edit"></i>
5
+ </a>
6
+ <%= link_to '<i class=\'icon-trash\'></i>'.html_safe, this_parent, :confirm => t('hobo.messages.confirm', :default=>'Are you sure?'), method: :delete %>
7
+ </def>
8
+
9
+ <extend tag="index-page">
10
+ <old-index-page: merge>
11
+
12
+ <new-link: class="btn pull-right"/>
13
+
14
+ <collection: replace>
15
+ <%
16
+ if this.first
17
+ klass = this.first.class
18
+ columns = standard_fields(klass)
19
+ field_names = columns.select {|f| can_view?(this.first, f)}
20
+ if can_edit?(this.first, field_names[0])
21
+ field_names << "actions"
22
+ end
23
+ field_names[0] = "this"
24
+ field_names = field_names.join(', ')
25
+ end
26
+ %>
27
+ <table class="table table-striped" without-header
28
+ fields="&field_names" param="collection">
29
+ <actions-label:>
30
+ <t key="hobo.messages.actions">Actions</t>
31
+ </actions-label:>
32
+ <actions-view:>
33
+ <bootstrap-table-actions/>
34
+ </actions-view:>
35
+ </table>
36
+ </collection>
37
+ </old-index-page:>
38
+ </extend>
@@ -0,0 +1,88 @@
1
+ <!-- Simple log-in form.
2
+
3
+ ### Attributes
4
+
5
+ - `user-model`: The User class
6
+ - all other attributes are passed on to `<form>`. You will probably need to set the action attribute: `action="&user_login_path"`.
7
+ -->
8
+ <def tag="login-form" attrs="user-model">
9
+ <% user_model ||= self.try.model -%>
10
+ <form action="&request.fullpath" class="login" merge>
11
+
12
+ <div param="field-list">
13
+ <div class="control-group login-field">
14
+ <label param="login-label" class="control-label" for="login">
15
+ <t key="hobo.login.#{user_model.login_attribute}"><%= user_model.login_attribute.to_s.titleize %></t>
16
+ </label>
17
+ <div class="controls">
18
+ <input type="text" name="login" id="login" class="string"
19
+ param="login-input" />
20
+ </div>
21
+ </div>
22
+
23
+ <div class="control-group password-field">
24
+ <label param="password-label" class="control-label" for="password">
25
+ <t key="hobo.login.password">Password</t>
26
+ </label>
27
+ <div class="controls">
28
+ <input type="password" name="password" id="password" class="string"
29
+ param="password-input"/>
30
+ </div>
31
+ </div>
32
+
33
+ <div class="control-group remember-me-field">
34
+ <label param="remember-me-label" class="control-label"
35
+ for="remember-me">
36
+ <t key="hobo.login.remember_me">Remember me</t>
37
+ </label>
38
+ <div class="controls">
39
+ <label class="checkbox">
40
+ <input type="checkbox" name="remember_me" id="remember-me"
41
+ param="remember-me-input"/>
42
+ </label>
43
+ </div>
44
+ </div>
45
+ </div>
46
+
47
+
48
+ <div class="actions form-actions" style="padding-left:110px;">
49
+ <input class="btn btn-primary button submit-button" type="submit"
50
+ value="#{t 'hobo.actions.login', :default=>['Log in'] }"/>
51
+ <if test="&signup_url" class='nav-item'>
52
+ <t key="hobo.support.or">or</t> <a param="signup" href="&signup_url"><t key="hobo.login.signup">Sign up</t></a>
53
+ </if>
54
+ or <a href="&forgot_password_url" param="forgot-password" if="&forgot_password_url"><t key="hobo.login.forgot_password">Forgot your password?</t></a>
55
+ </div>
56
+
57
+ </form>
58
+ </def>
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+ <!-- Simple log-in page -->
69
+ <def tag="login-page">
70
+ <% remember_me = true if remember_me.nil? %>
71
+ <simple-page title="#{t 'hobo.login.title', :default=>['Log in'] }" without-subnav merge>
72
+
73
+ <body: class="login-page" param/>
74
+
75
+ <content: param>
76
+ <div class="row">
77
+ <div class="span3">&nbsp;</div>
78
+ <div class="span6">
79
+ <section param="content-body" class="well" style="padding:50px 50px 10px 50px;">
80
+ <h2 param="heading"><t key="hobo.login.heading">Log In</t></h2>
81
+ <login-form param="form" user-model="&model"/>
82
+ </section>
83
+ </div>
84
+ <div class="span3">&nbsp;</div>
85
+ </div>
86
+ </content:>
87
+ </simple-page>
88
+ </def>
data/taglibs/nav.dryml ADDED
@@ -0,0 +1,124 @@
1
+
2
+ <!-- Development mode only - a menu to change the `current_user` -->
3
+ <def tag="dev-user-changer">
4
+ <set user="&Hobo::Model::UserBase.default_user_model"/>
5
+ <select-menu if="&user && Rails.env.development?"
6
+ first-option="#{t('hobo.dev_user_changer.guest', {:default=>'Guest'})}" options="&user.all(:limit => 30).*.login"
7
+ onchange="location.href = '#{dev_support_path :action=>:set_current_user}?login=' + encodeURIComponent(this.options[this.selectedIndex].value)"
8
+ selected="#{current_user.login}"
9
+ class="dev-user-changer"
10
+ merge-attrs/>
11
+ </def>
12
+
13
+
14
+ <!-- General purpose navigation bar. Renders a `<ul class="navigation">`. This tag is intended to be used in conunction with `<nav-item>`. The main feature of this pair of tags (over, say, just using a plain `<ul>` list), is that it's easy to have a 'current' CSS class added to the appropriate nav item (so you can highlight the page/section the user is)
15
+
16
+ The main navigation in the default hobo app is implemented with `<navigation>` but this tag is also appropriate for any sub-navigation.
17
+
18
+ ### Attributes
19
+
20
+ - `current` - the textual content of the nav item that should have the 'current' CSS class added (see example)
21
+
22
+ ### Example
23
+
24
+ The normal usage is to define your own navigation tag that calls `<navigation>`.
25
+
26
+ <def tag="sub-nav">
27
+ <navigation merge>
28
+ <nav-item>Red</nav-item>
29
+ <nav-item>Green</nav-item>
30
+ <nav-item>Blue</nav-item>
31
+ </navigation>
32
+ </def>
33
+
34
+ Then in your pages you can call the tag like this
35
+
36
+ - On the 'red' page: `<sub-nav current="red"/>`
37
+ - On the 'green' page: `<sub-nav current="green"/>`
38
+ - and so on.
39
+
40
+ -->
41
+ <def tag="navigation" attrs="current,include-search">
42
+ <ul class="navigation" merge-attrs>
43
+ <set-scoped current-navigation="&current">
44
+ <do param="default"/>
45
+ <if test="&include_search">
46
+ <li class="pull-right">
47
+ <live-search param if="&defined_route? :site_search"/>
48
+ </li>
49
+ </if>
50
+ </set-scoped>
51
+ </ul>
52
+ </def>
53
+
54
+
55
+ <!-- Renders a single item in a [`<navigation>`](/api_tag_defs/navigation).
56
+
57
+ `<nav-item>` is basically an [`<a>`](/api_tag_defs/a) tag wrapped in an `<li>` tag. The attributes for [`<a>`](/api_tag_defs/a) may all be used on this tag, and work the same way.
58
+
59
+ Example 1: explicit links. Note that we're using explicit routes for clarity. Named routes are better.
60
+
61
+ <navigation current="home">
62
+ <nav-item href="/">Home</nav-item>
63
+ <nav-item href="/logout">Logout</nav-item>
64
+ </navigation>
65
+
66
+ Example 2: navigation based on a collection of items. Each item will be transformed into a link as described in [`<a>`](/api_tag_defs/a).
67
+
68
+ <navigation with="&links">
69
+ <repeat>
70
+ <nav-item/>
71
+ </repeat>
72
+ </navigation>
73
+
74
+ -->
75
+ <def tag="nav-item" attrs="name">
76
+ <% body = parameters.default
77
+ body = h(this.to_s) if body.blank?
78
+ name ||= body.gsub(/<.*?>/, '').strip
79
+ -%>
80
+ <li class="#{'active' if (c = scope.current_navigation) && c.downcase == name.downcase}"
81
+ merge-attrs="&attributes - (attrs_for(:a)+['target'])">
82
+ <a merge-attrs="&attributes & (attrs_for(:a)+['target'])"><%= body %></a>
83
+ </li>
84
+ </def>
85
+
86
+
87
+ <!-- Account Navigation (log in / out / signup)
88
+
89
+ When logged in, this renders:
90
+
91
+ - "Logged in as ..."
92
+ - Link to account page
93
+ - Log out link
94
+
95
+ When not logged in, renders:
96
+
97
+ - Log in link
98
+ - Sign up link
99
+
100
+ This is a simple tag - just look at the source if you need to know more detail.
101
+
102
+ -->
103
+ <def tag="account-nav">
104
+ <div class="nav-collapse collapse">
105
+ <do with="&current_user">
106
+ <ul class="navigation account-nav nav pull-right" param>
107
+
108
+ <li if="&Rails.env.development?" param="dev-user-changer"><dev-user-changer/></li>
109
+ <if test="&logged_in?">
110
+ <li class='nav-item' param="logged-in-as"><a to="&current_user"><t key="hobo.actions.logged_in_as" name="&name">Logged in as <name/></t></a></li>
111
+ <li class='nav-item' param="account"><a action="account"><t key="hobo.actions.account">Account</t></a></li>
112
+ <li class='nav-item' param="log-out"><a href="&logout_url"><t key="hobo.actions.logout">Log out</t></a></li>
113
+ </if>
114
+ <else>
115
+ <li class='nav-item' param="log-in"><a href="&login_url"><t key="hobo.actions.login">Log in</t></a></li>
116
+ <li if="&signup_url" class="nav-item" param="sign-up"><a href="&signup_url"><t key="hobo.actions.signup">Sign up</t></a></li>
117
+ </else>
118
+
119
+
120
+
121
+ </ul>
122
+ </do>
123
+ </div>
124
+ </def>
@@ -0,0 +1,93 @@
1
+ <!-- This file is necessary, it was mostly cloned from the default Hobo theme -->
2
+ <def tag="ajax-progress">
3
+ <div id="ajax-progress-wrapper">
4
+ <div id="ajax-progress" class="ajax-progress" merge-attrs>
5
+ <div>
6
+ <span id="ajax-progress-text"></span>
7
+ </div>
8
+ </div>
9
+ </div>
10
+ </def>
11
+
12
+ <!-- Add bootstrap classes to the default page layout
13
+
14
+ Attributes:
15
+
16
+ - nav-location: `top`, `sub`. Where do you want your main-nav located. `top` merges it into the top bar, `sub` gives it its own bar. `top` is the default option.
17
+
18
+ Make your choice global with:
19
+
20
+ <extend tag="page">
21
+ <old-page merge nav-location="sub">
22
+ </extend>
23
+
24
+ -->
25
+ <def tag="page" attrs="title, full-title, nav-location">
26
+ <% full_title ||= "#{title} : #{app_name}" %>
27
+ <html lang="en" merge-attrs>
28
+ <head param>
29
+ <title param><%= strip_tags full_title %></title>
30
+ <do param="stylesheets"><%# in Hobo <= 1.3, we had other stylesheets here. Now the asset pipeline is preferred. %>
31
+ <stylesheet name="#{subsite || 'front'}" param="app-stylesheet"/>
32
+ </do>
33
+
34
+ <do param="scripts"><%# in Hobo <= 1.3, we had other javascripts here. Now the asset pipeline is preferred. %>
35
+ <javascript param="application-javascript" name="#{subsite || 'front'}"/>
36
+ <do param="custom-scripts"/>
37
+ </do>
38
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
39
+ <%= csrf_meta_tag %>
40
+ </head>
41
+
42
+ <body param>
43
+ <set-scoped flash-rendered="&false">
44
+ <ajax-progress param/>
45
+ <div class="navbar">
46
+ <div class="navbar-inner">
47
+ <header class="container" param>
48
+ <button data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar" type="button">
49
+ <span class="icon-bar"></span>
50
+ <span class="icon-bar"></span>
51
+ <span class="icon-bar"></span>
52
+ </button>
53
+ <h1 param="app-name">
54
+ <a class="brand" href="#{base_url}/"><app-name/></a>
55
+ </h1>
56
+ <main-nav class="nav" current="&title" include-search param if="&nav_location.blank? || nav_location=='top'" />
57
+ <account-nav if="&login_url(Hobo::Model::UserBase.default_user_model)" param/>
58
+ </header>
59
+ </div>
60
+ </div>
61
+ <div class="container" param="nav-container" if="&nav_location=='sub'">
62
+ <div class="subnav" param="subnav">
63
+ <main-nav class="nav nav-pills" current="&title" include-search param/>
64
+ </div>
65
+ </div>
66
+ <% attributes[:content_size] = "12" unless attributes[:content_size]
67
+ aside_span = "span" + (12 - attributes[:content_size].to_i).to_s
68
+ %>
69
+ <div class="container bootstrap-content">
70
+ <div class="row">
71
+ <div class="span#{attributes[:content_size]}">
72
+ <section with-flash-messages param="content"/>
73
+ </div>
74
+ <div class="#{aside_span}" if="&attributes[:content_size].to_i < 12">
75
+ <div class="well">
76
+ <section param="aside"/>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+
82
+ <footer class="page-footer" param/>
83
+ <page-scripts param/>
84
+ </set-scoped>
85
+ </body>
86
+ </html>
87
+ </def>
88
+
89
+ <def tag="simple-page">
90
+ <page without-live-search without-main-nav merge>
91
+ <account-nav: replace />
92
+ </page>
93
+ </def>
@@ -0,0 +1,4 @@
1
+ <extend tag="page-nav">
2
+ <% add_classes!(attributes, "pagination") %>
3
+ <old-page-nav merge renderer="&BootstrapPagination::Rails"/>
4
+ </extend>
@@ -0,0 +1,13 @@
1
+ <!--
2
+ Adds bootstrap styling to `<live-search>`
3
+ -->
4
+ <extend tag="live-search">
5
+ <old-live-search>
6
+ <label: replace/>
7
+ <form: class="form-search"/>
8
+ <input: placeholder="Search" class="search-query"/>
9
+ <after-input:>
10
+ <i class="icon-search"></i>
11
+ </after-input:>
12
+ </old-live-search>
13
+ </extend>
@@ -0,0 +1,7 @@
1
+ <extend tag="show-page">
2
+ <old-show-page: merge>
3
+ <field-list: class="form-horizontal"/>
4
+ <edit-link: class="btn pull-right"/>
5
+ <after-edit-link:><div style="clear: right;"/></after-edit-link:>
6
+ </old-show-page:>
7
+ </extend>
@@ -0,0 +1,14 @@
1
+ <!--
2
+ Adds bootstrap styling to `<table-plus>`
3
+ -->
4
+ <extend tag="table-plus">
5
+ <old-table-plus merge>
6
+ <table: class="table table-striped table-bordered" style="clear: both;"/>
7
+ <header: style="float: right;"/>
8
+ <search-filter:>
9
+ <search-form: class="form-search" style="display: inline;" />
10
+ <input: class="search-query"/>
11
+ <clear-form: class="form-search" style="display: inline;"/>
12
+ </search-filter:>
13
+ </old-table-plus>
14
+ </extend>
@@ -0,0 +1,35 @@
1
+ <%#
2
+
3
+ Given a list, renders a bootstrap tab collection.
4
+
5
+ ### Example
6
+
7
+ <bootstrap-tab-list:fragments class="tabs-left" active="&this.fragments.first" >
8
+ <a:>Page <view:page/></a:>
9
+ <body:><view:body/></body:>
10
+ </bootstrap-tab-list:fragments>
11
+
12
+ ### Attributes
13
+
14
+ - active: the element you wish to be initially visible
15
+
16
+ - id-prefix: (default: tab) if you have more than one set of tabs on a page, set this to a unique string.
17
+
18
+ %>
19
+ <def tag="bootstrap-tab-list" attrs="active, id-prefix">
20
+ <% id_prefix ||= "tab" %>
21
+ <div class="tabbable" merge param>
22
+ <ul class="nav nav-tabs" param>
23
+ <repeat>
24
+ <li class="#{'active' if this==active}" param>
25
+ <a href="##{id_prefix}#{this_field}" data-toggle="tab" param/>
26
+ </li>
27
+ </repeat>
28
+ </ul>
29
+ <div class="tab-content" param="content-container">
30
+ <repeat>
31
+ <div id="#{id_prefix}#{this_field}" class="tab-pane #{'active' if this==active}" param="body"/>
32
+ </repeat>
33
+ </div>
34
+ </div>
35
+ </def>
@@ -0,0 +1 @@
1
+ //=require bootstrap-all
@@ -0,0 +1,83 @@
1
+ @import "compass_twitter_bootstrap";
2
+
3
+ /* Top menu bar (app name, login...):
4
+ It's full width so border-radius is unnecessary */
5
+ .navbar-inner{
6
+ border-radius:0px;
7
+ }
8
+ /* Top menu tweaks */
9
+ .dev-user-changer{
10
+ margin-top:3px;
11
+ opacity:0.8;
12
+ border-radius:4px;
13
+ }
14
+ .dev-user-changer select{
15
+ margin-bottom:5px;
16
+ }
17
+
18
+
19
+
20
+
21
+
22
+ /* Main menu bar (model links): search box*/
23
+ .form-search{
24
+ margin:4px 4px 0 0;
25
+ }
26
+ .form-search i {
27
+ margin: -20px 0 0 162px;
28
+ display: block;
29
+ position:absolute;
30
+ }
31
+ #search-results-part{
32
+ display:none;
33
+ }
34
+
35
+
36
+
37
+
38
+ /* Page heading */
39
+ .bootstrap-content{
40
+ margin-top:16px;
41
+ }
42
+ h2.heading{
43
+ margin-bottom:10px;
44
+ line-height:24px;
45
+ }
46
+
47
+ /* hidden-fields */
48
+ div.hidden-fields {
49
+ display:none;
50
+ }
51
+
52
+ /* spinner */
53
+ .ajax-progress{
54
+ padding: 0 20px 10px;
55
+ background: url(ajax-loader.gif) no-repeat 0px 1px;
56
+ display: none;
57
+ }
58
+
59
+ /* wrap with a position:absolute so the relatively positioned stuff inside doesn't leave a blank space */
60
+ #ajax-progress-wrapper {
61
+ position: absolute;
62
+ }
63
+
64
+ /* input-many */
65
+ ul.input-many {list-style-type: none;}
66
+ ul.input-all {list-style-type: none;}
67
+
68
+ ul.input-many > li { overflow:hidden; zoom:1;}
69
+ ul.input-many .input-many-item {float:left;}
70
+ ul.input-many div.buttons {float:left; margin-left:10px;}
71
+ li.input-many-template { display:none; }
72
+
73
+
74
+
75
+
76
+ /* Index page fix */
77
+ .index-page .content-body .table{
78
+ clear:both;
79
+ }
80
+
81
+
82
+ /* collection */
83
+ ul.collection > li { margin-left: 0; list-style: none;}