Commit 80eba16a by tady

header search hint

parent 9dc4cef6
module StyleHelper
## Store style
# Usage:
# <% style do %>
# div {
# color: red;
# }
# <% end %>
def style(&block)
content_for(content_key, capture(&block))
end
## Render all style
def render_style
return if content_for(content_key).nil?
html_buf = '<style type="text/css">'
html_buf << content_for(content_key)
html_buf << '</style>'
html_buf.html_safe
end
private
# Use for `content_for`
def content_key
:style_addon
end
end
......@@ -9,6 +9,8 @@
<!-- Optional theme -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap-theme.min.css">
<%= render_style %>
<%= csrf_meta_tags %>
</head>
<body class="<%= params[:controller] %>-<%= params[:action] %>">
......
......@@ -25,8 +25,8 @@
</div>
</form>
<p class="navbar-text">
<a href="#"><span class="glyphicon glyphicon-question-sign"></span></a>
<p class="navbar-text" id="header-search-hint">
<a href="#"><span class="glyphicon glyphicon-question-sign" data-toggle="modal" data-target="#header-search-description"></span></a>
</p>
<%= form_tag(destroy_user_session_path, :method => :delete, class: 'navbar-form navbar-right') do %>
......@@ -45,3 +45,42 @@
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
<!-- Modal #header-search-description -->
<div class="modal fade" id="header-search-description" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Search command</h4>
</div>
<div class="modal-body">
<dl class="dl-horizontal">
<dt>Search by title</dt>
<dd><pre><a href="<%= posts_path(q: 'title:ruby') %>">title:ruby</a></pre></dd>
<dt>Search by id</dt>
<dd><pre><a href="<%= posts_path(q: 'id:123') %>">id:123</a></pre></dd>
<dt>Search by body</dt>
<dd><pre><a href="<%= posts_path(q: 'body:ruby') %>">body:ruby</a></pre></dd>
<dt>Search by author</dt>
<dd><pre><a href="<%= posts_path(q: '@taro') %>">@taro</a></pre></dd>
<dt>Search by tag</dt>
<dd><pre><a href="<%= posts_path(q: '#ruby') %>">#ruby</a></pre></dd>
<dt>Search by date</dt>
<dd><pre><a href="<%= posts_path(q: 'date:2013-12-16') %>">date:2013-12-16</a></pre></dd>
<dt>Search by title or body</dt>
<dd><pre><a href="<%= posts_path(q: 'ruby') %>">ruby</a></pre></dd>
</dl>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<% style do %>
#header-search-hint{
margin-left: 0;
}
<% end %>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment