Skip to content
This repository has been archived by the owner on Jul 17, 2018. It is now read-only.

Commit

Permalink
Serve Lookbooks and Projects without DB
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpdoyle committed Nov 13, 2014
1 parent d5b3ef9 commit bd9a514
Show file tree
Hide file tree
Showing 36 changed files with 85 additions and 33 deletions.
Binary file added app/assets/images/projects/magenta/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/13.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/projects/magenta/9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 73 additions & 2 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,78 @@
class ProjectsController < InheritedResources::Base
def index
@projects = Project.all
@projects = find_projects

render json: @projects, serializer: CachedCollectionSerializer
render json: { projects: @projects }
end

private

def find_projects
[{
id: 1,
name: "The Philadelphia Experiment",
numeral: "I",
slug: "the-philadelphia-experiment",
pages: [
{ url: image_url("the-philadelphia-experiment/1.jpg") },
{ url: image_url("the-philadelphia-experiment/2.jpg") },
{ url: image_url("the-philadelphia-experiment/3.jpg") },
{ url: image_url("the-philadelphia-experiment/4.jpg") },
{ url: image_url("the-philadelphia-experiment/5.jpg") },
{ url: image_url("the-philadelphia-experiment/6.jpg") },
{ url: image_url("the-philadelphia-experiment/7.jpg") },
{ url: image_url("the-philadelphia-experiment/8.jpg") },
{ url: image_url("the-philadelphia-experiment/9.jpg") },
{ url: image_url("the-philadelphia-experiment/10.jpg") },
{ url: vimeo_url(61014435), is_video: true },
{ url: image_url("the-philadelphia-experiment/12.jpg") },
]
}, {
id: 2,
name: "Zachary Armstrong",
numeral: "II",
slug: "zachary-armstrong",
pages: [
{ url: image_url("zachary-armstrong/1.jpg") },
{ url: image_url("zachary-armstrong/2.jpg") },
{ url: image_url("zachary-armstrong/3.jpg") },
{ url: image_url("zachary-armstrong/4.jpg") },
{ url: image_url("zachary-armstrong/5.jpg") },
{ url: image_url("zachary-armstrong/6.jpg") },
{ url: image_url("zachary-armstrong/7.jpg") },
{ url: image_url("zachary-armstrong/8.jpg") },
{ url: image_url("zachary-armstrong/9.jpg") },
{ url: vimeo_url(86785302), is_video: true },
{ url: image_url("zachary-armstrong/11.jpg") },
]
}, {
id: 3,
name: "Magenta",
numeral: "III",
slug: "magenta",
pages: [
{ url: image_url("magenta/1.jpg") },
{ url: image_url("magenta/2.jpg") },
{ url: image_url("magenta/3.jpg") },
{ url: image_url("magenta/4.jpg") },
{ url: image_url("magenta/5.jpg") },
{ url: vimeo_url(90116548), is_video: true },
{ url: image_url("magenta/7.jpg") },
{ url: image_url("magenta/8.jpg") },
{ url: image_url("magenta/9.jpg") },
{ url: image_url("magenta/10.jpg") },
{ url: image_url("magenta/11.jpg") },
{ url: vimeo_url(93339618), is_video: true },
{ url: image_url("magenta/13.jpg") },
]
}]
end

def image_url(name)
self.class.helpers.image_url("projects/#{name}")
end

def vimeo_url(id)
"http://player.vimeo.com/video/#{id}?title=0&amp;byline=0&amp;portrait=0&amp;color=cfcfcf%22%20width=%22888"
end
end
2 changes: 1 addition & 1 deletion spec/requests/lookbooks_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe "GET /api/lookbooks", type: :request do
it "returns all lookbooks" do
get lookbooks_path, format: :json
get "/api/lookbooks", json_header

expect(response.status).to eq 200
expect(response).to match_response_schema("lookbooks")
Expand Down
3 changes: 0 additions & 3 deletions spec/requests/projects_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
describe "GET /api/projects" do
it "includes all published projects" do
project = create(:project, :published, photos: [create(:photo)], )
create(:banner, resource: project)

get "/api/projects", {}, json_header

expect(response.status).to eq 200
Expand Down
38 changes: 11 additions & 27 deletions spec/support/api/schemas/projects.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,29 @@
{
"type": "object",
"required": ["projects", "photos"],
"required": ["projects"],
"properties": {
"projects": {
"type": "array",
"items": {
"required": [
"id",
"name",
"video_url",
"published_at",
"photo_ids"
"pages",
"slug"
],
"properties" : {
"id": { "type": "integer" },
"name": { "type": "string" },
"video_url": { "type": "string" },
"published_at": { "type": "string", "format": "date-time" },
"photo_ids": { "type": "array" },
"banner": { "type": "string" },
"banner_hover": { "type": "string" }
}
}
},
"photos": {
"type": "array",
"items": {
"required": [
"id",
"url",
"caption",
"thumbnail"
],
"properties" : {
"id": { "type": "integer" },
"url": { "type": "string" },
"caption": { "type": "string" },
"thumbnail": { "type": "string" }
"slug": { "type": "string" },
"pages": {
"type": "array",
"items": {
"url": { "type": "string" },
"is_video": { "type": "boolean" }
}
}
}
}
}
}
}

0 comments on commit bd9a514

Please sign in to comment.