0
0

some layout changes

This commit is contained in:
Gibheer 2011-08-09 11:06:53 +02:00
parent 326fb46236
commit 0cbaecd5dd
7 changed files with 201 additions and 39 deletions

View File

@ -3,13 +3,14 @@ class Admin < Sinatra::Base
use Rack::Session::Pool, :expire_after => 1800 use Rack::Session::Pool, :expire_after => 1800
use Rack::Flash, :accessorize => [:error, :warning, :notice] use Rack::Flash, :accessorize => [:error, :warning, :notice]
set :haml, :layout => :admin_layout set :haml, :layout => :admin_layout
register Sinatra::CompassSupport
get '/' do get '/' do
haml :admin_index haml :admin_index
end end
get '/post' do get '/post' do
@posts = Post.all(:order => [:id.desc]) @posts = Post.all(:order => [:id.desc], :limit => 15)
haml :admin_posts haml :admin_posts
end end
@ -88,7 +89,7 @@ class Admin < Sinatra::Base
session[:id] = nil session[:id] = nil
session[:last_updated] = nil session[:last_updated] = nil
flash.notice = 'Logout complete' flash.notice = 'Logout complete'
redirect '/' redirect '/'
end end
get '/stylesheet.css' do get '/stylesheet.css' do
@ -112,6 +113,15 @@ class Admin < Sinatra::Base
end end
hash = new_hash hash = new_hash
end end
def markup content, markup
markup = markup.to_sym
if respond_to? markup
send markup, content
else
content
end
end
end end
before do before do

View File

@ -1,5 +1,5 @@
%h1="Login" %form#login.fields{:action => '/admin/login', :method => 'post'}
%form{:action => '/admin/login', :method => 'post'} .login="Welcome in the admin area."
.username .username
%label.block{:for => 'username'}='Username' %label.block{:for => 'username'}='Username'
%input.block{:name => 'username', :placeholder => 'username', :value => flash[:username]} %input.block{:name => 'username', :placeholder => 'username', :value => flash[:username]}

View File

@ -2,11 +2,18 @@
%html %html
%head %head
%title="zero-knowledge - Adminpanel" %title="zero-knowledge - Adminpanel"
%link{:rel => 'stylesheet', :href => '/stylesheet.css', :type => 'text/css'}
%link{:rel => 'stylesheet', :href => '/admin/stylesheet.css', :type => 'text/css'} %link{:rel => 'stylesheet', :href => '/admin/stylesheet.css', :type => 'text/css'}
%script{:src => '/public/head.min.js'} %script{:src => '/public/head.min.js'}
%body %body
#menu="Menue" #menu
%ul
%li
%a{:href => '/'}="main"
%li
%a{:href => '/admin'}="admin"
-if @account
%li
%a{:href => '/admin/new'}="create"
#messages #messages
-unless flash.error.nil? -unless flash.error.nil?
%p.error=flash.error %p.error=flash.error

View File

@ -4,7 +4,9 @@
%form{:action => "/admin/post/#{@post.id}", :method => :post} %form{:action => "/admin/post/#{@post.id}", :method => :post}
.fields .fields
=haml :admin_post_edit, :layout => nil =haml :admin_post_edit, :layout => nil
.buttons .buttons
%button{:type => :submit}="Update" %button{:type => :submit}="Update"
%button{:type => :submit, :formmethod => :get, %button{:type => :submit, :formmethod => :get,
:formaction => '/admin/post'}="Back" :formaction => '/admin/post'}="Back"
~haml :post_single, :layout => nil

View File

@ -1,24 +1,34 @@
.title .main
%label{:for => :post_title}="Title" .content
%input{:id => :post_title, %label{:for => :post_content}="Content"
:name => 'post[title]', %textarea.content{:id => :post_content,
:value => @post.title} :name => 'post[content]'}=@post.content
.author .title
%label{:for => :post_author}="Author" %label{:for => :post_title}="Title"
%select{:name => 'post[account_id]', :id => :post_author} %input{:id => :post_title,
-Account.all(:order => [:id]).each do |account| :name => 'post[title]',
-if @post.account == account :value => @post.title}
%option{:value => account.id, :selected => :selected} .further
=account.username .written
-else %label{:for => :post_written}="written"
%option{:value => account.id}=account.username %input{:id => :post_written,
.written :name => 'post[written]', :value => @post.written}
%label{:for => :post_written}="written" .released
%input{:id => :post_written, %label{:for => :post_released}="released"
:name => 'post[written]', :value => @post.written} %input{:type => :checkbox, :name => 'post[released]',
.released :class => "post-released-#{@post.released}", :value => 0,
%label{:for => :post_released}="released" :checked => @post.released, :id => :post_released}
%input{:type => :checkbox, :name => 'post[released]', .author
:class => "post-released-#{@post.released}", :value => 0, %label{:for => :post_author}="Author"
:checked => @post.released, :id => :post_released} %select{:name => 'post[account_id]', :id => :post_author}
%textarea.content{:name => 'post[content]'}=@post.content -Account.all(:order => [:id]).each do |account|
-if @post.account == account
%option{:value => account.id, :selected => :selected}
=account.username
-else
%option{:value => account.id}=account.username
.tags
%label{:for => :post_tags}="Tags"
%select{:name => 'post[tags]', :id => :post_tags, :size => 10, :multiple => true}
- Tag.all.each do |tag|
%option{:value => tag.id}=tag.name

