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

Commit

Permalink
Update styling
Browse files Browse the repository at this point in the history
  • Loading branch information
joegatt committed Aug 6, 2013
1 parent 34e2426 commit 3f97a2e
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 53 deletions.
62 changes: 32 additions & 30 deletions app/assets/stylesheets/themes/default.css.sass
Original file line number Diff line number Diff line change
Expand Up @@ -568,28 +568,30 @@ section.links
margin: $line-height 0
height: $line-height * 2

.notes-index, .citations-index
ul.notes, ul.citations
+column(12)
ul.notes, ul.citations
+column(12)

ul.notes
li
position: relative
a
padding-right: 34.38889% // OPTIMIZE: We get these measurements from the columns.
+blurb(4, 34.38889%) // Ideally, we would sue the semantic.gs algorithm.
img
position: absolute
width: auto
right: 0
height: $line-height * 4
ul
&.notes
li
position: relative
a
padding-right: 34.38889% // OPTIMIZE: We get these measurements from the columns.
+blurb(4, 34.38889%) // Ideally, we would sue the semantic.gs algorithm.
img
position: absolute
width: auto
right: 0
height: $line-height * 4
&.citations
li
position: relative
a
padding-right: 34.38889%

#note-content
+clearfix
margin-bottom: $line-height
figure
&.image
+place(0, 12, 0)
Expand Down Expand Up @@ -707,8 +709,6 @@ section.links
&.main
font-weight: bold

ul.notes, ul.citations
+place(0, 9, 3)
.books
ul
+column(6)
Expand Down Expand Up @@ -741,10 +741,6 @@ section.links
+columns(4)
margin-bottom: $line-height

.citations-index
ul.citations
+column(6)

@media only screen and (min-width: 1024px)

+pass_media_query('screen-and-min-width-1024px')
Expand All @@ -755,20 +751,26 @@ section.links

.home-index
ul.notes
+column(12)
+columns(3)
+fixed-column-gap
a
+blurb(7)
+blurb(12)

.notes-index, .citations-index
ul.notes, ul.citations
+column(9)
li
a
+blurb(5, 34.38889%)
img
width: 240px // OPTIMIZE: We get these measurements from the columns.
height: $line-height * 5
ul.notes
+place(0, 9, 3)
li
a
+blurb(5, 34.38889%)
img
width: 240px // OPTIMIZE: We get these measurements from the columns.
height: $line-height * 5

ul.citations
+place(0, 9, 3)
li
a
padding-right: 34.38889%

.books-index, .links-index
ul
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class NotesController < ApplicationController

def index

@notes = Note.publishable.listable.all
@notes = Note.publishable.listable.blurbable.all

respond_to do |format|
format.html
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/blurb_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

module BlurbHelper

def blurb(headline, clean_body)
def blurb(headline, clean_body, blurb_length = Settings.notes.blurb_length)
# If the title is derived from the body, we do not include it in the blurb
body_contains_headline = (clean_body.index(headline) == 0)
headline = body_contains_headline ? headline : "#{ headline }: "
start_blurb_at = body_contains_headline ? headline.length : 0
blurb = clean_body[start_blurb_at .. clean_body.length]
.truncate(Settings.notes.blurb_length, separator: ' ', omission: Settings.notes.blurb_omission)
.truncate(blurb_length, separator: ' ', omission: Settings.notes.blurb_omission)
.gsub(/\W#{ Settings.notes.blurb_omission }$/, '')
[headline, blurb]
end
Expand Down
7 changes: 4 additions & 3 deletions app/models/note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ class Note < ActiveRecord::Base
}

default_scope order: 'external_updated_at DESC'
scope :publishable, where(active: true, hide: false)
scope :listable, where(listable: true, is_citation: false)
scope :blurbable, where('word_count > ?', (Settings.notes.blurb_length / Settings.lang.average_word_length))
scope :citations, where(is_citation: true)
scope :need_syncdown, where('dirty = ? AND attempts <= ?', true, Settings.notes.attempts).order('updated_at')
scope :listable, where(listable: true, is_citation: false)
scope :maxed_out, where('attempts > ?', Settings.notes.attempts).order('updated_at')
scope :need_syncdown, where('dirty = ? AND attempts <= ?', true, Settings.notes.attempts).order('updated_at')
scope :publishable, where(active: true, hide: false)

validates :title, :external_updated_at, presence: true
validate :body_or_source_or_resource?, before: :update
Expand Down
3 changes: 2 additions & 1 deletion app/views/application/_notes_list.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
%ul.notes
= list_of notes do |note|

