forked from asanderson15/rails-angular-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added code for part 2 of the tutorial.
- Loading branch information
1 parent
8a2f578
commit 350589f
Showing
194 changed files
with
52,428 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | ||
gem 'rails', '4.0.0.rc2' | ||
|
||
gem 'pg' | ||
|
||
# Gems used only for assets and not required | ||
# in production environments by default. | ||
group :assets do | ||
gem 'sass-rails', '~> 4.0.0.rc2' | ||
gem 'coffee-rails', '~> 4.0.0.rc2' | ||
gem 'bootstrap-sass', '~> 2.3.1.0' | ||
|
||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes | ||
# gem 'therubyracer', platforms: :ruby | ||
|
||
gem 'uglifier', '>= 1.0.3' | ||
end | ||
|
||
gem 'jquery-rails' | ||
|
||
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks | ||
gem 'turbolinks' | ||
|
||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder | ||
gem 'jbuilder', '~> 1.0.1' | ||
|
||
# To use ActiveModel has_secure_password | ||
# gem 'bcrypt-ruby', '~> 3.0.0' | ||
|
||
# Use unicorn as the app server | ||
# gem 'unicorn' | ||
|
||
# Deploy with Capistrano | ||
# gem 'capistrano', group: :development | ||
|
||
# To use debugger | ||
# gem 'debugger' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actionmailer (4.0.0.rc2) | ||
actionpack (= 4.0.0.rc2) | ||
mail (~> 2.5.3) | ||
actionpack (4.0.0.rc2) | ||
activesupport (= 4.0.0.rc2) | ||
builder (~> 3.1.0) | ||
erubis (~> 2.7.0) | ||
rack (~> 1.5.2) | ||
rack-test (~> 0.6.2) | ||
activemodel (4.0.0.rc2) | ||
activesupport (= 4.0.0.rc2) | ||
builder (~> 3.1.0) | ||
activerecord (4.0.0.rc2) | ||
activemodel (= 4.0.0.rc2) | ||
activerecord-deprecated_finders (~> 1.0.2) | ||
activesupport (= 4.0.0.rc2) | ||
arel (~> 4.0.0) | ||
activerecord-deprecated_finders (1.0.3) | ||
activesupport (4.0.0.rc2) | ||
i18n (~> 0.6, >= 0.6.4) | ||
minitest (~> 4.2) | ||
multi_json (~> 1.3) | ||
thread_safe (~> 0.1) | ||
tzinfo (~> 0.3.37) | ||
arel (4.0.0) | ||
atomic (1.1.9) | ||
bootstrap-sass (2.3.1.0) | ||
sass (~> 3.2) | ||
builder (3.1.4) | ||
coffee-rails (4.0.0) | ||
coffee-script (>= 2.2.0) | ||
railties (>= 4.0.0.beta, < 5.0) | ||
coffee-script (2.2.0) | ||
coffee-script-source | ||
execjs | ||
coffee-script-source (1.6.2) | ||
erubis (2.7.0) | ||
execjs (1.4.0) | ||
multi_json (~> 1.0) | ||
hike (1.2.3) | ||
i18n (0.6.4) | ||
jbuilder (1.0.2) | ||
activesupport (>= 3.0.0) | ||
jquery-rails (2.2.1) | ||
railties (>= 3.0, < 5.0) | ||
thor (>= 0.14, < 2.0) | ||
mail (2.5.4) | ||
mime-types (~> 1.16) | ||
treetop (~> 1.4.8) | ||
mime-types (1.23) | ||
minitest (4.7.4) | ||
multi_json (1.7.7) | ||
pg (0.15.1) | ||
polyglot (0.3.3) | ||
rack (1.5.2) | ||
rack-test (0.6.2) | ||
rack (>= 1.0) | ||
rails (4.0.0.rc2) | ||
actionmailer (= 4.0.0.rc2) | ||
actionpack (= 4.0.0.rc2) | ||
activerecord (= 4.0.0.rc2) | ||
activesupport (= 4.0.0.rc2) | ||
bundler (>= 1.3.0, < 2.0) | ||
railties (= 4.0.0.rc2) | ||
sprockets-rails (~> 2.0.0) | ||
railties (4.0.0.rc2) | ||
actionpack (= 4.0.0.rc2) | ||
activesupport (= 4.0.0.rc2) | ||
rake (>= 0.8.7) | ||
thor (>= 0.18.1, < 2.0) | ||
rake (10.0.4) | ||
sass (3.2.8) | ||
sass-rails (4.0.0.rc2) | ||
railties (>= 4.0.0.beta, < 5.0) | ||
sass (>= 3.1.10) | ||
sprockets-rails (~> 2.0.0) | ||
sprockets (2.10.0) | ||
hike (~> 1.2) | ||
multi_json (~> 1.0) | ||
rack (~> 1.0) | ||
tilt (~> 1.1, != 1.3.0) | ||
sprockets-rails (2.0.0) | ||
actionpack (>= 3.0) | ||
activesupport (>= 3.0) | ||
sprockets (~> 2.8) | ||
thor (0.18.1) | ||
thread_safe (0.1.0) | ||
atomic | ||
tilt (1.4.1) | ||
treetop (1.4.14) | ||
polyglot | ||
polyglot (>= 0.3.1) | ||
turbolinks (1.1.1) | ||
coffee-rails | ||
tzinfo (0.3.37) | ||
uglifier (2.0.1) | ||
execjs (>= 0.3.0) | ||
multi_json (~> 1.0, >= 1.0.2) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bootstrap-sass (~> 2.3.1.0) | ||
coffee-rails (~> 4.0.0.rc2) | ||
jbuilder (~> 1.0.1) | ||
jquery-rails | ||
pg | ||
rails (= 4.0.0.rc2) | ||
sass-rails (~> 4.0.0.rc2) | ||
turbolinks | ||
uglifier (>= 1.0.3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
== README | ||
|
||
This README would normally document whatever steps are necessary to get the | ||
application up and running. | ||
|
||
Things you may want to cover: | ||
|
||
* Ruby version | ||
|
||
* System dependencies | ||
|
||
* Configuration | ||
|
||
* Database creation | ||
|
||
* Database initialization | ||
|
||
* How to run the test suite | ||
|
||
* Services (job queues, cache servers, search engines, etc.) | ||
|
||
* Deployment instructions | ||
|
||
* ... | ||
|
||
|
||
Please feel free to use a different markup language if you do not plan to run | ||
<tt>rake doc:app</tt>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
|
||
Blog::Application.load_tasks |
7 changes: 7 additions & 0 deletions
7
part-2/app/assets/javascripts/Controllers/main/mainIndexCtrl.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@IndexCtrl = ($scope, $location) -> | ||
|
||
$scope.data = | ||
posts: [{title: 'My first post', contents: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec laoreet lobortis vulputate. Ut tempus, orci eu tempor sagittis, mauris orci ultrices arcu, in volutpat elit elit semper turpis. Maecenas id lorem quis magna lacinia tincidunt. In libero magna, pharetra in hendrerit vitae, luctus ac sem. Nulla velit augue, vestibulum a egestas et, imperdiet a lacus. Nam mi est, vulputate eu sollicitudin sed, convallis vel turpis. Cras interdum egestas turpis, ut vestibulum est placerat a. Proin quam tellus, cursus et aliquet ut, adipiscing id lacus. Aenean iaculis nulla justo.'}, {title: 'A walk down memory lane', contents: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin leo sem, imperdiet in faucibus et, feugiat ultricies tellus. Vivamus pellentesque iaculis dolor, sed pellentesque est dignissim vitae. Donec euismod purus non metus condimentum porttitor suscipit nibh tempor. Etiam malesuada elit in lectus pharetra facilisis. Fusce at nisl augue. Donec at est felis. Sed a gravida diam. Nunc nunc mi, egestas non dignissim et, porta aliquam ante.'}] | ||
|
||
$scope.viewPost = (postId) -> | ||
$location.url('/post/'+postId) |
7 changes: 7 additions & 0 deletions
7
part-2/app/assets/javascripts/Controllers/main/mainPostCtrl.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@PostCtrl = ($scope, $routeParams) -> | ||
|
||
$scope.data = | ||
post: {title: 'My first post', contents: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec laoreet lobortis vulputate. Ut tempus, orci eu tempor sagittis, mauris orci ultrices arcu, in volutpat elit elit semper turpis. Maecenas id lorem quis magna lacinia tincidunt. In libero magna, pharetra in hendrerit vitae, luctus ac sem. Nulla velit augue, vestibulum a egestas et, imperdiet a lacus. Nam mi est, vulputate eu sollicitudin sed, convallis vel turpis. Cras interdum egestas turpis, ut vestibulum est placerat a. Proin quam tellus, cursus et aliquet ut, adipiscing id lacus. Aenean iaculis nulla justo.'} | ||
|
||
$scope.data.postId = $routeParams.postId | ||
console.log($routeParams) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This is a manifest file that'll be compiled into application.js, which will include all the files | ||
// listed below. | ||
// | ||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, | ||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. | ||
// | ||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | ||
// compiled file. | ||
// | ||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD | ||
// GO AFTER THE REQUIRES BELOW. | ||
// | ||
//= require jquery | ||
//= require jquery_ujs | ||
//= require underscore | ||
//= require bootstrap | ||
//= require angular |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ | ||
|
||
#= require_self | ||
#= require_tree ./Controllers/main | ||
#= require_tree ./Directives/main | ||
#= require_tree ./Filters/main | ||
#= require_tree ./Services/main | ||
|
||
# Creates new Angular module called 'Blog' | ||
Blog = angular.module('Blog', []) | ||
|
||
# Sets up routing | ||
Blog.config(['$routeProvider', ($routeProvider) -> | ||
# Route for '/post' | ||
$routeProvider.when('/post/:postId', { templateUrl: '../assets/mainPost.html', controller: 'PostCtrl' } ) | ||
|
||
# Default | ||
$routeProvider.otherwise({ templateUrl: '../assets/mainIndex.html', controller: 'IndexCtrl' } ) | ||
|
||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* This is a manifest file that'll be compiled into application.css, which will include all the files | ||
* listed below. | ||
* | ||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, | ||
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. | ||
* | ||
* You're free to add application-wide styles to this file and they'll appear at the top of the | ||
* compiled file, but it's generally better to create a new file per style scope. | ||
* | ||
*= require_self | ||
*= require_tree . | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Place all the styles related to the Main controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ | ||
|
||
@import "bootstrap"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1 class="text-center">My blog</h1> | ||
<div class="row" ng-repeat="post in data.posts"> | ||
<h2><a ng-click="viewPost($index)">{{post.title}}</a></h2> | ||
<p>{{post.contents}}</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<h1 class="text-center">{{data.postId}} - {{data.post.title}}</h1> | ||
<div class="row"> | ||
<p>{{data.post.contents}}</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ApplicationController < ActionController::Base | ||
# Prevent CSRF attacks by raising an exception. | ||
# For APIs, you may want to use :null_session instead. | ||
protect_from_forgery with: :exception | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class MainController < ApplicationController | ||
def index | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ApplicationHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module MainHelper | ||
end |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html ng-app="Blog"> | ||
<head> | ||
<title>Blog</title> | ||
<%= stylesheet_link_tag "application", media: "all" %> | ||
<%= javascript_include_tag "application", controller_name %> | ||
<%= csrf_meta_tags %> | ||
</head> | ||
<body> | ||
|
||
<%= yield %> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div class="container" ng-view> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env ruby | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | ||
load Gem.bin_path('bundler', 'bundle') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
APP_PATH = File.expand_path('../../config/application', __FILE__) | ||
require_relative '../config/boot' | ||
require 'rails/commands' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
require_relative '../config/boot' | ||
require 'rake' | ||
Rake.application.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This file is used by Rack-based servers to start the application. | ||
|
||
require ::File.expand_path('../config/environment', __FILE__) | ||
run Blog::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require File.expand_path('../boot', __FILE__) | ||
|
||
# Pick the frameworks you want: | ||
require "active_record/railtie" | ||
require "action_controller/railtie" | ||
require "action_mailer/railtie" | ||
require "sprockets/railtie" | ||
# require "rails/test_unit/railtie" | ||
|
||
# Assets should be precompiled for production (so we don't need the gems loaded then) | ||
Bundler.require(*Rails.groups(assets: %w(development test))) | ||
|
||
module Blog | ||
class Application < Rails::Application | ||
# Settings in config/environments/* take precedence over those specified here. | ||
# Application configuration should go into files in config/initializers | ||
# -- all .rb files in that directory are automatically loaded. | ||
|
||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. | ||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. | ||
# config.time_zone = 'Central Time (US & Canada)' | ||
|
||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. | ||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] | ||
# config.i18n.default_locale = :de | ||
|
||
# Needed for Bootstrap-Sass gem | ||
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Set up gems listed in the Gemfile. | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | ||
|
||
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) |
Oops, something went wrong.