Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

several new scripts to improve workflow

  • Loading branch information...
commit f84ab76e32cf77a6d77f137a6c70a52d4c1d3619 1 parent 77a0d97
@ryanb authored
View
2  LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2011 Ryan Bates
+Copyright (c) 2012 Ryan Bates
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
4 README.md
@@ -2,7 +2,9 @@
Scripts used in the production of RailsCasts. http://railscasts.com/
-These scripts do the following:
+This is designed to be used as a plugin for [Oh My ZSH](https://github.com/robbyrussell/oh-my-zsh). To add it, symlink the project directory into `~/.oh-my-zsh/custom/plugins` and add it to your `.zshrc` file.
+
+**These scripts do the following:**
1. Generate a new project directory with the proper templates
View
5 bin/rcapp
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Generate a new Rails app for RailsCasts
+
+rails new $* -m "$(dirname $0)/../templates/rails_template.rb"
View
9 bin/rcencode
@@ -9,12 +9,17 @@ class RailsCastsEncoder
def initialize(path)
@source = File.expand_path(path)
@name = File.basename(@source, ".*")
- @out_dir = "#{File.dirname(@source)}/compressed"
+ if File.exist? "#{File.dirname(@source)}/upload/pro"
+ @out_dir = "#{File.dirname(@source)}/upload/pro/videos"
+ else
+ @out_dir = "#{File.dirname(@source)}/upload/videos"
+ end
end
def process
+ FileUtils.mkdir_p(@out_dir)
compress "mp4" do |input, output|
- run "HandBrakeCLI -i '#{input}' -o '#{output}' -e x264 -b 300 -a 1 -E ca_aac -B 96 -6 mono -R Auto -D 0.0 -f mp4 -r 30 --strict-anamorphic -O -x 'b-adapt=2:rc-lookahead=50'"
+ run "HandBrakeCLI -i '#{input}' -o '#{output}' -e x264 -b 300 -a 1 -E ca_aac -B 96 -6 mono -R Auto -D 0.0 -f mp4 -r 30 --strict-anamorphic -O -x 'cabac=0:ref=2:me=umh:bframes=0:weightp=0:subq=6:8x8dct=0:trellis=0'"
end
compress "m4v" do |input, output|
run "HandBrakeCLI -i '#{input}' -o '#{output}' -e x264 -q 20.0 -a 1 -E ca_aac -B 96 -6 mono -R Auto -D 0.0 -f mp4 -X 640 -O -x 'cabac=0:ref=2:me=umh:bframes=0:weightp=0:subq=6:8x8dct=0:trellis=0'"
View
43 bin/rcnew
@@ -1,12 +1,43 @@
#!/usr/bin/env ruby
# Creates a new project directory given an episode name.
-# rcnew '123 Some Episode'
+# rcnew 123 'Some Episode'
require "fileutils"
+require "erb"
-name = $*.join(" ")
-path = name.downcase.gsub(/[^0-9a-z]+/, ' ').strip.gsub(' ', '-')
-FileUtils.mkdir(path)
-FileUtils.mkdir("#{path}/edit")
-FileUtils.mkdir("#{path}/compressed")
+class EpisodeGenerator
+ attr_reader :number, :name
+
+ def initialize(number, name)
+ @number = number.to_i
+ @name = name
+ end
+
+ def run
+ FileUtils.cp_r(template_path, path)
+ Dir["#{path}/**/*.erb"].each do |erb|
+ result = ERB.new(File.read(erb)).result(binding)
+ File.write(erb.sub(/\.erb$/, ""), result)
+ FileUtils.rm(erb)
+ end
+ end
+
+ def dirname
+ [number, *@name.downcase.gsub(/[^0-9a-z]+/, " ").split].join("-")
+ end
+
+ def path
+ File.join(ENV["RAILSCASTS"], dirname)
+ end
+
+ def template_path
+ File.join(ENV["RAILSCASTS"], "template-#{pro? ? 'pro' : 'free'}")
+ end
+
+ def pro?
+ dirname =~ /revised$/ || @number % 2 > 0
+ end
+end
+
+EpisodeGenerator.new(*$*).run
View
37 bin/rcpush
@@ -0,0 +1,37 @@
+#!/usr/bin/env ruby
+
+# Push code to railscasts repository
+# rcpush
+
+require "rubygems"
+require "rest_client" # gem install rest-client
+
+class EpisodePusher
+ attr_reader :name
+
+ def initialize
+ @name = `pwd`[/\/([0-9]+-.+)\//, 1]
+ end
+
+ def run
+ create_repo
+ push
+ end
+
+ def create_repo
+ options = {login: ENV["GITHUB_USER"], token: ENV["GITHUB_TOKEN"], :name => "railscasts/#{name}", public: 1}
+ RestClient.post("https://github.com/api/v2/json/repos/create", options)
+ end
+
+ def push
+ system <<-COMMANDS
+ git init
+ git add .
+ git commit -m 'initial commit'
+ git remote add origin git@github.com:railscasts/#{name}.git
+ git push -u origin master
+ COMMANDS
+ end
+end
+
+EpisodePusher.new.run
View
5 bin/rcupload
@@ -10,7 +10,8 @@ def run(command)
system(command)
end
-path = ($*.first || ".") + "/compressed/*"
+path = ($*.first || ".") + "/upload/**/*.*"
Dir[path].each do |file|
- run "scp '#{file}' media.railscasts.com:/home/rbates/media.railscasts.com/assets/episodes/videos/"
+ run "scp '#{file}' media.railscasts.com:/home/rbates/media.railscasts.com/assets/episodes/#{file.sub('./upload/', '')}"
+ run "scp '#{file}' railscasts.com:~/code/railscasts/shared/assets/episodes/stills/" if file =~ /stills\/.*\.png/
end
View
8 railscasts.plugin.zsh
@@ -0,0 +1,8 @@
+export RAILSCASTS="$HOME/Projects/RailsCasts/Episodes"
+
+rc() { cd $RAILSCASTS/$1; }
+_rc() { _files -W $RAILSCASTS -/; }
+compdef _rc rc
+
+# add plugin's bin directory to path
+export PATH="$(dirname $0)/bin:$PATH"
View
11 templates/README.md
@@ -0,0 +1,11 @@
+# RailsCasts Example Application
+
+Run these commands to try it out.
+
+```
+bundle
+rake db:setup
+rails s
+```
+
+Requires Ruby 1.9.2 or later to run.
View
17 templates/application.html.erb
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Example</title>
+ <%= stylesheet_link_tag "application", media: "all" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tag %>
+ </head>
+ <body>
+ <div id="container">
+ <% flash.each do |name, msg| %>
+ <%= content_tag :div, msg, id: "flash_#{name}" %>
+ <% end %>
+ <%= yield %>
+ </div>
+ </body>
+</html>
View
79 templates/layout.css.scss
@@ -0,0 +1,79 @@
+html, body {
+ background-color: #4B7399;
+ font-family: Verdana, Helvetica, Arial;
+ font-size: 14px;
+}
+
+a img {
+ border: none;
+}
+
+a {
+ color: #0000FF;
+}
+
+.clear {
+ clear: both;
+ height: 0;
+ overflow: hidden;
+}
+
+#container {
+ width: 80%;
+ margin: 0 auto;
+ background-color: #FFF;
+ padding: 20px 40px;
+ border: solid 1px black;
+ margin-top: 20px;
+}
+
+#flash_notice, #flash_error, #flash_alert {
+ padding: 5px 8px;
+ margin: 10px 0;
+}
+
+#flash_notice {
+ background-color: #CFC;
+ border: solid 1px #6C6;
+}
+
+#flash_error, #flash_alert {
+ background-color: #FCC;
+ border: solid 1px #C66;
+}
+
+.field_with_errors {
+ display: inline;
+}
+
+.error_messages {
+ width: 400px;
+ border: 2px solid #CF0000;
+ padding: 0px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ font-size: 12px;
+}
+
+.error_messages h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 10px;
+ font-size: 12px;
+ margin: 0;
+ background-color: #c00;
+ color: #fff;
+}
+
+.error_messages p {
+ margin: 8px 10px;
+}
+
+.error_messages ul {
+ margin-bottom: 0;
+}
+
+form .field, form .actions {
+ margin: 12px 0;
+}
View
12 templates/rails_template.rb
@@ -0,0 +1,12 @@
+def template(from, to = nil)
+ to ||= from
+ remove_file to
+ file to, File.read(File.expand_path("../#{from}", __FILE__))
+end
+
+remove_file "app/assets/images/rails.png"
+remove_file "public/index.html"
+remove_file "README.rdoc"
+template "README.md"
+template "layout.css.scss", "app/assets/stylesheets/layout.css.scss"
+template "application.html.erb", "app/views/layouts/application.html.erb"
Please sign in to comment.
Something went wrong with that request. Please try again.