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 8, 2013
1 parent 8b52a09 commit aaeed49
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 116 deletions.
149 changes: 70 additions & 79 deletions app/assets/stylesheets/themes/default.css.sass
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ body, small
+dashboard-font
line-height: $line-height

blockquote
+body-font-citation
margin: ($line-height / 2) $text-indent

cite + a[href*=annotation]
margin-left: 3px

Expand Down Expand Up @@ -306,30 +302,6 @@ footer
display: inline-block
width: $text-indent

///////////////////////////////
//
// Pages
//
///////////////////////////////
.books-show
iframe[src*='books.google']
+place(5, 7, 0)
height: $line-height * 24

.home-index
figure, ul
+column(12)
iframe
+column(12)
&[src*='vimeo'],
&[src*='youtube']
height: $line-height * 25
&[src*='soundcloud.com']
height: $line-height * 6
&[src*='soundcloud.com%2Fplaylist']
height: $line-height * 15

ul.notes, ul.citations
+column(12)
li
Expand All @@ -349,6 +321,23 @@ ul.notes, ul.citations
&:after
border-color: $link-hover-color

nav.tags
+place(0, 12, 0)
ul
+horizontal-list
margin-bottom: $line-height
&:before
+icon-tags
color: $secondary-color
display: inline
float: left
li
a:after
content: ', '
&:last-child
a:after
content: ''

ul.citations
+column(12)
li, li h2
Expand All @@ -362,38 +351,55 @@ blockquote
+prefix-with-emdash
margin: 0

// GENERALISE
.notes-show, .citations-show
figure
margin-bottom: $line-height / 2
&.image
+column(12)
img
float: left
clear: both
&.citation
margin: ($line-height/2) 0
blockquote
margin: 0 $text-indent
figcaption
+body-font-citation
margin: 0 $text-indent
padding: 0
&:before
content: '\2014'
figure
// margin-bottom: $line-height / 2
&.image
+column(12)
img
float: left
clear: both
&.citation
margin: ($line-height/2) 0
blockquote
margin: 0 0 0 $text-indent
text-align: left
&:before
+icon-quote-left-alt
color: $secondary-color
font-size: $body-font-size
position: absolute
left: 0
top: -2px
figcaption
+body-font-citation
margin-left: $text-indent
padding: 0
&:before
content: '\2014'

// TODO: genericise
.books-show, .links-show_channel, .citations-index, .citations-show, .tags-show
//on citations show, figures are not used, why?
//figure.citation
blockquote
// text-align: left
&:before
+icon-quote-left-alt
color: $secondary-color
font-size: $body-font-size
position: absolute
left: 0
///////////////////////////////
//
// Pages
//
///////////////////////////////
.books-show
iframe[src*='books.google']
+place(5, 7, 0)
height: $line-height * 24

.home-index
figure, ul
+column(12)
iframe
+column(12)
&[src*='vimeo'],
&[src*='youtube']
height: $line-height * 25
&[src*='soundcloud.com']
height: $line-height * 6
&[src*='soundcloud.com%2Fplaylist']
height: $line-height * 15

.citations-show
figure.citation
Expand Down Expand Up @@ -423,6 +429,9 @@ blockquote
&[id*=annotation-mark]
font-size: $small-font-size - 2px
vertical-align: super
blockquote
+body-font-citation
margin: ($line-height / 2) $text-indent
section
margin-bottom: $line-height
h2
Expand All @@ -440,24 +449,6 @@ blockquote
p:first-of-type
text-indent: 0

.notes-show, .citations-show
nav.tags
+place(0, 12, 0)
ul
+horizontal-list
margin-bottom: $line-height
&:before
+icon-tags
color: $secondary-color
display: inline
float: left
li
a:after
content: ', '
&:last-child
a:after
content: ''

ul.books, ul.links
+column(12)

Expand Down Expand Up @@ -661,7 +652,7 @@ section.links
// Undo all...
// Make sure this only applies to ltr pages
// Maybe we need to always write dir in body / html
// Also annotations.
// Also annotations, blurb arrows, and quotes
[dir=ltr]
#note-content[dir=rtl]
#text
Expand Down Expand Up @@ -804,7 +795,7 @@ section.links
+fade(0)
+hyphens
+column(3, 6)
+push(3, 6)
+push(6, 6)

&:hover
#text
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/citations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def links(book)
response.push link_to 'GoogleBooks', "http://books.google.com/books?id=#{ book.google_books_id }" unless book.google_books_id.blank?
response.push link_to 'LibraryThing', "http://www.librarything.com/work/#{ book.library_thing_id }" unless book.library_thing_id.blank?
response.push link_to 'OpenLibrary', "http://openlibrary.org/works/#{ book.open_library_id }" unless book.open_library_id.blank?
response.push link_to "Full text at #{ book.full_text.scan(%r(http://(.*?)/))[0][0] }",
book.full_text unless book.full_text.blank?
response.push link_to "Full text at #{ book.full_text_url.scan(%r(http://(.*?)/))[0][0] }",
book.full_text_url unless book.full_text_url.blank?
response.join(' ').html_safe
end
end
19 changes: 11 additions & 8 deletions app/helpers/formatting_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ def sanitize_from_db(text)
end

def format_blockquotes(text)
# This only works for books
# text.gsub(/^.*?quote:(.*?)\n? ?-- *(.*[\d]{4}.*?)$/i,
# (render citation_style('blockquote_with_attribution'), citation_text: '\\1', attribution: '\\2'))
text.gsub(/^.*?quote:(.*?)\n? ?-- *(.*?)$/i,
(render 'notes/blockquote_with_attribution_inline', citation_text: '\\1', attribution: '\\2'))
text.gsub(/^.*?quote:(.*?)\n? ?-- *(.*?)$/i, "\n<blockquote>\\1[\\2]</blockquote>\n")
.gsub(/^.*?quote:(.*)$/i, "\n<blockquote>\\1</blockquote>\n")
end

