Permalink
Browse files

added the ability to edit files locally using "http://local.localhost…

…:4567" and putting files in ./local of the repo (now git ignored)
  • Loading branch information...
1 parent 846d1c1 commit 9e498f6e9a21192e06436f1428ef68092b68933b @geelen committed Jun 12, 2012
Showing with 6 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +5 −1 server.rb
View
@@ -1,3 +1,4 @@
bin
.bundle
+local
View
@@ -42,7 +42,11 @@ def pull_from_gist(filename)
end
def files
- @files ||= JSON.parse(fetch("https://api.github.com/gists/#{gist_id}")).fetch('files')
+ @files ||= if gist_id == 'local'
+ Hash[*Dir.glob(File.dirname(__FILE__) + "/local/*").map { |f| [File.basename(f),{'content' => File.read(f)}] }.flatten]
+ else
+ JSON.parse(fetch("https://api.github.com/gists/#{gist_id}")).fetch('files')
+ end
rescue KeyError
{}
end

0 comments on commit 9e498f6

Please sign in to comment.