Skip to content

Commit

Permalink
Use fallback title if empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Dec 7, 2017
1 parent 31aa6af commit 7125248
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/initializers/05-string.rb
Expand Up @@ -32,6 +32,11 @@ def trunc(i=140)
self.truncate(i, separator: " ", omission: " …") # …
end

def or(alt)
return alt if self.ustrip == ""
self
end

def esc
self.gsub("&","&amp;").gsub("<","&lt;")
end
Expand Down
2 changes: 1 addition & 1 deletion views/periscope_feed.erb
Expand Up @@ -11,7 +11,7 @@

<entry>
<id>periscope:broadcast:<%= post["id"] %><%= ":#{params[:cachebuster]}" if params[:cachebuster] %></id>
<title><%= post["status"].to_line.esc %></title>
<title><%= post["status"].or("No title").to_line.esc %></title>
<link href="https://www.periscope.tv/<%= "#{post["username"]}/#{post["id"]}" %>" />
<updated><%= Time.parse(post["created_at"]) %></updated>
<author><name><%= post["user_display_name"].esc %></name></author>
Expand Down

0 comments on commit 7125248

Please sign in to comment.