Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit ecf9f55e7dd77d2e7121d1e7f420cf4e436c4231 @lusis committed Aug 25, 2010
7 .components
@@ -0,0 +1,7 @@
+---
+:orm: mongomatic
+:test: none
+:mock: none
+:script: none
+:renderer: haml
+:stylesheet: none
3 .gitignore
@@ -0,0 +1,3 @@
+.bundle
+*.swp
+.rvmrc
17 Gemfile
@@ -0,0 +1,17 @@
+source :rubygems
+
+# Project requirements
+gem 'rake'
+gem 'rack-flash'
+gem 'thin' # or mongrel
+
+# Component requirements
+gem 'haml'
+gem 'mongomatic'
+gem 'bson_ext', :require => "mongo"
+
+# Test requirements
+
+
+# Padrino
+gem 'padrino', "0.9.14"
79 Gemfile.lock
@@ -0,0 +1,79 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activesupport (2.3.8)
+ bson (1.0.4)
+ bson_ext (1.0.4)
+ daemons (1.1.0)
+ eventmachine (0.12.10)
+ git (1.2.5)
+ haml (3.0.17)
+ http_router (0.3.13)
+ rack (>= 1.0)
+ url_mount (>= 0.2.1)
+ i18n (0.4.1)
+ mail (2.2.5)
+ activesupport (>= 2.3.6)
+ mime-types
+ treetop (>= 1.4.5)
+ mime-types (1.16)
+ mongo (1.0.7)
+ bson (>= 1.0.4)
+ mongomatic (0.3.2)
+ activesupport (>= 2.3.5)
+ bson (>= 1.0.4)
+ bson_ext (>= 1.0.4)
+ mongo (>= 1.0.7)
+ padrino (0.9.14)
+ padrino-admin (= 0.9.14)
+ padrino-core (= 0.9.14)
+ padrino-gen (= 0.9.14)
+ padrino-helpers (= 0.9.14)
+ padrino-mailer (= 0.9.14)
+ padrino-admin (0.9.14)
+ padrino-core (= 0.9.14)
+ padrino-gen (= 0.9.14)
+ padrino-helpers (= 0.9.14)
+ padrino-core (0.9.14)
+ activesupport (>= 2.3.8)
+ http_router (>= 0.3.12)
+ sinatra (>= 1.0.0)
+ thor (>= 0.13.0)
+ padrino-gen (0.9.14)
+ bundler (>= 1.0.0.rc.2)
+ git
+ padrino-core (= 0.9.14)
+ padrino-helpers (0.9.14)
+ i18n (>= 0.4.1)
+ padrino-core (= 0.9.14)
+ padrino-mailer (0.9.14)
+ mail (>= 2.2.0)
+ padrino-core (= 0.9.14)
+ polyglot (0.3.1)
+ rack (1.2.1)
+ rack-flash (0.1.1)
+ rack
+ rake (0.8.7)
+ sinatra (1.0)
+ rack (>= 1.0)
+ thin (1.2.7)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
+ thor (0.14.0)
+ treetop (1.4.8)
+ polyglot (>= 0.3.1)
+ url_mount (0.2.1)
+ rack
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bson_ext
+ haml
+ mongomatic
+ padrino (= 0.9.14)
+ rack-flash
+ rake
+ thin
34 app/app.rb
@@ -0,0 +1,34 @@
+class Pblog < Padrino::Application
+ register Padrino::Mailer
+ register Padrino::Helpers
+
+ ##
+ # Application configuration options
+ #
+ # set :raise_errors, true # Show exceptions (default for development)
+ # set :public, "foo/bar" # Location for static assets (default root/public)
+ # set :reload, false # Reload application files (default in development)
+ # set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder')
+ # set :locale_path, "bar" # Set path for I18n translations (defaults to app/locale/)
+ # enable :sessions # Disabled by default
+ # disable :flash # Disables rack-flash (enabled by default if sessions)
+ # layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
+ #
+
+ ##
+ # You can configure for a specified environment like:
+ #
+ # configure :development do
+ # set :foo, :bar
+ # disable :asset_stamp # no asset timestamping for dev
+ # end
+ #
+
+ ##
+ # You can manage errors like:
+ #
+ # error 404 do
+ # render 'errors/404'
+ # end
+ #
+end
37 app/controllers/post.rb
@@ -0,0 +1,37 @@
+Pblog.controllers :post do
+
+ get :index do
+ @posts = Post.all
+ render "posts/index"
+ end
+
+ get :new do
+ @post = Post.new
+ render "posts/new"
+ end
+
+ post :create do
+ @post =Post.new(params[:post])
+ if @post.insert
+ redirect url(:post, :index)
+ else
+ render "posts/new"
+ end
+ end
+
+ get :edit, :with => :id do
+ @post = Post.find_one({"_id" => BSON::ObjectID(params[:id])})
+ render 'posts/edit'
+ end
+
+ put :update, :with => :id do
+ @post = Post.find_one({"_id" => BSON::ObjectID(params[:id])})
+ @post.merge(params[:post])
+ if @post.update
+ redirect url(:post, :index)
+ else
+ render "posts/edit"
+ end
+ end
+
+end
7 app/helpers/post_helper.rb
@@ -0,0 +1,7 @@
+# Helper methods defined here can be accessed in any controller or view in the application
+
+Pblog.helpers do
+ # def simple_helper_method
+ # ...
+ # end
+end
46 app/models/post.rb
@@ -0,0 +1,46 @@
+class Post < Mongomatic::Base
+ include Mongomatic::Expectations::Helper
+
+ # Mongomatic does not have the traditional
+ # model definition that AR/MM/DM et. al. have.
+ # Staying true to the "ad-hoc" nature of MongoDB,
+ # there are no explicit column definitions in the
+ # model file.
+
+ # However you can "fake it" by making a column
+ # required using expectations
+ # For the sake of padrino g model,
+ # we'll assume that any property defined
+ # on the command-line is required
+ # In the case of Integer types, we'll add
+ # the expectation: be_a_number
+ # Future enhancement may allow a regex for
+ # String datatypes
+
+
+ # Examples
+ # def validate
+ # expectations do
+ # be_present self['name'], "Name cannot be blank"
+ # be_present self['email'], "Email cannot be blank"
+ # be_present self['age'], "Age cannot be blank"
+ # be_present self['password'], "Password cannot be blank"
+ # be_a_number self['age'], "Age must be a number"
+ # be_of_length self['password'], "Password must be at least 8 characters", :minimum => 8
+ # end
+ # end
+
+ # def create_indexes
+ # self.collection.create_index('name', :unique => true)
+ # self.collection.create_index('email', :unique => true)
+ # self.collection.create_index('age')
+ # end
+ def validate
+ expectations do
+ be_present self['name'], 'name cannot be blank'
+ be_present self['body'], 'body cannot be blank'
+
+ end
+ end
+
+end
25 app/views/posts/edit.haml
@@ -0,0 +1,25 @@
+<!doctype html>
+%html.no-js{:lang => "en"}
+ %head
+ %meta{:charset => "utf-8"}/
+ %title My Blog Posts!
+ %link{:href => "/favicon.ico", :rel => "shortcut icon"}/
+ %link{:href => "/css/style.css?v=1", :rel => "stylesheet"}/
+ %body
+ #container
+ %header
+ #main
+ - form_for @post, url(:post, :update, :id => @post['_id']), :method => :put do |f|
+ .group
+ =f.label :name
+ =f.text_field :name, :value => @post['name']
+ .group
+ =f.label :author
+ =f.text_field :author, :value => @post['author']
+ .group
+ =f.label :body
+ =f.text_area :body, :value => @post['body']
+ .group
+ =f.submit
+ %footer
+ / ! end of #container
29 app/views/posts/index.haml
@@ -0,0 +1,29 @@
+<!doctype html>
+%html.no-js{:lang => "en"}
+ %head
+ %meta{:charset => "utf-8"}/
+ %title My Blog Posts!
+ %link{:href => "/favicon.ico", :rel => "shortcut icon"}/
+ %link{:href => "/css/style.css?v=1", :rel => "stylesheet"}/
+ %body
+ #container
+ %header
+ #main
+ -if @posts.empty?
+ %h1 No posts found
+ -else
+ %table.table
+ %tr
+ %th Name
+ %th Author
+ %th Body
+ %th Operation
+ -@posts.each do |post|
+ %tr
+ %td= post["name"]
+ %td= post["author"]
+ %td= post["body"]
+ %td= link_to "edit", url(:post, :edit, :id => post["_id"])
+
+ %footer
+ / ! end of #container
25 app/views/posts/new.haml
@@ -0,0 +1,25 @@
+<!doctype html>
+%html.no-js{:lang => "en"}
+ %head
+ %meta{:charset => "utf-8"}/
+ %title My Blog Posts!
+ %link{:href => "/favicon.ico", :rel => "shortcut icon"}/
+ %link{:href => "/css/style.css?v=1", :rel => "stylesheet"}/
+ %body
+ #container
+ %header
+ #main
+ - form_for @post, url(:post, :create) do |f|
+ .group
+ =f.label :name
+ =f.text_field :name
+ .group
+ =f.label :author
+ =f.text_field :author
+ .group
+ =f.label :body
+ =f.text_area :body
+ .group
+ =f.submit
+ %footer
+ / ! end of #container
2 config.ru
@@ -0,0 +1,2 @@
+require ::File.dirname(__FILE__) + '/config/boot.rb'
+run Padrino.application
25 config/apps.rb
@@ -0,0 +1,25 @@
+##
+# This file mounts each app in the Padrino project to a specified sub-uri.
+# You can mount additional applications using any of these commands below:
+#
+# Padrino.mount("blog").to('/blog')
+# Padrino.mount("blog", :app_class => "BlogApp").to('/blog')
+# Padrino.mount("blog", :app_file => "path/to/blog/app.rb").to('/blog')
+#
+# You can also map apps to a specified host:
+#
+# Padrino.mount("Admin").host("admin.example.org")
+# Padrino.mount("WebSite").host(/.*\.?example.org/)
+# Padrino.mount("Foo").to("/foo").host("bar.example.org")
+#
+# Note 1: Mounted apps (by default) should be placed into the project root at '/app_name'.
+# Note 2: If you use the host matching remember to respect the order of the rules.
+#
+# By default, this file mounts the parimary app which was generated with this project.
+# However, the mounted app can be modified as needed:
+#
+# Padrino.mount(:app_file => "path/to/file", :app_class => "Blog").to('/')
+#
+
+# Mounts the core application for this project
+Padrino.mount("Pblog").to('/')
30 config/boot.rb
@@ -0,0 +1,30 @@
+# Defines our constants
+PADRINO_ENV = ENV["PADRINO_ENV"] ||= ENV["RACK_ENV"] ||= "development" unless defined?(PADRINO_ENV)
+PADRINO_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) unless defined?(PADRINO_ROOT)
+
+begin
+ # Require the preresolved locked set of gems.
+ require File.expand_path('../../.bundle/environment', __FILE__)
+rescue LoadError
+ # Fallback on doing the resolve at runtime.
+ require 'rubygems'
+ require 'bundler'
+ Bundler.setup
+end
+
+Bundler.require(:default, PADRINO_ENV.to_sym)
+puts "=> Located #{Padrino.bundle} Gemfile for #{Padrino.env}"
+
+##
+# Add here your before load hooks
+#
+Padrino.before_load do
+end
+
+##
+# Add here your after load hooks
+#
+Padrino.after_load do
+end
+
+Padrino.load!
6 config/database.rb
@@ -0,0 +1,6 @@
+
+case Padrino.env
+ when :development then Mongomatic.db = Mongo::Connection.new.db("pblog_development")
+ when :production then Mongomatic.db = Mongo::Connection.new.db("pblog_production")
+ when :test then Mongomatic.db = Mongo::Connection.new.db("pblog_test")
+end
8 public/css/handheld.css
@@ -0,0 +1,8 @@
+* {
+ float: none; /* Screens are not big enough to account for floats */
+ background: #fff; /* As much contrast as possible */
+ color: #000;
+}
+
+/* Slightly reducing font size to reduce need to scroll */
+body { font-size: 80%; }
265 public/css/style.css
@@ -0,0 +1,265 @@
+/*
+ style.css contains a reset, font normalization and some base styles.
+
+ credit is left where credit is due.
+ additionally, much inspiration was taken from these projects:
+ yui.yahooapis.com/2.8.1/build/base/base.css
+ camendesign.com/design/
+ praegnanz.de/weblog/htmlcssjs-kickstart
+*/
+
+/*
+ html5doctor.com Reset Stylesheet (Eric Meyer's Reset Reloaded + HTML5 baseline)
+ v1.4 2009-07-27 | Authors: Eric Meyer & Richard Clark
+ html5doctor.com/html-5-reset-stylesheet/
+*/
+
+html, body, div, span, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+abbr, address, cite, code,
+del, dfn, em, img, ins, kbd, q, samp,
+small, strong, sub, sup, var,
+b, i,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, figcaption, figure,
+footer, header, hgroup, menu, nav, section, summary,
+time, mark, audio, video {
+ margin:0;
+ padding:0;
+ border:0;
+ outline:0;
+ font-size:100%;
+ vertical-align:baseline;
+ background:transparent;
+}
+
+article, aside, details, figcaption, figure,
+footer, header, hgroup, menu, nav, section {
+ display:block;
+}
+
+nav ul { list-style:none; }
+
+blockquote, q { quotes:none; }
+
+blockquote:before, blockquote:after,
+q:before, q:after { content:''; content:none; }
+
+a { margin:0; padding:0; font-size:100%; vertical-align:baseline; background:transparent; }
+
+ins { background-color:#ff9; color:#000; text-decoration:none; }
+
+mark { background-color:#ff9; color:#000; font-style:italic; font-weight:bold; }
+
+del { text-decoration: line-through; }
+
+abbr[title], dfn[title] { border-bottom:1px dotted; cursor:help; }
+
+/* tables still need cellspacing="0" in the markup */
+table { border-collapse:collapse; border-spacing:0; }
+
+hr { display:block; height:1px; border:0; border-top:1px solid #ccc; margin:1em 0; padding:0; }
+
+input, select { vertical-align:middle; }
+/* END RESET CSS */
+
+
+/* fonts.css from the YUI Library: developer.yahoo.com/yui/
+ Please refer to developer.yahoo.com/yui/fonts/ for font sizing percentages
+
+ There are two custom edits:
+ * remove arial, helvetica from explicit font stack
+ * we normalize monospace styles ourselves
+*/
+body { font:13px/1.231 sans-serif; *font-size:small; } /* hack retained to preserve specificity */
+
+table { font-size:inherit; font: 100%; }
+
+select, input, textarea, button { font:99% sans-serif; }
+
+/* normalize monospace sizing
+ * en.wikipedia.org/wiki/MediaWiki_talk:Common.css/Archive_11#Teletype_style_fix_for_Chrome
+ */
+pre, code, kbd, samp { font-family: monospace, sans-serif; }
+
+
+
+/*
+ * minimal base styles
+ */
+
+
+/* #444 looks better than black: twitter.com/H_FJ/statuses/11800719859 */
+body, select, input, textarea { color: #444; }
+
+/* Headers (h1,h2,etc) have no default font-size or margin,
+ you'll want to define those yourself. */
+h1,h2,h3,h4,h5,h6 { font-weight: bold; }
+
+html {
+ /* maxvoltar.com/archive/-webkit-font-smoothing */
+ -webkit-font-smoothing: antialiased;
+ /* always force a scrollbar in non-IE */
+ overflow-y: scroll;
+}
+
+
+/* Accessible focus treatment: people.opera.com/patrickl/experiments/keyboard/test */
+a:hover, a:active { outline: none; }
+
+a, a:active, a:visited { color: #607890; }
+a:hover { color: #036; }
+
+
+ul { margin-left: 30px; }
+ol { margin-left: 30px; list-style-type: decimal; }
+
+small { font-size: 85%; }
+strong, th { font-weight: bold; }
+
+td, td img { vertical-align: top; }
+
+sub { vertical-align: sub; font-size: smaller; }
+sup { vertical-align: super; font-size: smaller; }
+
+pre {
+ padding: 15px;
+
+ /* www.pathf.com/blogs/2008/05/formatting-quoted-code-in-blog-posts-css21-white-space-pre-wrap/ */
+ white-space: pre; /* CSS2 */
+ white-space: pre-wrap; /* CSS 2.1 */
+ white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
+ word-wrap: break-word; /* IE */
+}
+
+/* align checkboxes, radios, text inputs with their label
+ by: Thierry Koblentz tjkdesign.com/ez-css/css/base.css */
+input[type="radio"] { vertical-align: text-bottom; }
+input[type="checkbox"] { vertical-align: bottom; }
+.ie7 input[type="checkbox"] { vertical-align: baseline; }
+.ie6 input { vertical-align: text-bottom; }
+
+/* hand cursor on clickable input elements */
+label, input[type=button], input[type=submit], button { cursor: pointer; }
+
+/* colors for form validity */
+input:invalid { background-color: #f0dddd; }
+input:valid { background-color: #ddf0dd; }
+
+/* These selection declarations have to be separate.
+ No text-shadow: twitter.com/miketaylr/status/12228805301
+ Also: hot pink. */
+::-moz-selection{ background: #FF5E99; color:#fff; text-shadow: none; }
+::selection { background:#FF5E99; color:#fff; text-shadow: none; }
+
+/* j.mp/webkit-tap-highlight-color */
+a:link { -webkit-tap-highlight-color: #FF5E99; }
+
+/* make buttons play nice in IE:
+ www.viget.com/inspire/styling-the-button-element-in-internet-explorer/ */
+button { width: auto; overflow: visible; }
+
+/* bicubic resizing for non-native sized IMG:
+ code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ */
+.ie7 img { -ms-interpolation-mode: bicubic; }
+
+
+
+/*
+ * Non-semantic helper classes
+ */
+
+/* for image replacement */
+.ir { display: block; text-indent: -999em; overflow: hidden; background-repeat: no-repeat; text-align: left; direction: ltr; }
+
+/* Hide for both screenreaders and browsers
+ css-discuss.incutio.com/wiki/Screenreader_Visibility */
+.hidden { display: none; visibility: hidden; }
+
+/* Hide only visually, but have it available for screenreaders
+ www.webaim.org/techniques/css/invisiblecontent/
+ Solution from: j.mp/visuallyhidden - Thanks Jonathan Neal! */
+.visuallyhidden { position: absolute !important;
+ clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
+ clip: rect(1px, 1px, 1px, 1px); }
+
+/* Hide visually and from screenreaders, but maintain layout */
+.invisible { visibility: hidden; }
+
+/* >> The Magnificent CLEARFIX << j.mp/phayesclearfix */
+.clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
+.clearfix { zoom: 1; }
+
+
+
+
+
+
+ /* Primary Styles
+ Author:
+ */
+
+
+
+
+
+
+
+
+
+
+
+/*
+ * print styles
+ * inlined to avoid required HTTP connection www.phpied.com/delay-loading-your-print-css/
+ */
+@media print {
+ * { background: transparent !important; color: #444 !important; text-shadow: none !important; }
+
+ a, a:visited { color: #444 !important; text-decoration: underline; }
+
+ a:after { content: " (" attr(href) ")"; }
+
+ abbr:after { content: " (" attr(title) ")"; }
+
+ .ir a:after { content: ""; } /* Don't show links for images */
+
+ pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }
+
+ img { page-break-inside: avoid; }
+
+ @page { margin: 0.5cm; }
+
+ p, h2, h3 { orphans: 3; widows: 3; }
+
+ h2, h3{ page-break-after: avoid; }
+}
+
+
+
+/*
+ * Media queries for responsive design
+ */
+
+@media all and (orientation:portrait) {
+ /* Style adjustments for portrait mode goes here */
+
+}
+
+@media all and (orientation:landscape) {
+ /* Style adjustments for landscape mode goes here */
+
+}
+
+/* Grade-A Mobile Browsers (Opera Mobile, iPhone Safari, Android Chrome)
+ Consider this: www.cloudfour.com/css-media-query-for-mobile-is-fools-gold/ */
+@media screen and (max-device-width: 480px) {
+
+
+ /* Uncomment if you don't want iOS and WinMobile to mobile-optimize the text for you
+ j.mp/textsizeadjust
+ html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; } */
+}
+
0 public/favicon.ico
No changes.

0 comments on commit ecf9f55

Please sign in to comment.