-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some basic design, and the UI server skeleton.
- Loading branch information
Showing
14 changed files
with
207 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
.bundle | ||
Gemfile.lock | ||
pkg/* | ||
.sass-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
require "rubygems" | ||
require "bundler/setup" | ||
require "copycat/api_server" | ||
require "copycat" | ||
|
||
run Rack::URLMap.new \ | ||
"/api/v2/projects" => Copycat::ApiServer.new | ||
run Copycat.application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
require 'copycat/version' | ||
require 'copycat/api_server' | ||
require 'copycat/ui_server' | ||
|
||
module Copycat | ||
def self.application | ||
Rack::URLMap.new \ | ||
"/" => Copycat::UiServer.new, | ||
"/api/v2/projects" => Copycat::ApiServer.new | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'haml' | ||
require 'sass' | ||
|
||
module Copycat | ||
class UiServer < Sinatra::Application | ||
use Rack::Auth::Basic do |username, password| | ||
username == settings.default_username && password == settings.default_password | ||
end | ||
|
||
set :default_username, "admin" | ||
set :default_password, "password" | ||
|
||
set :redis, { | ||
:ns => "copycat", | ||
:host => "localhost", | ||
:port => 6379 | ||
} | ||
|
||
set :public, File.expand_path("../../../assets", __FILE__) | ||
set :views, File.expand_path("../../../views", __FILE__) | ||
|
||
get '/' do | ||
haml :index | ||
end | ||
|
||
get '/styles.css' do | ||
scss :styles | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
require 'rspec' | ||
require 'rack/test' | ||
require 'capybara/rspec' | ||
require 'copycat' | ||
|
||
RSpec.configure do |conf| | ||
conf.include Rack::Test::Methods | ||
conf.include Capybara | ||
|
||
def app | ||
Copycat.application | ||
end | ||
|
||
def login | ||
basic_authorize Copycat::UiServer.settings.default_username, Copycat::UiServer.settings.default_password | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'spec_helper' | ||
|
||
describe "authentication" do | ||
it "rejects the request if no authentication was provided" do | ||
get "/" | ||
last_response.status.should eq 401 | ||
end | ||
|
||
it "allows access if logging in with the default credentials" do | ||
Copycat::UiServer.set :default_username, "admin" | ||
Copycat::UiServer.set :default_password, "password" | ||
|
||
basic_authorize "admin", "password" | ||
|
||
get "/" | ||
last_response.status.should eq 200 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'spec_helper' | ||
require 'json' | ||
|
||
describe "the UI server" do | ||
def app | ||
Copycat::UiServer | ||
end | ||
|
||
def redis | ||
@redis ||= Redis::Namespace.new(app.redis[:ns], :redis => Redis.new(app.redis)) | ||
end | ||
|
||
before(:each) do | ||
redis.flushdb | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
%h1 Projects | ||
|
||
%section#projects | ||
%p It doesn't look like you've got any projects yet. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
!!! 5 | ||
%html | ||
%head | ||
%title Copycat | ||
%link{ rel: "stylesheet", href: "/styles.css"} | ||
|
||
%body | ||
%header | ||
%ul#navigation | ||
%li | ||
%a{ href: "/users" } Users | ||
%li | ||
%a{ href: "/" } Projects | ||
|
||
%h1 Copycat | ||
|
||
%section#content | ||
=yield | ||
|
||
%footer | ||
%a{ href: "http://blankpad.net", target: "_top" } | ||
%img{ src: "/images/blankpad.png", alt: "Blank Pad Development", title: "Developed by Blank Pad Development" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* Reset */ | ||
html, body, div, span, applet, object, iframe, | ||
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | ||
a, abbr, acronym, address, big, cite, code, | ||
del, dfn, em, img, ins, kbd, q, s, samp, | ||
small, strike, strong, sub, sup, tt, var, | ||
b, u, i, center, | ||
dl, dt, dd, ol, ul, li, | ||
fieldset, form, label, legend, | ||
table, caption, tbody, tfoot, thead, tr, th, td, | ||
article, aside, canvas, details, embed, | ||
figure, figcaption, footer, header, hgroup, | ||
menu, nav, output, ruby, section, summary, | ||
time, mark, audio, video { | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
font-size: 100%; | ||
font: inherit; | ||
vertical-align: baseline; | ||
} | ||
/* HTML5 display-role reset for older browsers */ | ||
article, aside, details, figcaption, figure, | ||
footer, header, hgroup, menu, nav, section { | ||
display: block; | ||
} | ||
body { | ||
line-height: 1; | ||
} | ||
ol, ul { | ||
list-style: none; | ||
} | ||
blockquote, q { | ||
quotes: none; | ||
} | ||
blockquote:before, blockquote:after, | ||
q:before, q:after { | ||
content: ''; | ||
content: none; | ||
} | ||
table { | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
} | ||
|
||
/* The real deal */ | ||
body { | ||
background-color: #f5f5f5; | ||
font-family: "Georgia", serif; | ||
padding: 0; | ||
margin: 0; | ||
|
||
header { | ||
margin: 0; | ||
padding: 0.5em 1em; | ||
background-color: darken(#f5f5f5, 50%); | ||
|
||
h1 { | ||
margin-top: 0; | ||
margin-bottom: 0.2em; | ||
font-size: 2em; | ||
font-weight: bold; | ||
} | ||
|
||
ul#navigation { | ||
li { | ||
float: right; | ||
font-weight: bold; | ||
display: inline; | ||
margin-top: 0.5em; | ||
margin-left: 1em; | ||
|
||
a { | ||
color: black; | ||
text-decoration: none; | ||
} | ||
} | ||
} | ||
} | ||
|
||
section#content { | ||
padding: 0.5em 1em; | ||
|
||
h1 { | ||
font-size: 1.5em; | ||
} | ||
} | ||
|
||
footer { | ||
padding: 0.5em 1em; | ||
text-align: right; | ||
} | ||
} |