View File

@ -3,5 +3,4 @@
.title .title
%a{:href => "/admin/post/#{post.id}"}=post.title %a{:href => "/admin/post/#{post.id}"}=post.title
%span.released{:class => "post-released-#{post.released}"} %span.released{:class => "post-released-#{post.released}"}
.written=post.written .written=post.written
.content=post.content

View File

@ -1,17 +1,151 @@
// imports
@import "blueprint/colors";
@import "compass/reset";
@import "compass/css3";
@import "compass/utilities";
// variables
$font-color: hsl(0, 6%, 90%);
$link-color: $font-color;
$link-hover-color: hsl(32, 100%, 50%);
$border-color: black;
$background-normal: hsl(204, 25%, 35%);
$background-menu-normal: hsl(0, 0%, 20%);
$background-menu: color-stops(lighten($background-menu-normal, 15%),
$background-menu-normal 25%, darken($background-menu-normal, 15%));
$background-button: color-stops(lighten($background-normal, 15%),
$background-normal 75%, darken($background-normal, 5%));
$background-button-hover: color-stops(lighten($background-normal, 5%),
$background-normal 75%, darken($background-normal, 15%));
// some defaults for functions
$default-text-shadow-color: hsl(0, 10%, 50%);
$default-text-shadow-h-offset: 2px;
$default-text-shadow-v-offset: 2px;
$default-text-shadow-blur: 2px;
$default-border-radius: 2px;
body {background: $background-normal; color: $font-color;}
#menu, #messages, #content {
padding-left: 3em;
padding-right: 3em;
}
#messsages, #content {
padding-top: 1em;
}
#menu {
@include background-image(linear-gradient($background-menu));
li {
float: left;
display: inline-block;
}
:after {
content: '';
clear: both;
display: block;
}
a {
color: $link-color;
padding: 1em;
display: block;
text-decoration: none;
font-weight: bold;
@include single-text-shadow;
&:hover {
color: $link-hover-color;
};
}
}
#messages { #messages {
padding-top: 1em;
.message { .message {
border: 1px solid black; border: 1px solid black;
padding: 0.5em;
} }
.error { .error {
@extend .message; @extend .message;
background-color: red; background-color: $error-bg-color;
border-color: $error-border-color;
color: $error-color;
} }
.warning { .warning {
@extend .message; @extend .message;
background-color: orange; background-color: $notice-bg-color;
border-color: $notice-border-color;
color: $notice-color;
} }
.notice { .notice {
@extend .message; @extend .message;
background-color: green; background-color: $success-bg-color;
border-color: $success-border-color;
color: $success-color;
}
}
#content {
.buttons {
clear: both;
}
.fields {
clear: both;
.main {
width: 74%;
float: left;
textarea {
width: 100%;
height: 25em;
@include box-sizing(border-box);
}
}
.further {
float: right;
width: 24%;
}
.further:after {
content: '';
clear: both;
}
label, input, select {
display: block;
}
label {
font-size: 120%;
font-weight: bold;
}
input, select {
width: 100%;
}
}
button {
padding: 0.5em;
margin: 0.1em;
border: 1px solid $border-color;
color: $link-color;
font-weight: bold;
@include background-image(linear-gradient($background-button));
&:hover {
@include background-image(linear-gradient($background-button-hover));
}
&:active {
position: relative;
top: 1px;
}
}
a {
color: $link-color;
font: {
weight: bold;
decoration: none;
}
}
}
#login {
text-align: center;
.login {
padding: 1em;
font-weight: bold;
font-family: Sans;
}
> div {
width: 18em;
margin: auto;
} }
} }