Skip to content

Commit

Permalink
Added Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris committed Jan 19, 2011
1 parent fc355c5 commit 01b106d
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 43 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ gem 'rails', '3.0.3'
gem 'sqlite3-ruby', '1.3.2', :require => 'sqlite3', :group => :development
gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '3.0.pre2'
gem 'maruku'

group :development do
gem 'rspec-rails', '2.3.0'
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
maruku (0.6.0)
syntax (>= 1.0.0)
mime-types (1.16)
nokogiri (1.4.4.1-x86-mingw32)
polyglot (0.3.1)
Expand Down Expand Up @@ -82,6 +84,7 @@ GEM
railties (~> 3.0)
rspec (~> 2.3.0)
sqlite3-ruby (1.3.2-x86-mingw32)
syntax (1.0.0)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
Expand All @@ -100,6 +103,7 @@ DEPENDENCIES
factory_girl_rails (= 1.0)
faker (= 0.3.1)
gravatar_image_tag (= 1.0.0.pre2)
maruku
rails (= 3.0.3)
rspec (= 2.3.0)
rspec-rails (= 2.3.0)
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/blogs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
class BlogsController < ApplicationController

def destroy
redirect_to root_path unless signed_in?
@blog = Blog.find(params[:id])
@blog.destroy
redirect_to blogs_path, :flash => { :success => "Blog deleted!" }
end
end
3 changes: 2 additions & 1 deletion app/controllers/microposts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class MicropostsController < ApplicationController
def create
success_message = "Micropost created!"
@micropost = current_user.microposts.build(params[:micropost])

puts params[:micropost]

if Blog.is_blog_post? params[:micropost][:content]
current_user.blogs.create_with_post params[:micropost][:content]
success_message = "Blog created!"
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def create
@user = User.new(params[:user])
if @user.save
sign_in @user
redirect_to @user, :flash => { :success => "Welcome to the Sample App!" }
@user.follow_all
redirect_to @user, :flash => { :success => "Welcome to the Sample App!" }
else
@title = "Sign up"
render 'new'
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ApplicationHelper

# Return a title on a per-page basis.
def title
base_title = "Ruby on Rails Tutorial Sample App"
base_title = "Geronimo!"
if @title.nil?
base_title
else
Expand Down
17 changes: 9 additions & 8 deletions app/models/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@
# updated_at :datetime
#

require 'maruku'

class Blog < ActiveRecord::Base

belongs_to :user

def to_html
doc = Maruku.new(blogtext)
doc.to_html
end

class << self
def latest_for_frontpage
self.where(:frontpage => true).last
Expand All @@ -32,14 +39,8 @@ def new_from_post(post)
end
end

def get_blog_text(post)
post_array = post.split()
if(is_front_page? post)
post_array.shift(2)
else
post_array.shift(1)
end
post_array.join(' ')
def get_blog_text(post)
post.gsub(/blog\sfrontpage\s|blog\s/, '')
end

def is_blog_post?(post)
Expand Down
12 changes: 8 additions & 4 deletions app/models/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

class Show < ActiveRecord::Base


def to_html
doc = Maruku.new(showtext)
doc.to_html
end

class << self

def next_show()
Expand Down Expand Up @@ -74,9 +80,7 @@ def get_date(post)
end

def get_show_text(post)
post_array = post.split()
post_array.shift(1)
post_array.join(' ')
post.gsub(/^show\s/,'')
end
end
end
end
9 changes: 9 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def follow!(followed)
def unfollow!(followed)
relationships.find_by_followed_id(followed).destroy
end

def follow_all
User.all.each { |u|
if u != self
u.follow! (self)
self.follow! (u)
end
}
end

class << self
def authenticate(email, submitted_password)
Expand Down
2 changes: 1 addition & 1 deletion app/views/blogs/_blog.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="blogContainer round">
<article>
<%= blog.blogtext %>
<%= raw blog.to_html %>
</article>

<span>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<header>
<%= link_to logo, root_path %>
<%= link_to "Geronimo!", root_path, :class => "BandName" %>
<nav class="round">
<ul>
<li><%= link_to "Home", home_path %></li>
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/_stylesheets.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>
<!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]-->
<%= stylesheet_link_tag 'custom', :media => 'screen' %>
<%= stylesheet_link_tag 'custom', :media => 'screen' %>
<%= stylesheet_link_tag 'geronimo', :media => 'screen' %>
3 changes: 0 additions & 3 deletions app/views/microposts/_micropost.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<% user = micropost.user rescue User.find(micropost.user_id) %>
<% if current_user?(user) %>
<td>
<%= link_to "delete", micropost, :method => :delete,
:confirm => "You sure?",
:title => micropost.content %>
</td>
<% end %>
</tr>
3 changes: 0 additions & 3 deletions app/views/shared/_feed_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
</td>
<% if current_user?(feed_item.user) %>
<td>
<%= link_to "delete", feed_item, :method => :delete,
:confirm => "You sure?",
:title => feed_item.content %>
</td>
<% end %>
</tr>
19 changes: 1 addition & 18 deletions app/views/shared/_stats.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
<% @user ||= current_user %>
<div class="stats">
<table summary="User stats">
<tr>
<td>
<a href="<%= following_user_path(@user) %>">
<span id="following" class="stat">
<%= @user.following.count %> following
</span>
</a>
</td>
<td>
<a href="<%= followers_user_path(@user) %>">
<span id="followers" class="stat">
<%= pluralize(@user.followers.count, "follower") %>
</span>
</a>
</td>
</tr>
</table>
<!-- Removing stats. Different feeds are not necessary currently. -->
</div>
2 changes: 1 addition & 1 deletion app/views/shows/_show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div>

<span class="show">*&nbsp;<%= show.showtext %></span>
<span class="show">*&nbsp;<%= raw show.to_html %></span>


<% if signed_in? %>
Expand Down
16 changes: 16 additions & 0 deletions public/stylesheets/geronimo.css
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ a:hover {
margin: 5px;
}

.show p{

display: inline;
}


nav {
padding: 0 0.7em;
Expand Down Expand Up @@ -243,4 +248,15 @@ nav ul li a:hover {
margin: 10px;
background-color: orange;
width: 760px;
}

.blogContainer p
{
display: inline;
}

.blogContainer h1, h2, h3, h4, h5, h6
{
margin-top: 4px;
margin-bottom: 4px;
}

0 comments on commit 01b106d

Please sign in to comment.