Skip to content

Instantly share code, notes, and snippets.

@tundal45
Created March 28, 2012 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tundal45/2223033 to your computer and use it in GitHub Desktop.
Save tundal45/2223033 to your computer and use it in GitHub Desktop.
commit b242bf4e453f1a91703f006e9239ab0168256dd7
Author: bglusman <brian@enjyn.com>
Date: Sun Mar 18 22:21:08 2012 -0400
wiki methods on course and dryer path creation/use
diff --git a/app/models/course.rb b/app/models/course.rb
index baee48c..a98f0e3 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -9,9 +9,16 @@ class Course < ActiveRecord::Base
@people ||= course_memberships.map {|cm| cm.person }
end
+ def wiki_path
+ FileUtils.mkdir_p("wikis/#{id}/repo.git")
+ "wikis/#{id}/repo.git"
+ end
+
+ def wiki
+ @wiki ||= Gollum::Wiki.new(wiki_path)
+ end
+
def build_wiki_repo
- FileUtils.mkdir("wikis/#{id}")
- FileUtils.mkdir("wikis/#{id}/repo.git")
- Grit::Repo.new("wikis/#{id}/repo.git")
+ Grit::Repo.new(wiki_path)
end
end
###############################################
commit 62b87b91dedba41a588c95e74fced558851a6dda
Author: bglusman <brian@enjyn.com>
Date: Sun Mar 18 21:49:47 2012 -0400
working bare git repo creation per course in wikis directory
diff --git a/Gemfile b/Gemfile
index 5e5271b..f573c40 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,6 +8,7 @@ gem 'omniauth-github'
gem 'haml'
gem 'sass'
+gem 'gollum'
gem 'draper', :git => "git://github.com/jcasimir/draper.git"
diff --git a/Gemfile.lock b/Gemfile.lock
index 1cc6dac..e43fb3d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -36,6 +36,8 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.7)
+ albino (1.3.3)
+ posix-spawn (>= 0.3.6)
arel (3.0.2)
builder (3.0.0)
capybara (1.1.2)
@@ -64,6 +66,7 @@ GEM
sass (~> 3.1)
compass-rails (1.0.0.rc.3)
compass (~> 0.12.rc.0)
+ diff-lcs (1.1.3)
erubis (2.7.0)
exception_notification (2.5.2)
actionmailer (>= 3.0.4)
@@ -80,6 +83,19 @@ GEM
rack (~> 1.1)
ffi (1.0.11)
fssm (0.2.8.1)
+ github-markup (0.7.1)
+ gollum (1.3.1)
+ albino (~> 1.3.2)
+ github-markup (>= 0.4.0, < 1.0.0)
+ grit (~> 2.4.1)
+ mustache (>= 0.11.2, < 1.0.0)
+ nokogiri (~> 1.4)
+ redcarpet
+ sanitize (~> 2.0.0)
+ sinatra (~> 1.0)
+ grit (2.4.1)
+ diff-lcs (~> 1.1)
+ mime-types (~> 1.15)
haml (3.1.4)
hashie (1.2.0)
highline (1.6.11)
@@ -100,6 +116,7 @@ GEM
minitest (2.11.2)
multi_json (1.1.0)
multipart-post (1.1.5)
+ mustache (0.99.4)
nokogiri (1.5.0)
notifier (0.1.4)
oauth2 (0.5.2)
@@ -116,9 +133,12 @@ GEM
omniauth (~> 1.0)
pg (0.13.1)
polyglot (0.3.3)
+ posix-spawn (0.3.6)
rack (1.4.1)
rack-cache (1.1)
rack (>= 0.4)
+ rack-protection (1.2.0)
+ rack
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
@@ -142,8 +162,11 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
+ redcarpet (2.1.1)
ruby-progressbar (0.0.10)
rubyzip (0.9.6.1)
+ sanitize (2.0.3)
+ nokogiri (>= 1.4.4, < 1.6)
sass (3.1.15)
sass-rails (3.2.4)
railties (~> 3.2.0)
@@ -154,6 +177,10 @@ GEM
ffi (~> 1.0.9)
json_pure
rubyzip
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
@@ -185,6 +212,7 @@ DEPENDENCIES
draper!
exception_notification
factory_girl_rails
+ gollum
haml
highline
jquery-rails
diff --git a/app/models/course.rb b/app/models/course.rb
index 4b91529..baee48c 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -2,7 +2,16 @@ class Course < ActiveRecord::Base
has_many :discussions
has_many :course_memberships
+
+ after_create :build_wiki_repo
+
def people
@people ||= course_memberships.map {|cm| cm.person }
end
+
+ def build_wiki_repo
+ FileUtils.mkdir("wikis/#{id}")
+ FileUtils.mkdir("wikis/#{id}/repo.git")
+ Grit::Repo.new("wikis/#{id}/repo.git")
+ end
end
diff --git a/wikis/.gitkeep b/wikis/.gitkeep
new file mode 100644
index 0000000..e69de29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment