diff --git a/app/assets/stylesheets/themes/default.css.sass b/app/assets/stylesheets/themes/default.css.sass index c09ad4f2..348e2f2a 100644 --- a/app/assets/stylesheets/themes/default.css.sass +++ b/app/assets/stylesheets/themes/default.css.sass @@ -568,21 +568,21 @@ 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 @@ -590,6 +590,8 @@ section.links padding-right: 34.38889% #note-content + +clearfix + margin-bottom: $line-height figure &.image +place(0, 12, 0) @@ -707,8 +709,6 @@ section.links &.main font-weight: bold - ul.notes, ul.citations - +place(0, 9, 3) .books ul +column(6) @@ -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') @@ -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 diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 6440a245..8a9c296d 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -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 diff --git a/app/helpers/blurb_helper.rb b/app/helpers/blurb_helper.rb index 08381d9c..5740200e 100644 --- a/app/helpers/blurb_helper.rb +++ b/app/helpers/blurb_helper.rb @@ -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 diff --git a/app/models/note.rb b/app/models/note.rb index 099a0ea8..52dbe235 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -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 diff --git a/app/views/application/_notes_list.html.haml b/app/views/application/_notes_list.html.haml index dbf05552..a727c84c 100644 --- a/app/views/application/_notes_list.html.haml +++ b/app/views/application/_notes_list.html.haml @@ -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) } diff --git a/app/views/books/show.html.haml b/app/views/books/show.html.haml index ed821c3e..a3202b56 100644 --- a/app/views/books/show.html.haml +++ b/app/views/books/show.html.haml @@ -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 } diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 7ac013af..951d8d16 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -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 diff --git a/app/views/notes/show.html.haml b/app/views/notes/show.html.haml index b8ef38b9..0749e7c1 100644 --- a/app/views/notes/show.html.haml +++ b/app/views/notes/show.html.haml @@ -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 } diff --git a/app/views/notes/version.html.haml b/app/views/notes/version.html.haml index faec39e3..f5efe531 100644 --- a/app/views/notes/version.html.haml +++ b/app/views/notes/version.html.haml @@ -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, diff --git a/app/views/tags/index.html.haml b/app/views/tags/index.html.haml index 17256283..e65f7a8a 100644 --- a/app/views/tags/index.html.haml +++ b/app/views/tags/index.html.haml @@ -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 }, diff --git a/app/views/tags/show.html.haml b/app/views/tags/show.html.haml index a4c65de5..57da7e03 100644 --- a/app/views/tags/show.html.haml +++ b/app/views/tags/show.html.haml @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index be82a992..81d19d93 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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: diff --git a/config/nembrot.yml b/config/nembrot.yml index 9829197f..b875f286 100644 --- a/config/nembrot.yml +++ b/config/nembrot.yml @@ -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: