Skip to content

Commit

Permalink
for now moved the collections extension back into my site,
Browse files Browse the repository at this point in the history
helper method to strip images,
whitespace,
fixed the atom template in regards to author support
  • Loading branch information
tcurdt committed May 12, 2011
1 parent 681dfe8 commit cae4407
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 63 deletions.
10 changes: 7 additions & 3 deletions lib/awestruct/context_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ def clean_html(str)
str.gsub( / /, ' ' )
end

def without_images(str)
str.gsub(/<img[^>]+>/,'').gsub(/<a[^>]+>([^<]*)<\/a>/, '\1')
end

def summarize(text, numwords=20)
text.split()[0, numwords].join(' ')
end

def fully_qualify_urls(base_url, text)
doc = Hpricot( text )

doc.search( "//a" ).each do |a|
a['href'] = fix_url( base_url, a['href'] )
end
Expand All @@ -29,7 +33,7 @@ def fully_qualify_urls(base_url, text)
end
return doc.to_s
end

def fix_url(base_url, url)
return url unless ( url =~ /^\// )
"#{base_url}#{url}"
Expand Down
1 change: 0 additions & 1 deletion lib/awestruct/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

require 'awestruct/extensions/pipeline'
require 'awestruct/extensions/posts'
require 'awestruct/extensions/collection'
require 'awestruct/extensions/indexifier'
require 'awestruct/extensions/data_dir'
require 'awestruct/extensions/paginator'
Expand Down
52 changes: 0 additions & 52 deletions lib/awestruct/extensions/collection.rb

This file was deleted.

23 changes: 16 additions & 7 deletions lib/awestruct/extensions/template.atom.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
%feed{ 'xml:base'=>site.base_url, 'xml:lang'=>'en-US', :xmlns=>'http://www.w3.org/2005/Atom' }
%id #{site.base_url}
%title #{page.title}
- if ( defined?( site.author ) )
%author
- if ( defined?( site.author.name ) )
%name= site.author.name
- if ( site.author.email )
%email= site.author.email
- else
%name= site.author
- unless page.entries.empty?
%updated= page.entries.first.date.xmlschema
%link{:rel=>"alternate", :type=>"text/html", :href=>site.base_url}
Expand All @@ -15,13 +23,14 @@
%title= escape_once( entry.title )
%updated= entry.date.xmlschema
%link{:rel=>"alternate", :type=>"text/html", :href=>"#{site.base_url}#{entry.url}" }
%author
- if ( defined?( entry.author.name ) )
%name= entry.author.name
- if ( entry.author.email )
%name= entry.author.email
- else
%name= entry.author
- if ( defined?( entry.author ) )
%author
- if ( defined?( entry.author.name ) )
%name= entry.author.name
- if ( entry.author.email )
%email= entry.author.email
- else
%name= entry.author
%summary
#{summarize( html_to_text( entry.content ), 100 )}...
%content{:type=>'html'}
Expand Down

0 comments on commit cae4407

Please sign in to comment.