module TumblrClientWrapper::Posts
Public Class Methods
parse_answer(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 218 def parse_answer(post) question = post["question"] answer = post["answer"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_container"> <div class="post_title"> #{question} </div> <div class="post_body"> #{answer} </div> </div> </div> ) end
parse_audio(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 175 def parse_audio(post) if post[:type] == "audio" source_url = post["source_url"] source_title = post["source_title"] id3_title = post["id3_title"] caption = post["caption"] player = post["player"] plays = post["plays"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_media" style="width: 540px; height: 304px;"> <iframe src="#{source_url}"></iframe> </div> <div class="post_body"> #{caption} </div> </div> ) end end
parse_chat(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 154 def parse_chat(post) title = post["title"] body = post["body"] dialogue = post["dialogue"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_title">Post Tile"</div> <div class="post_body"> <ul class="conversation_lines"> <li class="chat_line"> <strong></strong> </li> </ul> </div> </div> ) end
parse_link(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 127 def parse_link(post) title = post["title"] url = post["url"] author = post["author"] excerpt = post["excerpt"] publisher = post["publisher"] photos = post["photos"] description = post["description"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_media"> <div class="link_button"> <a href="#" class="link_source_container"> </a> </div> </div> <dvi class="post_body"> <p>#{description}</p> </div> </div> ) end
parse_photo(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 75 def parse_photo(post) caption = post["caption"] link_url = post["link_url"] photos = post["photos"] date = time_ago_in_words(post["date"]) photos_embed = "" photos.each do |photo| photos_embed = %Q( <a href="#{link_url}"> <img src="#{photo["original_size"]["url"]}" width="#{photo["original_size"]["width"]}" height="#{photo["original_size"]["height"]}" alt="#{caption}"> </a> ) end embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_media"> #{photos_embed} </div> <div class="body"> #{caption} </div> </div> ) end
parse_quote(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 102 def parse_quote(post) content = post["text"] source = post["source"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_title extra_large"> <blockquote> <p>#{content}</p> </blockquote> </div> ) unless source.empty? embed += %Q( <div class="post_body"> <p class="source">- #{source}</p> </div> ) end embed += %Q( </div> ) end
parse_text(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 56 def parse_text(post) title = post["title"] body = post["body"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_container"> <div class="post_title"> #{title} </div> <div class="post_body"> #{body} </div> </div> </div> ) end
parse_video(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 199 def parse_video(post) source_url = post["source_url"] source_title = post["source_title"] caption = post["caption"] player = post["player"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_media" style="width: 540px; height: 304px;"> <iframe src="#{source_url}"></iframe> </div> <div class="post_body"> #{caption} </div> </div> ) end
Public Instance Methods
embed_post(tumblr_id, options)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 26 def embed_post(tumblr_id, options) api = ApiRequest.new posts = api.get_posts(tumblr_id, options) embed = "" if posts["posts"] posts["posts"].each do |post| post_type = post["type"] case post_type when "text" embed += parse_text(post) when "photo" embed += parse_photo(post) when "quote" embed += parse_quote(post) when "link" embed += parse_link(post) when "chat" embed += parse_chat(post) when "audio" embed += parse_audio(post) when "video" embed += parse_video(post) when "answer" embed += parse_answer(post) end end end return embed end
Private Instance Methods
parse_answer(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 218 def parse_answer(post) question = post["question"] answer = post["answer"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_container"> <div class="post_title"> #{question} </div> <div class="post_body"> #{answer} </div> </div> </div> ) end
parse_audio(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 175 def parse_audio(post) if post[:type] == "audio" source_url = post["source_url"] source_title = post["source_title"] id3_title = post["id3_title"] caption = post["caption"] player = post["player"] plays = post["plays"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_media" style="width: 540px; height: 304px;"> <iframe src="#{source_url}"></iframe> </div> <div class="post_body"> #{caption} </div> </div> ) end end
parse_chat(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 154 def parse_chat(post) title = post["title"] body = post["body"] dialogue = post["dialogue"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_title">Post Tile"</div> <div class="post_body"> <ul class="conversation_lines"> <li class="chat_line"> <strong></strong> </li> </ul> </div> </div> ) end
parse_link(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 127 def parse_link(post) title = post["title"] url = post["url"] author = post["author"] excerpt = post["excerpt"] publisher = post["publisher"] photos = post["photos"] description = post["description"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_media"> <div class="link_button"> <a href="#" class="link_source_container"> </a> </div> </div> <dvi class="post_body"> <p>#{description}</p> </div> </div> ) end
parse_photo(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 75 def parse_photo(post) caption = post["caption"] link_url = post["link_url"] photos = post["photos"] date = time_ago_in_words(post["date"]) photos_embed = "" photos.each do |photo| photos_embed = %Q( <a href="#{link_url}"> <img src="#{photo["original_size"]["url"]}" width="#{photo["original_size"]["width"]}" height="#{photo["original_size"]["height"]}" alt="#{caption}"> </a> ) end embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_media"> #{photos_embed} </div> <div class="body"> #{caption} </div> </div> ) end
parse_quote(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 102 def parse_quote(post) content = post["text"] source = post["source"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_title extra_large"> <blockquote> <p>#{content}</p> </blockquote> </div> ) unless source.empty? embed += %Q( <div class="post_body"> <p class="source">- #{source}</p> </div> ) end embed += %Q( </div> ) end
parse_text(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 56 def parse_text(post) title = post["title"] body = post["body"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_container"> <div class="post_title"> #{title} </div> <div class="post_body"> #{body} </div> </div> </div> ) end
parse_video(post)
click to toggle source
# File lib/tumblr_client_wrapper/posts.rb, line 199 def parse_video(post) source_url = post["source_url"] source_title = post["source_title"] caption = post["caption"] player = post["player"] date = time_ago_in_words(post["date"]) embed = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_media" style="width: 540px; height: 304px;"> <iframe src="#{source_url}"></iframe> </div> <div class="post_body"> #{caption} </div> </div> ) end