Skip to content

Commit

Permalink
data have been pulled out into yaml files
Browse files Browse the repository at this point in the history
  • Loading branch information
yokolet committed Aug 29, 2010
1 parent 13193dd commit 5b8dfaf
Show file tree
Hide file tree
Showing 16 changed files with 490 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@ public/images/golden_gate_bridge-s.jpg
public/images/info.txt
public/images/small_redbridge.jpg
*/*/*/.DS_Store
log
11 changes: 2 additions & 9 deletions WEB-INF/appengine-generated/datastore-indexes-auto.xml
@@ -1,11 +1,4 @@
<!-- Indices written at Fri, 27 Aug 2010 06:14:42 UTC -->
<!-- Indices written at Sun, 29 Aug 2010 04:22:50 UTC -->

<datastore-indexes>
<datastore-indexes/>

<!-- Used 15 times in query history -->
<datastore-index kind="Pages" ancestor="false" source="auto">
<property name="clue" direction="asc"/>
<property name="order" direction="asc"/>
</datastore-index>

</datastore-indexes>
Binary file modified WEB-INF/appengine-generated/local_db.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion WEB-INF/appengine-web.xml
@@ -1,6 +1,6 @@
<!-- Generated from app.yaml. Do not edit. -->
<appengine-web-app xmlns='http://appengine.google.com/ns/1.0'>
<application>application-id</application>
<application>servletgarden-point</application>
<version>1</version>
<public-root>/public</public-root>
<static-files>
Expand Down
8 changes: 0 additions & 8 deletions WEB-INF/web.xml
Expand Up @@ -8,14 +8,6 @@
<servlet-name>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-name>
<url-pattern>/remote_api/*</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<url-pattern>/remote_api/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<url-pattern>/contacts/*</url-pattern>
Expand Down
3 changes: 2 additions & 1 deletion app.yaml
@@ -1,10 +1,11 @@
application: servletgarden-point
#application: application-id
version: 1
runtime: jruby

handlers:
- url: /remote_api/*
login: admin
# login: admin
servlet: com.google.apphosting.utils.remoteapi.RemoteApiServlet

- url: /contacts/*
Expand Down
54 changes: 54 additions & 0 deletions app/controllers/slideshow_controller.rb
@@ -1,3 +1,5 @@
require 'yaml'

class SlideshowController < ApplicationController
def index
@presentations = Presentation.all
Expand Down Expand Up @@ -28,4 +30,56 @@ def dialog
end
end

def restore_pages
result = Page.restore
render :text => result.join("<br/>")
end

def restore_presentations
result = Presentation.restore
render :text => result.join("<br/>")
end

def restore_sections
result = Section.restore
render :text => result.join("<br/>")
end

def restore_snippets
result = Snippet.restore
render :text => result.join("<br/>")
end

def dump_pages
#result = YAML.dump(Page.all)
result = Page.all.collect { |page|
{:id=>page.id, :order=>page.order, :title=>page.title, :clue=>page.clue, :body=>page.body}
}
render :text => result.to_yaml
end

def dump_sections
#result = YAML.dump(Section.all)
result = Section.all.collect { |section|
{:id=>section.id, :order=>section.order, :title=>section.title, :clue=>section.clue}
}
render :text => result.to_yaml
end

def dump_snippets
#result = YAML.dump(Snippet.all)
result = Snippet.all.collect { |snippet|
{:id=>snippet.id, :name=>snippet.name, :code=>snippet.code}
}
render :text => result.to_yaml
end


def dump_presentations
#result = YAML.dump(Presentation.all)
result = Presentation.all.collect { |presentation|
{:id=>presentation.id, :title=>presentation.title, :speaker=>presentation.speaker, :conference=>presentation.conference}
}
render :text => result.to_yaml
end
end
13 changes: 13 additions & 0 deletions app/models/page.rb
Expand Up @@ -7,4 +7,17 @@ class Page
property :clue, String, :required => true, :length => 500
property :body, Text, :required => true, :lazy => false
timestamps :at


def self.restore
return ['already populated'] if Page.all(:limit => 1).size == 1
result = []
archive = YAML.load_file("vendor/data/pages.yaml")
archive.each do |entry|
m = Page.new entry
result << m.save
end
result
end

end
12 changes: 12 additions & 0 deletions app/models/presentation.rb
Expand Up @@ -6,4 +6,16 @@ class Presentation
property :speaker, String, :required => true, :length => 500
property :conference, String, :required => true, :length => 500
timestamps :at

def self.restore
return ['already populated'] if Presentation.all(:limit => 1).size == 1
result = []
archive = YAML.load_file("vendor/data/presentations.yaml")
archive.each do |entry|
m = Presentation.new entry
result << m.save
end
result
end

end
13 changes: 13 additions & 0 deletions app/models/section.rb
Expand Up @@ -6,4 +6,17 @@ class Section
property :title, String, :required => true, :length => 500
property :clue, String, :required => true, :length => 500
timestamps :at


def self.restore
return ['already populated'] if Section.all(:limit => 1).size == 1
result = []
archive = YAML.load_file("vendor/data/sections.yaml")
archive.each do |entry|
m = Section.new entry
result << m.save
end
result
end

end
12 changes: 12 additions & 0 deletions app/models/snippet.rb
Expand Up @@ -5,4 +5,16 @@ class Snippet
property :name, String, :required => true, :length => 500
property :code, Text, :required => true, :lazy => false
timestamps :at

def self.restore
return ['already populated'] if Snippet.all(:limit => 1).size == 1
result = []
archive = YAML.load_file("vendor/data/snippets.yaml")
archive.each do |entry|
m = Snippet.new entry
result << m.save
end
result
end

end
8 changes: 4 additions & 4 deletions config/routes.rb
@@ -1,9 +1,9 @@
ActionController::Routing::Routes.draw do |map|
map.resources :snippets
#map.resources :snippets

map.resources :sections
map.resources :pages
map.resources :presentations
#map.resources :sections
#map.resources :pages
#map.resources :presentations

# The priority is based upon order of creation: first created -> highest priority.

Expand Down

0 comments on commit 5b8dfaf

Please sign in to comment.