Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Too many motherboning updates to mention

  • Loading branch information...
commit edc8a5fd5d87ecf93f496754279b9413202a5712 1 parent b10a9a7
Jamie Rumbelow authored
12 app/controllers/notes_controller.rb
View
@@ -5,6 +5,12 @@ class NotesController < ApplicationController
def show
@pad = @etherpad.pad(params[:id])
@note = Note.find params[:id]
+
+ puts @note.git_file_path
+
+ unless File.exists?(@note.git_file_path)
+ @git.add(@note.relative_git_file_path).and.commit('-m "Adding lecture note ' + @note.title + ' (' + @note.course.university.name + ' - ' + @note.course.name + ')"').and.push('origin master')
+ end
end
def create
@@ -30,10 +36,14 @@ def update
# I'm sorry about this. I know it's horrible. But it's 5:40am.
def load_git
- @git = Gittastic.new(YAML::load(File.open("#{Rails.root}/config/servers.yml"))['git'])
+ @git = Gittastic.new(root_path)
end
def load_etherpad
@etherpad = EtherpadLite.connect(YAML::load(File.open("#{Rails.root}/config/servers.yml"))['etherpad'], YAML::load(File.open("#{Rails.root}/config/servers.yml"))['etherpad_api_key'])
end
+
+ def root_path
+ @root_path ||= Rails.root.to_s + YAML::load(File.open("#{Rails.root}/config/servers.yml"))['git']
+ end
end
16 app/models/note.rb
View
@@ -9,16 +9,28 @@ class Note < ActiveRecord::Base
end
def git_file_path
- YAML::load(File.open("#{Rails.root}/config/servers.yml"))['git'] + "/" + course.university.name + '/' + course.name + '/' + name + '.txt'
+ File.expand_path(root_path + "/" + course.university.name.parameterize + '/' + course.name.parameterize + '/' + title.parameterize + '.txt')
end
def relative_git_file_path
- "/" + course.university.name + '/' + course.name + '/' + name + '.txt'
+ "/" + course.university.name.parameterize + '/' + course.name.parameterize + '/' + title.parameterize + '.txt'
end
def write(content)
+ unless File.exists?(root_path + "/" + course.university.name.parameterize)
+ Dir.mkdir(root_path + "/" + course.university.name.parameterize)
+ end
+
+ unless File.exists?(root_path + "/" + course.university.name.parameterize + '/' + course.name.parameterize)
+ Dir.mkdir(root_path + "/" + course.university.name.parameterize + '/' + course.name.parameterize)
+ end
+
File.open git_file_path, 'w+' do |f|
f.puts content
end
end
+
+ def root_path
+ @root_path ||= Rails.root.to_s + YAML::load(File.open("#{Rails.root}/config/servers.yml"))['git']
+ end
end
2  app/views/home/index.html.erb
View
@@ -1,5 +1,5 @@
<form id="search" action="" method="GET">
- <input class="defaultText title-text" type="text" name="query" size="10" maxlength="100" title="Type in course name, uni or any other search queries..." />
+ <input class="defaultText title-text" type="text" name="query" autocomplete="off" size="10" maxlength="100" title="Type in course name, uni or any other search queries..." />
</form>
<div id="results">
5 db/migrate/20111113101550_add_delta_to_notes.rb
View
@@ -0,0 +1,5 @@
+class AddDeltaToNotes < ActiveRecord::Migration
+ def change
+ add_column :notes, :delta, :boolean
+ end
+end
3  db/schema.rb
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111112214000) do
+ActiveRecord::Schema.define(:version => 20111113101550) do
create_table "courses", :force => true do |t|
t.integer "university_id"
@@ -26,6 +26,7 @@
t.datetime "created_at"
t.datetime "updated_at"
t.integer "course_id"
+ t.boolean "delta"
end
create_table "notes_tags", :force => true do |t|
BIN  db/sphinx/development/note_core.spa
View
Binary file not shown
BIN  db/sphinx/development/note_core.spd
View
Binary file not shown
BIN  db/sphinx/development/note_core.sph
View
Binary file not shown
BIN  db/sphinx/development/note_core.spi
View
Binary file not shown
BIN  db/sphinx/development/note_core.spp
View
Binary file not shown
0  db/sphinx/development/note_delta.spa
View
No changes.
1  db/sphinx/development/note_delta.spd
View
@@ -0,0 +1 @@
+
BIN  db/sphinx/development/note_delta.sph
View
Binary file not shown
1  db/sphinx/development/note_delta.spi
View
@@ -0,0 +1 @@
+
0  db/sphinx/development/note_delta.spk
View
No changes.
0  db/sphinx/development/note_delta.spm
View
No changes.
1  db/sphinx/development/note_delta.spp
View
@@ -0,0 +1 @@
+
2  log/searchd.development.pid
View
@@ -1 +1 @@
-8827
+9154
Please sign in to comment.
Something went wrong with that request. Please try again.