Skip to content

Instantly share code, notes, and snippets.

@plasticbugs
Created March 21, 2012 23:21
Show Gist options
  • Save plasticbugs/2154099 to your computer and use it in GitHub Desktop.
Save plasticbugs/2154099 to your computer and use it in GitHub Desktop.
Logged in as <%= @user.email %>
<div class="well">
<h1>StreetPass Messages</h1>
<% if @messages.count > 0 %>
<table class="table table-striped">
<thead>
<tr>
<th>Link</th>
<th>Comments</th>
<th>Views</th>
<th>Contents</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<% @messages.each do |m|%>
<tr>
<td><%= link_to "3dstxt.com/#{m.pickUpCode}", :controller => 'messages', :action => 'show', :pickUpCode => m.pickUpCode %></td>
<td><span class="badge badge-info"><%= "#{m.comments.count}" %></span></td>
<td><span class="badge"><%= "#{m.impressionist_count(:filter=>:ip_address)}" %></span></td>
<td WIDTH="35%">
<%= truncate m.contents, :length => 150 %>
</td>
<td><%= link_to "edit", {:controller => 'messages', :action => 'edit', :pickUpCode => m.pickUpCode} %></td>
<td><i class="icon-trash" style:"margin-left:-20px;"></i><%= link_to "delete", m, :confirm => "Are you sure you want to delete this message? Your custom URL will also be deleted! Click 'edit' to KEEP your URL and only edit the message.", :method => :delete, :alt => 'Delete' %></td>
</tr>
<% end %>
</table>
<% else %>
You have no saved messages.
<% end %>
</div>
<% if @message.errors.any? %>
<div class="alert alert-error">
<% @message.errors.full_messages.each do |msg| %>
<%= msg %>
<% end %>
</div>
<% end %>
<%= form_for(@message, :html => { :class => "form-horizontal"}) do |f| -%>
<fieldset><legend>Create a new page</legend>
<div class="control-group">
<label class="control-label">Your message</label>
<div class="controls"><%= f.text_area :contents, :class => "span7", :style => "height:250px;" %></div>
</div>
<div class="control-group">
<label class="control-label">Custom link</label>
<div class="controls"><div class="input-prepend"><span class="add-on">3dstxt.com/</span><%= f.text_field :pickUpCode, :size => "5", :maxlength => "5", :class => "span2", :id => "prependedInput" %></div>
<p class="help-block">Give this message a custom URL like <span style="color: #f00">3dstxt.com/scott</span> (5 letters max)</p>
</div>
</div>
<div class="form-actions"><%= f.submit "Create", :class => "btn btn-primary" %></div>
</fieldset>
<% end -%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment