Use asciicast title in page title

openid
Marcin Kulik 12 years ago
parent 1e2e8bfcc3
commit 8b504d8fea

@ -15,6 +15,7 @@ class AsciicastsController < ApplicationController
end end
def show def show
@title = @asciicast.smart_title
respond_with @asciicast respond_with @asciicast
end end

@ -1,15 +1,5 @@
module AsciicastsHelper module AsciicastsHelper
def asciicast_title(asciicast)
if asciicast.title.present?
asciicast.title
elsif asciicast.command.present?
"$ #{asciicast.command}"
else
"##{asciicast.id}"
end
end
def profile_link(asciicast, options = {}) def profile_link(asciicast, options = {})
if asciicast.user if asciicast.user
if options[:avatar] if options[:avatar]

@ -83,4 +83,14 @@ class Asciicast < ActiveRecord::Base
end end
end end
end end
def smart_title
if title.present?
title
elsif command.present?
"$ #{command}"
else
"##{id}"
end
end
end end

@ -1,6 +1,6 @@
<li class="asciicast-preview"> <li class="asciicast-preview">
<h3> <h3>
<%= link_to asciicast_title(asciicast), asciicast %> <%= link_to asciicast.smart_title, asciicast %>
<span class="meta"> <span class="meta">
<% if asciicast.user || asciicast.username %> <% if asciicast.user || asciicast.username %>

@ -1,6 +1,6 @@
<div class="page-header asciicast-heading"> <div class="page-header asciicast-heading">
<h1> <h1>
<span class="title"><%= asciicast_title(@asciicast) %></span> <span class="title"><%= @asciicast.smart_title %></span>
<% if current_user && @asciicast.user == current_user %> <% if current_user && @asciicast.user == current_user %>
<% if @asciicast.title.blank? %> <% if @asciicast.title.blank? %>

@ -36,7 +36,7 @@
</p> </p>
<div class="featured-asciicast"> <div class="featured-asciicast">
<h3><%= asciicast_title(@asciicast) %></h3> <h3><%= @asciicast.smart_title %></h3>
<%= render :partial => 'asciicasts/asciicast', <%= render :partial => 'asciicasts/asciicast',
:object => @asciicast, :object => @asciicast,

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>ascii.io</title> <title><% if @title %><%= @title + " - "%><% end %>ascii.io</title>
<%= airbrake_javascript_notifier %> <%= airbrake_javascript_notifier %>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>

Loading…
Cancel
Save