Expand Down Expand Up @@ -153,15 +149,21 @@ def smartify_hyphens(text)

def smartify_quotation_marks(text)
# TODO: This needs to be language dependent
# The following assumes we are not running this on HTML text. This is not hugely concerning since for body text we
# run this via Nokogiri and other strings should not be marked up. (But: cite links in headers?)
text.html_safe.gsub(/'([\d]{2})/, "\u2019\\1")
.gsub(/s' /, "s\u2019 ")
.gsub(/\&\#x27\;/, "\u2019")
.gsub(/(\b)'(\b)/, "\u2019")
.gsub(/(\w)'(\w)/, "\\1\u2019\\2")
.gsub(/(<[^>]*?)'([^']+?)'([^<]*?\>)/, '\\1ATTRIBUTE_QUOTES\\2ATTRIBUTE_QUOTES\\3')
.gsub(/(<[^>]*?)"([^"]+?)"([^<]*?\>)/, '\\1ATTRIBUTE_QUOTES\\2ATTRIBUTE_QUOTES\\3')
.gsub(/'([^']+)'/, "\u2018\\1\u2019") # If quotes are not closed this would trip up.
.gsub(/"([^"]+)"/, "\u201C\\1\u201D") # Same here.
.gsub(/ATTRIBUTE_QUOTES/, '"')

# .gsub(/(<[^>]*?)'([^']+?)'([^<]*?\>)/, '\\1ATTRIBUTE_QUOTES\\2ATTRIBUTE_QUOTES\\3') # IS THIS STILL NECESSARY SINCE WE@RE DOING IT THROUGH DOM?
# .gsub(/(<[^>]*?)"([^"]+?)"([^<]*?\>)/, '\\1ATTRIBUTE_QUOTES\\2ATTRIBUTE_QUOTES\\3')
# .gsub(/'([^']+)'/, "\u2018\\1\u2019") # If quotes are not closed this would trip up.
# .gsub(/"([^"]+)"/, "\u201C\\1\u201D") # Same here.
# .gsub(/ATTRIBUTE_QUOTES/, '"')
end

def smartify_numbers(text)
Expand All @@ -188,6 +190,7 @@ def paragraphize(text)

def sectionize(text)
text = text.split(/\*\*+/)
.reject(&:empty?)
.map { |content| "<section>#{ content }</section>" }
.join unless text[/\*\*+/].blank?
text = text.split('<h2>')
Expand Down
2 changes: 1 addition & 1 deletion app/views/citations/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
= render 'header', title: t('citations.index.title', id: @citation.id), :document_title => document_title

%section#text
= bodify(@citation.body, @citation.books, @citation.links, 'book_main_details', 'link_main_details')
= bodify(@citation.body, @citation.books, @citation.links)

= render 'notes/tag_list', tags: @tags unless @tags.blank?
3 changes: 0 additions & 3 deletions app/views/notes/_blockquote_with_attribution_inline.html.haml

This file was deleted.

49 changes: 26 additions & 23 deletions spec/helpers/formatting_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,32 @@
end
end

# This should be tested in views.
# describe '#bookify' do
# before do
# @book = FactoryGirl.create(:book, title: 'Discourse Networks 1800/1900',
# author: 'Friedrich Kittler',
# published_date: '21 Jan 2000')
# @book.valid?
# @book.save
# @books = Book.all
# end
# it 'converts inline references' do
# bookify('Text is -- Kittler 2000.', @books)
# .should == 'Text is -- <a href="/bibliography/kittler-2000">Kittler: Discourse Metworks 1800/1900</a>.'
# end
# end
# This should be tested in views.
# describe '#bookify' do
# before do
# @book = FactoryGirl.create(:book, title: 'Discourse Networks 1800/1900',
# author: 'Friedrich Kittler',
# published_date: '21 Jan 2000')
# @book.valid?
# @book.save
# @books = Book.all
# end
# it 'converts inline references' do
# bookify('Text is -- Kittler 2000.', @books)
# .should == 'Text is -- <a href="/bibliography/kittler-2000">Kittler: Discourse Metworks 1800/1900</a>.'
# end
# end

# describe '#smartify' do
# it 'does not convert double quotes inside html tags' do
# smartify('Plain text with <a href="link">link</a> does "nothing silly".')
# .should == "Plain text with <a href=\"link\">link</a> does \u201Cnothing silly\u201D."
# end
# it 'does not convert double quotes inside html tags' do
# smartify('Plain "text with <a href="link">link</a> is OK."')
# .should == "Plain \u201Ctext with <a href=\"link\">link</a> is OK.\u201D"
# end
# end

describe '#smartify_hyphens' do
# it 'converts parenthetical hyphens to en dashes' do
Expand Down Expand Up @@ -102,14 +113,6 @@
it 'converts double quotes to 66 and 99' do
smartify_quotation_marks("Text \"I'm ironic\" quotes.").should == "Text \u201CI\u2019m ironic\u201D quotes."
end
it 'does not convert double quotes inside html tags' do
smartify_quotation_marks('Plain text with <a href="link">link</a> does "nothing silly".')
.should == "Plain text with <a href=\"link\">link</a> does \u201Cnothing silly\u201D."
end
it 'does not convert double quotes inside html tags' do
smartify_quotation_marks('Plain "text with <a href="link">link</a> is OK."')
.should == "Plain \u201Ctext with <a href=\"link\">link</a> is OK.\u201D"
end
end

describe '#smartify_numbers' do
Expand Down

0 comments on commit aaeed49

Please sign in to comment.