Skip to content

Commit

Permalink
flow view
Browse files Browse the repository at this point in the history
  • Loading branch information
tadyjp committed Mar 11, 2014
1 parent 7b595a0 commit fc172c5
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 56 deletions.
16 changes: 16 additions & 0 deletions app/assets/javascripts/lib/mod-time-ago.js.coffee
@@ -0,0 +1,16 @@
# Desc
# nn分前をjsで表示する
# `.js-time-ago`クラスのついた要素の`data-time-ago-at`属性を時刻に変換
# Usage:
# <abbr class="js-time-ago" data-time-ago-at="2014-03-12 00:27:57 +0900"></abbr>
# Example:
# <abbr class="js-time-ago" data-time-ago-at="2014-03-12 00:27:57 +0900">a minute ago</abbr>

$ ->
renderTimeAgo = ->
$('.js-time-ago').each ->
$this = $(@)
$this.text moment($this.data('time-ago-at')).fromNow()

setInterval(renderTimeAgo, 1000 * 10)
renderTimeAgo()
15 changes: 12 additions & 3 deletions app/views/flow/show.html.slim
Expand Up @@ -8,19 +8,28 @@
.col-xs-8 role="navigation"
.list-group
- @posts.each_with_index do |post, i|
a.list-group-item.post-list data-post-id=post.id href="#" = post.title
a.list-group-item.post-list data-post-id=post.id href="#"
.text-primary #{post.title}
small
| #{post.author.name} posted&nbsp;
abbr.js-time-ago data-time-ago-at=post.updated_at
|.&nbsp;&nbsp;
- post.tags.each do |tag|
span.label.label-success ##{tag.name}
| &nbsp;


.col-xs-4
.panel.panel-default
.panel-heading
h2.panel-title この1週間で閲覧の多かった投稿
h2.panel-title この1週間で閲覧の多かった投稿(調整中)
.panel-body.list-group
- Post.limit(5).each_with_index do |post, i|
a.list-group-item.post-list data-post-id=post.id href="#" = post.title

.panel.panel-default
.panel-heading
h2.panel-title 最近投稿したユーザー
h2.panel-title 最近投稿したユーザー(調整中)
.panel-body.list-group
- User.post_recently.limit(10).each_with_index do |author, i|
a.list-group-item.post-list data-author-id=author.id href="#" = author.name
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.slim
Expand Up @@ -20,6 +20,7 @@ html lang="ja"
script src="//cdnjs.cloudflare.com/ajax/libs/underscore.string/2.3.3/underscore.string.min.js"
script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"
script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js"
javascript:
window.RV = window.RV || {};
window.RV.AllTags = JSON.parse('#{raw Tag.all.pluck(:name).to_json}');
Expand Down
46 changes: 45 additions & 1 deletion app/views/partials/_app_footer.html.slim
Expand Up @@ -2,8 +2,12 @@ footer
.container
p
a href="https://github.com/tadyjp/rendezvous" Github
| &nbsp;
| &nbsp;|&nbsp;
a href="https://twitter.com/tady_jp" @tady_jp
| &nbsp;|&nbsp;
a data-target="#header-search-description" data-toggle="modal" href="#" Search
| &nbsp;|&nbsp;
a href="https://help.github.com/articles/github-flavored-markdown" target="_blank" Markdown
| &nbsp;
a href="https://travis-ci.org/tadyjp/rendezvous"
img src="https://travis-ci.org/tadyjp/rendezvous.png"/
Expand All @@ -16,3 +20,43 @@ footer
| &nbsp;
a href="https://gemnasium.com/tadyjp/rendezvous"
img src="https://gemnasium.com/tadyjp/rendezvous.png"/

#header-search-description.modal.fade aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1"
.modal-dialog
.modal-content
.modal-header
button.close aria-hidden="true" data-dismiss="modal" type="button" &times;
h4#myModalLabel.modal-title Search command
.modal-body
dl.dl-horizontal
dt Search by title
dd
pre
a href=(posts_path(q: 'title:ruby')) title:ruby
dt Search by id
dd
pre
a href=(posts_path(q: 'id:123')) id:123
dt Search by body
dd
pre
a href=(posts_path(q: 'body:ruby')) body:ruby
dt Search by author
dd
pre
a href=(posts_path(q: '@taro')) @taro
dt Search by tag
dd
pre
a href=(posts_path(q: '#ruby')) #ruby
dt Search by date
dd
pre
a href=(posts_path(q: 'date:2013-12-16')) date:2013-12-16
dt Search by title or body
dd
pre
a href=(posts_path(q: 'ruby')) ruby
.modal-footer
button.btn.btn-default data-dismiss="modal" type="button" Close

56 changes: 6 additions & 50 deletions app/views/partials/_app_header.html.slim
Expand Up @@ -10,13 +10,12 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
span.input-group-btn
button.btn.btn-default data-disable-with="Searching..." type="submit"
span.glyphicon.glyphicon-search
p#header-search-hint.navbar-text
a data-target="#header-search-description" data-toggle="modal" href="#"
| Search
span.glyphicon.glyphicon-question-sign
a href="https://help.github.com/articles/github-flavored-markdown" target="_blank"
| Markdown
span.glyphicon.glyphicon-question-sign
ul.nav.navbar-nav
li
a Stock
li.active
a Flow

= form_tag(destroy_user_session_path, :method => :delete, class: 'navbar-form navbar-right') do
= submit_tag 'SignOut', class: 'btn btn-default'
.navbar-right
Expand All @@ -26,46 +25,3 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
img height="25" src=current_user.image_url width="25" /
= current_user.name

#header-search-description.modal.fade aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1"
.modal-dialog
.modal-content
.modal-header
button.close aria-hidden="true" data-dismiss="modal" type="button" &times;
h4#myModalLabel.modal-title Search command
.modal-body
dl.dl-horizontal
dt Search by title
dd
pre
a href=(posts_path(q: 'title:ruby')) title:ruby
dt Search by id
dd
pre
a href=(posts_path(q: 'id:123')) id:123
dt Search by body
dd
pre
a href=(posts_path(q: 'body:ruby')) body:ruby
dt Search by author
dd
pre
a href=(posts_path(q: '@taro')) @taro
dt Search by tag
dd
pre
a href=(posts_path(q: '#ruby')) #ruby
dt Search by date
dd
pre
a href=(posts_path(q: 'date:2013-12-16')) date:2013-12-16
dt Search by title or body
dd
pre
a href=(posts_path(q: 'ruby')) ruby
.modal-footer
button.btn.btn-default data-dismiss="modal" type="button" Close

- style do
| \#header-search-hint{
| margin-left: 0;
| }
4 changes: 2 additions & 2 deletions app/views/posts/_show_fragment.html.slim
Expand Up @@ -5,10 +5,10 @@
ul.list-group
li.list-group-item
- @post.tags.each do |tag|
span.label.label-info
span.label.label-success
a href=tag.decorate.show_path
| ##{tag.name}
span.label.label-success
span.label.label-info
a href=(posts_path(q: "@#{@post.author.name}"))
| @#{@post.author.name}
span.label.label-danger
Expand Down

0 comments on commit fc172c5

Please sign in to comment.