Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Add statistics to index pages
Browse files Browse the repository at this point in the history
  • Loading branch information
joegatt committed Aug 9, 2013
1 parent 2807305 commit e714ebf
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 12 deletions.
13 changes: 13 additions & 0 deletions app/assets/stylesheets/themes/default.css.sass
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ article[dir=rtl]
text-align: right
float: right

aside
font-style: italic

body, small
+dashboard-font
line-height: $line-height
Expand Down Expand Up @@ -338,6 +341,13 @@ nav.tags
a:after
content: ''

#main
.books-index, .links-index, .tags-index // Genericise index lists to avoid this
section
ul, ol
+clearfix
margin-bottom: $line-height

ul.citations
+column(12)
li, li h2
Expand Down Expand Up @@ -377,6 +387,9 @@ figure
&:before
content: '\2014'

.statistics
+column(12)

///////////////////////////////
//
// Pages
Expand Down
1 change: 1 addition & 0 deletions app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class BooksController < ApplicationController

def index
@books = Book.publishable
@references_count = @books.sum { |b| b.notes.size }

respond_to do |format|
format.html
Expand Down
1 change: 1 addition & 0 deletions app/controllers/links_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def index
# REVIEW: This gives the count of links per channel, what we really want is number of citations
# @channels = Link.publishable.group(:channel).count(:channel)
@channels = Link.publishable.group(:channel)
@references_count = @channels.sum { |l| l.notes.size }

respond_to do |format|
format.html
Expand Down
1 change: 1 addition & 0 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class NotesController < ApplicationController
def index

@notes = Note.publishable.listable.blurbable.all
@word_count = Note.publishable.listable.blurbable.sum(:word_count)

respond_to do |format|
format.html
Expand Down
1 change: 1 addition & 0 deletions app/controllers/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class TagsController < ApplicationController
def index

@tags = Note.publishable.tag_counts_on(:tags)
@references_count = @tags.sum { |t| t.count }

respond_to do |format|
format.html
Expand Down
15 changes: 9 additions & 6 deletions app/views/books/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
- document_title = "#{ t('.title') } | #{ t('site.title') }"
- set_meta_tags :title => document_title,
:description => '',
:open_graph => { :title => document_title },
:noindex => true
- set_meta_tags title: document_title,
description: '',
open_graph: { title: document_title },
noindex: true

%section

= render 'header', :title => t('.title'), :document_title => document_title
= render 'header', title: t('.title'), document_title: document_title

= render 'books_list', :books => @books
= render 'books_list', books: @books

%aside.statistics
= t('.statistics', count: number_with_delimiter(@books.size), references_count: number_with_delimiter(@references_count))
15 changes: 9 additions & 6 deletions app/views/citations/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
- document_title = "#{ t('.title') } | #{ t('site.title') }"
- set_meta_tags :title => document_title,
:description => '',
:open_graph => { :title => document_title },
:noindex => true
- set_meta_tags title: document_title,
description: '',
open_graph: { title: document_title },
noindex: true

%section

= render 'header', :title => t('.title'), :document_title => document_title
= render 'header', title: t('.title'), document_title: document_title

= render 'citations_list', :citations => @citations.first(Settings.notes.index.page_size)
= render 'citations_list', citations: @citations.first(Settings.notes.index.page_size)

%aside.statistics
= t('.statistics', count: number_with_delimiter(@citations.size))
3 changes: 3 additions & 0 deletions app/views/links/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
= render 'header', title: t('.title'), document_title: document_title

= render 'channels_list', channels: @channels

%aside.statistics
= t('.statistics', count: number_with_delimiter(@channels.size), references_count: number_with_delimiter(@references_count))
3 changes: 3 additions & 0 deletions app/views/notes/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
= render 'header', title: t('.title'), document_title: document_title

= render 'notes_list', notes: @notes.first(Settings.notes.index.page_size)

%aside.statistics
= t('.statistics', count: number_with_delimiter(@notes.size), word_count: number_with_delimiter(@word_count))
3 changes: 3 additions & 0 deletions app/views/tags/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
= render 'header', title: t('.title'), document_title: document_title

= render 'tags_list', tags: @tags

%aside.statistics
= t('.statistics', count: number_with_delimiter(@tags.size), references_count: number_with_delimiter(@references_count))
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ en:
notes:
index:
title: 'Notes'
statistics: "%{count} notes (%{word_count} words)."
show:
title: "Note %{id}"
not_found: "Note %{id} is not available."
Expand Down Expand Up @@ -64,6 +65,7 @@ en:
tags:
index:
title: 'Tags'
statistics: "%{count} tags (%{references_count} references)."
show:
title: "Tag: \"%{name}\""
title_short: "%{name}"
Expand All @@ -72,6 +74,7 @@ en:
books:
index:
title: 'Bibliography'
statistics: "%{count} books (%{references_count} references)."
show:
title: 'Bibliography'
not_found: "Book: %{slug} is not available."
Expand All @@ -89,13 +92,15 @@ en:
links:
index:
title: 'Links'
statistics: "%{count} links (%{references_count} references)."
show_channel:
title: 'Links'
not_found: "Links for %{channel} are not available."

citations:
index:
title: 'Citations'
statistics: "%{count} citations."
show:
title: "Citation %{id}"
not_found: "Citation %{id} is not available."
Expand Down

0 comments on commit e714ebf

Please sign in to comment.