- headline, blurb = blurb(note.headline, note.clean_body)
- blurb_length = blurb_length || Settings.notes.blurb_length
- headline, blurb = blurb(note.headline, note.clean_body, blurb_length)
- image = note.resources.attached_images.first

%a{ href: note_path(note), lang: lang_attr(note.lang), dir: dir_attr(note.lang) }
Expand Down
2 changes: 1 addition & 1 deletion app/views/books/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- document_title = @book.headline
- document_title = "#{ strip_tags(@book.headline) } | #{ t('.title') } | #{ t('site.title') }"
- set_meta_tags :title => document_title,
:description => '',
:open_graph => { :title => document_title }
Expand Down
18 changes: 9 additions & 9 deletions app/views/home/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
- document_title = t('site.title')
- set_meta_tags :title => document_title,
:description => '',
:open_graph => { :title => document_title }
- set_meta_tags title: document_title,
description: '',
open_graph: { title: document_title }

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

- if @notes.size == 1

-#= render 'images', :note => @notes.first, :type => :standard
-#= render 'images', note: @notes.first, type: :standard
- image = @notes.first.resources.first
%figure
= link_to image_tag(cut_image_binary_path(image, :type => :cinema),
:alt => strip_tags(image.description)), @notes.first
= link_to image_tag(cut_image_binary_path(image, type: :cinema),
alt: strip_tags(image.description)), @notes.first
- if image.caption
%figcaption= image.caption.html_safe

= render 'media', :note => @notes.first
= render 'media', note: @notes.first

- elsif @notes.size > 1

= render 'notes_list', :notes => @notes.first(3)
= render 'notes_list', notes: @notes.first(3), blurb_length: Settings.notes.blurb_length * 1.5

- else

Expand Down
2 changes: 1 addition & 1 deletion app/views/notes/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- document_title = "#{ @note.headline } | #{ t('.title', id: @note.id) }"
- document_title = "#{ @note.headline } | #{ t('.title', id: @note.id) } | #{ t('site.title') }"
- set_meta_tags title: document_title,
description: @note.body,
open_graph: { title: @note.title }
Expand Down
2 changes: 1 addition & 1 deletion app/views/notes/version.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- document_title = "#{ @diffed_version.title } | #{ t('notes.version.full', id: @note.id, sequence: @diffed_version.sequence) }"
- document_title = "#{ @diffed_version.title } | #{ t('notes.version.full', id: @note.id, sequence: @diffed_version.sequence) } | #{ t('site.title') }"
- set_meta_tags title: document_title,
canonical: note_path(@note),
description: @diffed_version.body,
Expand Down
2 changes: 1 addition & 1 deletion app/views/tags/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- document_title = t('.title')
- document_title = "#{ t('.title') } | #{ t('site.title') }"
- set_meta_tags title: document_title,
description: '',
open_graph: { title: document_title },
Expand Down
4 changes: 2 additions & 2 deletions app/views/tags/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
- document_title = t('.title', name: @tag.name)
- document_title = "#{ t('.title', name: @tag.name) } | #{ t('site.title') }"
- set_meta_tags title: document_title,
description: '',
open_graph: { title: document_title }

%section

= render 'header', title: t('.title', name: @tag.name), document_title: document_title
= render 'header', title: t('.title_short', name: @tag.name), document_title: document_title

= render 'notes_list', notes: @notes

Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ en:
index:
title: 'Tags'
show:
title: "%{name}"
title: "Tag: \"%{name}\""
title_short: "%{name}"
not_found: "Tag: %{slug} is not available."

books:
Expand Down
1 change: 1 addition & 0 deletions config/nembrot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ defaults: &defaults
errors: ['', 'UNKNOWN', 'BAD_DATA_FORMAT', 'PERMISSION_DENIED', 'INTERNAL_ERROR', 'DATA_REQUIRED', 'LIMIT_REACHED', 'QUOTA_REACHED', 'INVALID_AUTH', 'AUTH_EXPIRED', 'DATA_CONFLICT', 'ENML_VALIDATION', 'SHARD_UNAVAILABLE', 'LEN_TOO_SHORT', 'LEN_TOO_LONG', 'TOO_FEW', 'TOO_MANY', 'UNSUPPORTED_OPERATION']
daemon_frequency: 30
lang:
average_word_length: 5.5
rtl_langs: ['ar', 'fa']
home:
instructions:
Expand Down

0 comments on commit 3f97a2e

Please sign in to comment.