Module: TumblrClientWrapper::Posts
- Includes:
- ActionView::Helpers::DateHelper
- Included in:
- Helpers
- Defined in:
- lib/tumblr_client_wrapper/posts.rb
Defined Under Namespace
Classes: ApiRequest
Class Method Summary collapse
- .parse_answer(post) ⇒ Object
- .parse_audio(post) ⇒ Object
- .parse_chat(post) ⇒ Object
- .parse_link(post) ⇒ Object
- .parse_photo(post) ⇒ Object
- .parse_quote(post) ⇒ Object
- .parse_text(post) ⇒ Object
- .parse_video(post) ⇒ Object
Instance Method Summary collapse
Class Method Details
.parse_answer(post) ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# 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"]) = %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) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# 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"] = post["caption"] player = post["player"] plays = post["plays"] date = time_ago_in_words(post["date"]) = %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"> #{} </div> </div> ) end end |
.parse_chat(post) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# 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"]) = %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) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/tumblr_client_wrapper/posts.rb', line 127 def parse_link(post) title = post["title"] url = post["url"] = post["author"] excerpt = post["excerpt"] publisher = post["publisher"] photos = post["photos"] description = post["description"] date = time_ago_in_words(post["date"]) = %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) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/tumblr_client_wrapper/posts.rb', line 75 def parse_photo(post) = post["caption"] link_url = post["link_url"] photos = post["photos"] date = time_ago_in_words(post["date"]) = "" photos.each do |photo| = %Q( <a href="#{link_url}"> <img src="#{photo["original_size"]["url"]}" width="#{photo["original_size"]["width"]}" height="#{photo["original_size"]["height"]}" alt="#{}"> </a> ) end = %Q( <div class="post_content"> <div class="post_date">#{date}</div> <div class="post_media"> #{} </div> <div class="body"> #{} </div> </div> ) end |
.parse_quote(post) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# 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"]) = %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? += %Q( <div class="post_body"> <p class="source">- #{source}</p> </div> ) end += %Q( </div> ) end |
.parse_text(post) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# 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"]) = %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) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/tumblr_client_wrapper/posts.rb', line 199 def parse_video(post) source_url = post["source_url"] source_title = post["source_title"] = post["caption"] player = post["player"] date = time_ago_in_words(post["date"]) = %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"> #{} </div> </div> ) end |
Instance Method Details
#embed_post(tumblr_id, options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tumblr_client_wrapper/posts.rb', line 26 def (tumblr_id, ) api = ApiRequest.new posts = api.get_posts(tumblr_id, ) = "" if posts["posts"] posts["posts"].each do |post| post_type = post["type"] case post_type when "text" += parse_text(post) when "photo" += parse_photo(post) when "quote" += parse_quote(post) when "link" += parse_link(post) when "chat" += parse_chat(post) when "audio" += parse_audio(post) when "video" += parse_video(post) when "answer" += parse_answer(post) end end end return end |