Skip to content

Commit

Permalink
Changing language to Twetter and Twet
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvt committed Oct 31, 2013
1 parent c160c92 commit 5ee724b
Show file tree
Hide file tree
Showing 34 changed files with 169 additions and 160 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
twitter-clone
Twetter
=============

This is the sample Twitter Clone code base for Thinkful's Ruby on Rails course.
This is the sample version of Twetter, a basic clone of the most popular micro-blogging site, produced for Thinkful's Ruby on Rails course.

Before Beginning
-------------
Expand All @@ -24,15 +24,15 @@ Getting Started

```sh
# Clone the repository
git clone [email protected]:Thinkful/twitter-clone.git
git clone [email protected]:Thinkful/twetter.git

cd ./twitter-clone
cd ./twetter

# Install the required gems
bundle install

# Generate a new config/initializers/secret_token.rb file.
echo "TwitterClone::Application.config.secret_key_base = '`bundle exec rake secret`'" > config/initializers/secret_token.rb
echo "Twetter::Application.config.secret_key_base = '`bundle exec rake secret`'" > config/initializers/secret_token.rb

# Set up the database
bundle exec rake db:create db:migrate db:test:prepare
Expand All @@ -50,7 +50,7 @@ Seeds

```sh
bundle exec rake seed:users # Create 20 users
bundle exec rake seed:tweets # Create 5 tweets for each user
bundle exec rake seed:twets # Create 5 twets for each user
```

If you'd like to log in as one of your recently seeded users, use the rails console to
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

require File.expand_path('../config/application', __FILE__)

TwitterClone::Application.load_tasks
Twetter::Application.load_tasks
Binary file added app/assets/images/twetter-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
4 changes: 2 additions & 2 deletions app/assets/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ nav {
}

.bird-topbar-blue {
background-image: url(../assets/twitter_web_sprite_icons.png);
background-position: -80px 0;
background-image: url(../assets/twetter-logo.png);
background-position: 0 0;
width: 24px;
height: 21px;
float: left;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Place all the styles related to the Tweets controller here.
// Place all the styles related to the Twets controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
57 changes: 0 additions & 57 deletions app/controllers/tweets_controller.rb

This file was deleted.

57 changes: 57 additions & 0 deletions app/controllers/twets_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
class TwetsController < ApplicationController
# All actions in this controller require the presence of an authenticated user.
before_filter :authenticate_user!

# GET /twets
#
# This action uses the #get_twets method to set the @twets instance variable.
#
# @twets # => All twets defaultly shown to the authenticated user.
#
def index
get_twets
end

# POST /twets
#
# Used to create a new twet for the authenticated user based on the data passed
# in params[:twet]. If the twet is created successfully, a success message is
# set and we are directed to the index action. Otherwise, an error message is set,
# the twets visible to the authenticated user are loaded into @twets and the index
# view template is displayed.
#
# @twet # => The newly created (or attempted) twet.
# @twets # => (only set if the twet was not created) All twets defaultly shown
# to the authenticated user.
#
#
def create
@twet = current_user.twets.create(twet_params)
if @twet.valid?
flash[:success] = "Your twet was shared"
redirect_to :action => :index and return
else
get_twets
flash[:error] = "Your twet could not be saved"
render :action => :index and return
end
end

private

# Sets the @twets instance variable to all twets viewable by the current user
def get_twets
@twets = current_user.all_twets
end

# http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters
#
# This method uses Strong Parameters to ensure that the data passed by the user
# is appropriate. If params[:twet] does not exist or contains any key / value
# pairs other then :content, an error will be raised and the page will return
# a 400 'Bad Request' HTML response code.
#
def twet_params
params.require(:twet).permit(:content)
end
end
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def active_class(name)
case name
when "Follow" then
controller_name == 'follows' ? 'active' : ''
when "Tweet" then
controller_name == 'tweets' ? 'active' : ''
when "Twet" then
controller_name == 'twets' ? 'active' : ''
end
end

Expand Down
2 changes: 0 additions & 2 deletions app/helpers/tweets_helper.rb

This file was deleted.

2 changes: 2 additions & 0 deletions app/helpers/twets_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module TwetsHelper
end
6 changes: 3 additions & 3 deletions app/models/tweet.rb → app/models/twet.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class Tweet < ActiveRecord::Base
class Twet < ActiveRecord::Base
belongs_to :user

validates :content, :presence => true, :length => { :minimum => 2, :maximum => 140 }
validates :user, :presence => true

# Gets all tweets made by the users referenced by the ids passed, starting with the
# most recent tweet made.
# Gets all twets made by the users referenced by the ids passed, starting with the
# most recent twet made.
#
def self.by_user_ids(*ids)
where(:user_id => ids.flatten.compact.uniq).order('created_at DESC')
Expand Down
8 changes: 4 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable

has_many :follows
has_many :tweets
has_many :twets

validates :name, :presence => true
validates :username, :presence => true, :uniqueness => true
Expand All @@ -15,10 +15,10 @@ def self.all_except(user)
User.where(arel_table[:id].not_eq(user.id)).order(:name)
end

# Leverages Tweet.by_user_ids to return all tweets created by this user
# Leverages Twet.by_user_ids to return all twets created by this user
# and all users that this user follows.
#
def all_tweets
Tweet.by_user_ids(id, *follows.map(&:following_id))
def all_twets
Twet.by_user_ids(id, *follows.map(&:following_id))
end
end
2 changes: 1 addition & 1 deletion app/views/follows/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="panel panel-default col-md-8 text-left">
<div class="pull-left">
<h4>Who to follow</h4>
<p class="text-muted">Twitter accounts in alpabetical order.</p>
<p class="text-muted">Twetter accounts in alpabetical order.</p>
</div>
<div class="clearfix"></div>
<hr />
Expand Down
4 changes: 2 additions & 2 deletions app/views/home/_sign_up.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="row">
<div class="col-md-4 col-md-offset-4 panel panel-default">
<div class="pull-left">
<h4>New to Twitter? <span>Sign up</span></h4>
<h4>New to Twetter? <span>Sign up</span></h4>
</div>
<div class="clearfix"></div>
<hr />
Expand Down Expand Up @@ -31,7 +31,7 @@
<% end %>

<div class="form-group tall">
<%= f.submit "Sign up for Twitter", :class => "btn btn-warning pull-right" %>
<%= f.submit "Sign up for Twetter", :class => "btn btn-warning pull-right" %>
</div>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Twitter Clone</title>
<title>Twetter</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
Expand Down
12 changes: 6 additions & 6 deletions app/views/shared/_left_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<tbody>
<tr>
<td>
<%= content_tag :h4, current_user.tweets.count %>
<%= content_tag :small, 'Tweets', :class => "uppercase lighter" %>
<%= content_tag :h4, current_user.twets.count %>
<%= content_tag :small, 'Twets', :class => "uppercase lighter" %>
</td>
<td>
<%= content_tag :h4, current_user.follows.count %>
Expand All @@ -26,23 +26,23 @@
</table>
</li>
<li>
<%= form_for (@tweet || :tweet), :url => tweets_path,
<%= form_for (@twet || :twet), :url => twets_path,
:builder => InlineErrorsBuilder,
:method => :POST,
:role => :form do |f| %>
<div class="mar-top-15">
<%= content_tag :div, :class => f.validation_class(:content, "form-group") do %>
<%= f.text_area :content, :placeholder => "Compose new Tweet...", :class => 'form-control' %>
<%= f.text_area :content, :placeholder => "Compose new Twet...", :class => 'form-control' %>
<%= f.errors_for :content %>
<% end %>

<%= f.submit "Tweet", :class => "btn btn-primary pull-right" %>
<%= f.submit "Twet", :class => "btn btn-primary pull-right" %>
</div>
<% end %>
</ul>

<ul class="nav nav-pills nav-stacked well">
<%= nav_item("Follow", follows_path) %>
<%= nav_item("Tweet", tweets_path) %>
<%= nav_item("Twet", twets_path) %>
</ul>
</div>
26 changes: 0 additions & 26 deletions app/views/tweets/index.html.erb

This file was deleted.

26 changes: 26 additions & 0 deletions app/views/twets/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div class="clearfix top-space small"></div>
<div class="row">

<%= render :partial => 'shared/left_nav' %>

<div class="panel panel-default col-md-8 text-left">
<div class="pull-left">
<h4>Twets</h4>
</div>
<div class="clearfix"></div>
<hr />
<ol class="list-unstyled">
<% @twets.each do |twet| -%>
<li>
<%= content_tag :strong, twet.user.name, :class => 'pull-left text-middle' %>
<%= content_tag :small, "@"+twet.user.username, :class => 'text-muted pad-10 text-middle' %>
<%= content_tag :small, twet.created_at.strftime("%b %-d"), :class => 'text-muted text-middle pull-right' %>
<div class="clearfix"></div>
<%= content_tag :p, twet.content %>
</li>
<li><hr></li>
<% end -%>
</ol>
</div>
</div>

2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)

module TwitterClone
module Twetter
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
Expand Down
2 changes: 1 addition & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
TwitterClone::Application.initialize!
Twetter::Application.initialize!
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TwitterClone::Application.configure do
Twetter::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TwitterClone::Application.configure do
Twetter::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Code is not reloaded between requests.
Expand Down
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TwitterClone::Application.configure do
Twetter::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# The test environment is used exclusively to run your application's
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.

TwitterClone::Application.config.session_store :cookie_store, key: '_twitter-clone_session'
Twetter::Application.config.session_store :cookie_store, key: '_twetter_session'
Loading

0 comments on commit 5ee724b

Please sign in to comment.