santey_blog 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/.document +5 -0
  2. data/.gitignore +5 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE +20 -0
  5. data/README.rdoc +38 -0
  6. data/Rakefile +60 -0
  7. data/VERSION +1 -0
  8. data/app/controllers/posts_controller.rb +30 -0
  9. data/app/models/post.rb +44 -0
  10. data/app/views/includes/_archives.html.haml +5 -0
  11. data/app/views/includes/_disqus_comments.html.erb +14 -0
  12. data/app/views/includes/_footer.html.haml +2 -0
  13. data/app/views/includes/_footer_javascript.html.erb +0 -0
  14. data/app/views/includes/_head.html.haml +17 -0
  15. data/app/views/includes/_header.html.haml +2 -0
  16. data/app/views/includes/_menu.html.haml +12 -0
  17. data/app/views/includes/_recent.html.haml +6 -0
  18. data/app/views/includes/_tags.html.haml +5 -0
  19. data/app/views/includes/_top.html.haml +6 -0
  20. data/app/views/layouts/application.html.haml +11 -0
  21. data/app/views/posts/_post.html.haml +15 -0
  22. data/app/views/posts/index.html.haml +9 -0
  23. data/app/views/posts/index.rss.builder +18 -0
  24. data/app/views/posts/show.html.haml +25 -0
  25. data/config/routes.rb +10 -0
  26. data/lib/generators/santey_blog_generator.rb +31 -0
  27. data/lib/generators/templates/css/blueprint/TUTORIAL.textile +206 -0
  28. data/lib/generators/templates/css/blueprint/ie.css +35 -0
  29. data/lib/generators/templates/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  30. data/lib/generators/templates/css/blueprint/plugins/buttons/icons/key.png +0 -0
  31. data/lib/generators/templates/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  32. data/lib/generators/templates/css/blueprint/plugins/buttons/readme.txt +32 -0
  33. data/lib/generators/templates/css/blueprint/plugins/buttons/screen.css +97 -0
  34. data/lib/generators/templates/css/blueprint/plugins/fancy-type/readme.txt +14 -0
  35. data/lib/generators/templates/css/blueprint/plugins/fancy-type/screen.css +71 -0
  36. data/lib/generators/templates/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
  37. data/lib/generators/templates/css/blueprint/plugins/link-icons/icons/email.png +0 -0
  38. data/lib/generators/templates/css/blueprint/plugins/link-icons/icons/external.png +0 -0
  39. data/lib/generators/templates/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
  40. data/lib/generators/templates/css/blueprint/plugins/link-icons/icons/im.png +0 -0
  41. data/lib/generators/templates/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  42. data/lib/generators/templates/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
  43. data/lib/generators/templates/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
  44. data/lib/generators/templates/css/blueprint/plugins/link-icons/readme.txt +18 -0
  45. data/lib/generators/templates/css/blueprint/plugins/link-icons/screen.css +40 -0
  46. data/lib/generators/templates/css/blueprint/plugins/rtl/readme.txt +10 -0
  47. data/lib/generators/templates/css/blueprint/plugins/rtl/screen.css +110 -0
  48. data/lib/generators/templates/css/blueprint/print.css +29 -0
  49. data/lib/generators/templates/css/blueprint/screen.css +258 -0
  50. data/lib/generators/templates/css/blueprint/src/forms.css +65 -0
  51. data/lib/generators/templates/css/blueprint/src/grid.css +280 -0
  52. data/lib/generators/templates/css/blueprint/src/grid.png +0 -0
  53. data/lib/generators/templates/css/blueprint/src/ie.css +76 -0
  54. data/lib/generators/templates/css/blueprint/src/print.css +85 -0
  55. data/lib/generators/templates/css/blueprint/src/reset.css +45 -0
  56. data/lib/generators/templates/css/blueprint/src/typography.css +106 -0
  57. data/lib/generators/templates/css/screen.css +53 -0
  58. data/lib/generators/templates/initializers/santey_blog.rb +16 -0
  59. data/lib/generators/templates/migrations/create_posts.rb +24 -0
  60. data/lib/santey_blog/engine.rb +13 -0
  61. data/lib/santey_blog/view_helper.rb +84 -0
  62. data/lib/santey_blog.rb +16 -0
  63. data/santey_blog.gemspec +114 -0
  64. data/test/santey_blog_test.rb +7 -0
  65. data/test/test_helper.rb +10 -0
  66. metadata +163 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ gem "santey_view", :git => "git://github.com/shamne/santey_view.git"
2
+ gem "santey_blog", :git => "git://github.com/shamne/santey_blog.git"
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Alexander Shamne
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,38 @@
1
+ = Rails blog plugin
2
+
3
+ add this to your Gemfile:
4
+ gem "mysql", ">=2.8.1"
5
+ gem "rmagick", "2.13.1"
6
+ gem "hpricot", ">=0.8.2"
7
+ gem "aws-s3", :require => "aws/s3"
8
+ gem "haml", "2.2.23"
9
+ gem "ckeditor", :git => "git://github.com/galetahub/rails-ckeditor.git", :branch => "rails3"
10
+ gem "acts-as-taggable-on", :git => "git://github.com/shamne/acts-as-taggable-on.git"
11
+ gem "will_paginate", :git => "git://github.com/mislav/will_paginate.git", :branch => "rails3"
12
+ gem "nokogiri", "1.4.1"
13
+ gem "sanitize", "1.2.1"
14
+ gem "santey_vote", :path => "d:/web/gems_and_plugins/santey_vote"
15
+ gem "santey_view", :path => "d:/web/gems_and_plugins/santey_view"
16
+ gem "santey_blog", :path => "d:/web/gems_and_plugins/santey_blog"
17
+
18
+ configure plugins:
19
+ rails generate santey_blog [--css, --migrate]
20
+ rails generate santey_vote
21
+ rails generate santey_view
22
+ rails generate acts_as_taggable_on:migration
23
+
24
+
25
+ == Note on Patches/Pull Requests
26
+
27
+ * Fork the project.
28
+ * Make your feature addition or bug fix.
29
+ * Add tests for it. This is important so I don't break it in a
30
+ future version unintentionally.
31
+ * Commit, do not mess with rakefile, version, or history.
32
+ (if you want to have your own version, that is fine but
33
+ bump version in a commit by itself I can ignore when I pull)
34
+ * Send me a pull request. Bonus points for topic branches.
35
+
36
+ == Copyright
37
+
38
+ Copyright (c) 2010 Alexander Shamne. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "santey_blog"
8
+ gem.summary = %Q{Blog gem}
9
+ gem.description = %Q{longer description of your gem}
10
+ gem.email = "alexander.shamne@gmail.com"
11
+ gem.homepage = "http://github.com/shamne/santey_blog"
12
+ gem.authors = ["Alexander Shamne"]
13
+ gem.add_development_dependency "thoughtbot-shoulda"
14
+
15
+ gem.add_dependency 'santey_vote'
16
+ gem.add_dependency 'santey_view'
17
+
18
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
+ end
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
22
+ end
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.libs << 'lib' << 'test'
27
+ test.pattern = 'test/**/*_test.rb'
28
+ test.verbose = true
29
+ end
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/*_test.rb'
36
+ test.verbose = true
37
+ end
38
+ rescue LoadError
39
+ task :rcov do
40
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
+ end
42
+ end
43
+
44
+ task :test => :check_dependencies
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ if File.exist?('VERSION')
51
+ version = File.read('VERSION')
52
+ else
53
+ version = ""
54
+ end
55
+
56
+ rdoc.rdoc_dir = 'rdoc'
57
+ rdoc.title = "santey_blog #{version}"
58
+ rdoc.rdoc_files.include('README*')
59
+ rdoc.rdoc_files.include('lib/**/*.rb')
60
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.2
@@ -0,0 +1,30 @@
1
+ class PostsController < ApplicationController
2
+
3
+ protect_from_forgery
4
+ before_filter :find_post, :only => [:show]
5
+
6
+ def index
7
+ @posts = Post.published.recent.with_dates(params[:year], params[:month], params[:day]).paginate(:all, :page=>params[:page], :per_page=>5)
8
+ end
9
+
10
+ def show
11
+ if @post
12
+ @post.view(request.remote_ip, nil)
13
+ else
14
+ redirect_to root_path
15
+ end
16
+ end
17
+
18
+ def tags
19
+ @tag = params[:id].gsub(/~dot~/, ".")
20
+ @posts = Post.tagged_with(@tag).published.recent.paginate(:all, :page=>params[:page], :per_page=>5)
21
+ render :index
22
+ end
23
+
24
+
25
+ private
26
+ def find_post
27
+ @post = Post.find_by_slug(params[:id])
28
+ end
29
+
30
+ end
@@ -0,0 +1,44 @@
1
+ class Post < ActiveRecord::Base
2
+
3
+ belongs_to :user
4
+
5
+ santey_vote
6
+ santey_view
7
+
8
+ # tags examples: http://github.com/mbleigh/acts-as-taggable-on
9
+ acts_as_taggable
10
+ #acts_as_taggable_on :tags
11
+
12
+ validates_presence_of :title, :message => "Please enter title"
13
+ validates_presence_of :content, :message => "Please enter content"
14
+
15
+ scope :published, where("#{self.table_name}.published = true")
16
+ scope :published_since, lambda { |ago|
17
+ published.where("#{self.table_name}.created_at >= ?", ago)
18
+ }
19
+ scope :recent, order("#{self.table_name}.created_at DESC")
20
+ scope :top, joins([:votes]).select("distinct #{self.table_name}.*, count(votes.vote) AS count_votes").where("votes.vote = true").group(self.column_names.map{|i| "#{self.table_name}.#{i}"}.join(',')).order("count_votes DESC, #{self.table_name}.created_at DESC")
21
+
22
+ scope :archives, published.select("COUNT(#{self.table_name}.id) AS count_posts, YEAR(#{self.table_name}.created_at) AS year, MONTH(#{self.table_name}.created_at) AS month").group("year, month").order("year DESC, month DESC")
23
+
24
+ scope :with_dates, lambda { |y,m,d|
25
+ where("#{self.table_name}.created_at between ? and ?",
26
+ Time.parse("#{y || "2000"}-#{m || "01"}-#{d || "01"}"),
27
+ Time.parse("#{y || Time.now.year}-#{m || "12"}-#{d || "31"}"))
28
+ }
29
+
30
+
31
+ class << self
32
+ # example: Post.search('w').published_since(10.days.ago).collect(&:title)
33
+ def search(q)
34
+ [:title, :content].inject(scoped) do |combined_scope, attr|
35
+ combined_scope.where("#{self.table_name}.#{attr} LIKE ?", "%#{q}%")
36
+ end
37
+ end
38
+ end
39
+
40
+ def before_save
41
+ self.slug = title.gsub(/[^A-Za-z0-9\.\-]/, '_').downcase+"-#{rand(1000)}" if self.slug.nil?
42
+ end
43
+
44
+ end
@@ -0,0 +1,5 @@
1
+ .side_box.archive
2
+ %h2 Archives
3
+ - Post.archives.limit(100).each do |a|
4
+ =link_to Time.parse("#{a.year}-#{a.month}-01").strftime("%B %Y"), dates_path_helper(a.year, a.month)
5
+ %br/
@@ -0,0 +1,14 @@
1
+ <!-- Disqus code -->
2
+ <div id="disqus_thread"></div>
3
+ <script type="text/javascript">
4
+ var disqus_developer = 1;
5
+ /**
6
+ * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
7
+ */
8
+ (function() {
9
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
10
+ dsq.src = 'http://directautoinsurance.disqus.com/embed.js';
11
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
12
+ })();
13
+ </script>
14
+ <noscript>Please enable JavaScript to view the comments</noscript>
@@ -0,0 +1,2 @@
1
+ .footer
2
+ =render :partial => "includes/footer_javascript"
File without changes
@@ -0,0 +1,17 @@
1
+ %head
2
+ %title
3
+ =yield(:title)
4
+ %meta{:content=>"test", :name=>"description"}
5
+ %meta{:content=>"test", :name=>"keywords"}
6
+ %meta{:content=>"index,follow", :name=>"robots"}
7
+ %link{:href=>"/favicon.ico", :rel=>"shortcut icon"}
8
+ =stylesheet_link_tag('santey_blog/blueprint/screen.css', :media=> 'screen, projection')
9
+ =stylesheet_link_tag('santey_blog/blueprint/print.css', :media=> 'print')
10
+ =stylesheet_link_tag('santey_blog/screen.css', :media=> 'screen')
11
+ /[if lt IE 8]
12
+ =stylesheet_link_tag('santey_blog/blueprint/lib/ie.css', :media=> 'screen')
13
+ =javascript_include_tag :defaults
14
+
15
+ =csrf_meta_tag
16
+
17
+ !=auto_discovery_link_tag(:rss, "/posts.rss", :title=>"Blog posts")
@@ -0,0 +1,2 @@
1
+ #header
2
+ =image_tag("logo.png", :class=>"logo", :style=>"width:950px;height:70px;", :alt=>"Santey blog")
@@ -0,0 +1,12 @@
1
+ .main_menu
2
+ %ul
3
+ %li
4
+ %h3
5
+ =link_to "home", root_path
6
+ %li
7
+ %h3
8
+ =link_to "top", "#"
9
+ %li
10
+ %h3
11
+ =link_to "questions", "#"
12
+ .clear
@@ -0,0 +1,6 @@
1
+ .side_box.latest_posts
2
+ %h2 Recent posts
3
+ - posts = Post.published.recent.limit(5)
4
+ - posts.each do |post|
5
+ =link_to post.title, path_to_content(post)
6
+ %br/
@@ -0,0 +1,5 @@
1
+ .side_box.tags
2
+ %h2 Tags
3
+ - tags = Post.tag_counts
4
+ - tag_cloud(tags, %w(cloud1 cloud2 cloud3 cloud4 cloud5 cloud6 cloud7)) do |tag, css_class|
5
+ =link_to tag.name, tag_path_helper(tag.name.gsub(/\./, "~dot~")), :class => css_class
@@ -0,0 +1,6 @@
1
+ .side_box.top_posts
2
+ %h2 Top posts
3
+ - posts = Post.published.top.limit(5)
4
+ - posts.each do |post|
5
+ =link_to post.title, path_to_content(post)
6
+ %br/
@@ -0,0 +1,11 @@
1
+ !!! Strict
2
+ %html
3
+ =render :partial => "includes/head"
4
+ %body
5
+ .container
6
+ =render :partial => "includes/header"
7
+ =render :partial => "includes/menu"
8
+ %p
9
+ =flash[:notice]
10
+ =yield
11
+ =render :partial => "includes/footer"
@@ -0,0 +1,15 @@
1
+ .item
2
+ =render :partial=>"votes/vote", :locals=>{:voteable=>post}
3
+ %h1
4
+ =link_to post.title, path_to_content(post)
5
+ !=posted_at_helper(post)
6
+ !=cut_text(Sanitize.clean(post.content, SanteyBlog::ViewHelper::SANITIZER_CONFIG), path_to_content(post), 500)
7
+ .bottom_info
8
+ %a{:href=>path_to_content(post)+"#disqus_thread"} Comments
9
+ %br/
10
+ Tags:
11
+ - post.tags.each do |tag|
12
+ =link_to tag.name, tag_path_helper(tag.name.gsub(/\./, "~dot~"))
13
+ %br/
14
+ Meta:
15
+ =link_to "permalink", path_to_content(post)
@@ -0,0 +1,9 @@
1
+ =santey_title
2
+
3
+ .column.span-17.first.append-1
4
+ .posts_list
5
+ =render :partial => "post", :collection => @posts
6
+ .column.span-6.last
7
+ =render :partial => "/includes/tags"
8
+ =render :partial => "/includes/top"
9
+ =render :partial => "/includes/archives"
@@ -0,0 +1,18 @@
1
+ xml.instruct! :xml, :version => "1.0"
2
+ xml.rss :version => "2.0" do
3
+ xml.channel do
4
+ xml.title "Santey blog"
5
+ xml.description "View all posts"
6
+ xml.link url_for({:format=>:rss})
7
+
8
+ for post in @posts
9
+ xml.item do
10
+ xml.title post.title
11
+ xml.description cut_text(Sanitize.clean(post.content, SanteyBlog::ViewHelper::SANITIZER_CONFIG), path_to_content(post), 300)
12
+ xml.pubDate post.created_at.to_s(:rfc822)
13
+ xml.link path_to_content(post)
14
+ xml.guid path_to_content(post)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ =santey_title
2
+
3
+ .column.span-17.first.append-1
4
+ .posts_show
5
+ =render :partial=>"votes/vote", :locals=>{:voteable=>@post}
6
+ %h1
7
+ =@post.title
8
+ !=posted_at_helper(@post)
9
+ !=Sanitize.clean(@post.content, SanteyBlog::ViewHelper::SANITIZER_CONFIG)
10
+
11
+ .bottom_info
12
+ Tags:
13
+ - @post.tags.each do |tag|
14
+ =link_to tag.name, tag_path_helper(tag.name.gsub(/\./, "~dot~"))
15
+ %br/
16
+ Meta:
17
+ =link_to "permalink", path_to_content(@post)
18
+
19
+ %a{:href=>"#disqus_thread"} comments
20
+ =render :partial => "/includes/disqus_comments"
21
+
22
+ .column.span-6.last
23
+ =render :partial => "/includes/recent"
24
+ =render :partial => "/includes/tags"
25
+ =render :partial => "/includes/top"
data/config/routes.rb ADDED
@@ -0,0 +1,10 @@
1
+ Rails.application.routes.draw do |map|
2
+
3
+ match "/:year/:month/:day/:id" => "posts#show", :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ }
4
+ match "/:year(/:month(/:day))" => "posts#index", :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ }
5
+ match "/tag/:id" => 'posts#tag'
6
+ resources :posts
7
+
8
+ root :to => "posts#index"
9
+
10
+ end
@@ -0,0 +1,31 @@
1
+ require 'rails/generators'
2
+
3
+ class SanteyBlogGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+
6
+ class_option :css, :type => :boolean, :default => false, :desc => "--css option - Install stylesheets to public/stylesheets"
7
+ class_option :migrate, :type => :boolean, :default => false, :desc => "--migrate option - Install migrations to db/migrate"
8
+
9
+ def self.source_root
10
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
11
+ end
12
+
13
+ def self.next_migration_number(dirname)
14
+ Time.now.strftime("%Y%m%d%H%M%S")
15
+ end
16
+
17
+ def install_config
18
+ directory "initializers", "config/initializers"
19
+ end
20
+
21
+ # copy stylesheets to public folder
22
+ def install_css
23
+ directory "css", "public/stylesheets/santey_blog" if options[:css] == true
24
+ end
25
+
26
+ # copy migrations to db/migrate
27
+ def install_migrations
28
+ migration_template "migrations/create_posts.rb", File.join('db/migrate', "create_posts.rb") if options[:migrate] == true
29
+ end
30
+
31
+ end
@@ -0,0 +1,206 @@
1
+ h1. Blueprint CSS Framework Tutorial
2
+
3
+ Welcome to this tutorial on Blueprint. It will give you a thorough intro to what you can do with the framework, and a few notes on what you shouldn't do with it. Let's get started.
4
+
5
+ h2. About Blueprint
6
+
7
+ Blueprint is a CSS framework, designed to cut down on your development time. It gives you a solid foundation to build your CSS on top of, including some sensible default typography, a customizable grid, a print stylesheet and much more.
8
+
9
+ However, BP is not a silver bullet, and it's best suited for websites where each page may require its own design. Take a look at existing BP pages before deciding if the framework is right for you. You may also check out the test files in the @tests@ directory, which demonstrates most of the features in Blueprint.
10
+
11
+ The word "framework" may be a bit misleading in this context, since BP does not make suggestions on how you should organize or write your CSS. It's more like a "css toolbox" with helpful bits and pieces, from which you may pick and choose based on your needs.
12
+
13
+ h2. Structural Overview
14
+
15
+ From the bottom up, here are the CSS layers in Blueprint:
16
+
17
+ # *CSS reset*: Removes any default CSS rules set by each browser.
18
+ # *Typography*: Gives you some nice default typography and colors.
19
+ # *Grid*: Provides a set of CSS classes for making grid layouts.
20
+
21
+ The second part of Blueprint are the scripts, which let you customize most
22
+ aspects of the framework, from column count and widths, to output paths and
23
+ CSS class namespaces. We have two scripts:
24
+
25
+ # *Compressor*: For compressing and customizing the source files.
26
+ # *Validator*: For validating the Blueprint core files.
27
+
28
+ That's the quick overview, so now we can finally get into the details. First, we'll take
29
+ a look at the CSS in Blueprint. We'll then move on to the scripts, where I'll show you
30
+ how to customize the framework.
31
+
32
+ h2. Setting Up Blueprint
33
+
34
+ To use Blueprint, you must include three files in your HTML:
35
+
36
+ * @blueprint/screen.css@: All CSS for screen, projection viewing.
37
+ * @blueprint/print.css@: A basic stylesheet for printing.
38
+ * @blueprint/ie.css@: A few needed corrections for Internet Explorer
39
+
40
+ To include them, use the following HTML (make sure the href paths are correct):
41
+ <pre>
42
+ <link rel="stylesheet" href="css/blueprint/screen.css" type="text/css" media="screen, projection">
43
+ <link rel="stylesheet" href="css/blueprint/print.css" type="text/css" media="print">
44
+ <!--[if lt IE 8]>
45
+ <link rel="stylesheet" href="css/blueprint/ie.css" type="text/css" media="screen, projection">
46
+ <![endif]-->
47
+ </pre>
48
+ Remember to add trailing slashes if you're using XHTML (" />").
49
+
50
+ h2. Using the CSS in Blueprint
51
+
52
+ As mentioned before, there's basically three layers of CSS in Blueprint. The first two layers, the browser CSS reset and the default typography, apply themselves by changing the CSS of standard HTML elements. In other words, you don't need to change anything in these files. If you, for instance, want to change the font size, do this in your own stylesheet, so that it's easy to upgrade Blueprint when new versions arrive.
53
+
54
+ h3. Classes for Typography
55
+
56
+ While the typography of Blueprint mainly applies itself, there's a few classes
57
+ provided. Here's a list of their names and what they do:
58
+
59
+ <dl>
60
+ <dt>@.small@</dt><dd>Makes the text of this element smaller.</dd>
61
+ <dt>@.large@</dt><dd>Makes the text of this element larger.</dd>
62
+ <dt>@.hide@</dt><dd>Hides an element.</dd>
63
+ <dt>@.quiet@</dt><dd>Tones down the font color for this element.</dd>
64
+ <dt>@.loud@</dt><dd>Makes this elements text black.</dd>
65
+ <dt>@.highlight@</dt><dd>Adds a yellow background to the text.</dd>
66
+ <dt>@.added@</dt><dd>Adds green background to the text.</dd>
67
+ <dt>@.removed@</dt><dd>Adds red background to the text.</dd>
68
+ <dt>@.first@</dt><dd>Removes any left sided margin/padding from the element.</dd>
69
+ <dt>@.last@</dt><dd>Removes any right sided margin/padding from the element.</dd>
70
+ <dt>@.top@</dt><dd>Removes any top margin/padding from the element.</dd>
71
+ <dt>@.bottom@</dt><dd>Removes any bottom margin/padding from the element.</dd>
72
+ </dl>
73
+
74
+ h3. Styling Forms
75
+
76
+ To make Blueprint style your input elements, each text input element should
77
+ have the class @.text@, or @.title@, where @.text@ is the normal size,
78
+ and @.title@ gives you an input field with larger text.
79
+
80
+ There's also a few classes you may use for success and error messages:
81
+
82
+ <dl>
83
+ <dt>@div.error@</dt><dd>Creates an error box (red).</dd>
84
+ <dt>@div.notice@</dt><dd>Creates a box for notices (yellow).</dd>
85
+ <dt>@div.success@</dt><dd>Creates a box for success messages (green).</dd>
86
+ </dl>
87
+
88
+ h3. Creating a Grid
89
+
90
+ The third layer is the grid CSS classes, which is the tool Blueprint gives you to create almost any kind of grid layout for your site. Keep in mind that most of the CSS behind the grid can be customized (explained below). In this section however, I'm using the default settings.
91
+
92
+ The default grid is made up of 24 columns, each spanning 30px, with a 10px margin between each column. The total width comes to 950px, which is a good width for 1024x768 resolution displays. If you're interested in a narrower design, see the section on customizing the grid, below.
93
+
94
+ So how do you set up a grid? By using classes provided by Blueprint. To create a column, make a new @<div/>@, and apply one of the @.span-x@ classes to it. For instance, if you want a 3-column setup, with two narrow and one wide column, a header and a footer here's how you do it:
95
+
96
+ <pre>
97
+ <div class="container">
98
+ <div class="span-24">
99
+ The header
100
+ </div>
101
+
102
+ <div class="span-4">
103
+ The first column
104
+ </div>
105
+ <div class="span-16">
106
+ The center column
107
+ </div>
108
+ <div class="span-4 last">
109
+ The last column
110
+ </div>
111
+
112
+ <div class="span-24">
113
+ The footer
114
+ </div>
115
+ </div>
116
+ </pre>
117
+
118
+ In addition to the spans, there are two important classes you need to know about. First of all, every Blueprint site needs to be wrapped in a div with the class @.container@, which is usually placed right after the body tag.
119
+
120
+ Second, the last column in a row (which by default has 24 columns), needs the class @.last@ to remove its left hand margin. Note, however, that each @.span-24@ don't need the @.last@ class, since these always span the entire width of the page.
121
+
122
+ To create basic grids, this is all you need to know. The grid CSS however, provides many more classes for more intricate designs. To see some of them in action, check out the files in @tests/parts/@. These files demonstrate what's possible with the grid in Blueprint.
123
+
124
+ Here's a quick overview of the other classes you can use in to make your grid:
125
+
126
+ <dl>
127
+ <dt>@.append-x@</dt><dd>Appends x number of empty columns after a column.</dd>
128
+ <dt>@.prepend-x@</dt><dd>Preppends x number of empty columns before a column.</dd>
129
+ <dt>@.push-x@</dt><dd>Pushes a column x columns to the left. Can be used to swap columns.</dd>
130
+ <dt>@.pull-x@</dt><dd>Pulls a column x columns to the right. Can be used to swap columns.</dd>
131
+ <dt>@.border@</dt><dd>Applies a border to the right side of the column.</dd>
132
+ <dt>@.colborder@</dt><dd>Appends one empty column, with a border down the middle.</dd>
133
+ <dt>@.clear@</dt><dd>Makes a column drop below a row, regardless of space.</dd>
134
+ <dt>@.showgrid@</dt><dd>Add to container or column to see the grid and baseline.</dd>
135
+ </dl>
136
+
137
+ In this list, @x@ is a number from 1 through 23 for append/prepend and 1 through 24 for push/pull. These numbers will of course change if you set a new number of columns in the settings file.
138
+
139
+ Here's another example where we have four columns of equal width, with a border between the two first and the two last columns, as well as a four column gap in the middle:
140
+
141
+ <pre>
142
+ <div class="container">
143
+ <div class="span-5 border">
144
+ The first column
145
+ </div>
146
+ <div class="span-5 append-4">
147
+ The second column
148
+ </div>
149
+ <div class="span-5 border">
150
+ The third column
151
+ </div>
152
+ <div class="span-5 last">
153
+ The fourth (last) column
154
+ </div>
155
+ </div>
156
+ </pre>
157
+
158
+ You may also nest columns to achieve the desired layout. Here's a setup where we want four rectangles with two on top and two below on the first half of the page, and one single column spanning the second half of the page:
159
+
160
+ <pre>
161
+ <div class="container">
162
+ <div class="span-12">
163
+ <div class="span-6">
164
+ Top left
165
+ </div>
166
+ <div class="span-6 last">
167
+ Top right
168
+ </div>
169
+ <div class="span-6">
170
+ Bottom left
171
+ </div>
172
+ <div class="span-6 last">
173
+ Bottom right
174
+ </div>
175
+ </div>
176
+ <div class="span-12 last">
177
+ Second half of page
178
+ </div>
179
+ </div>
180
+ </pre>
181
+
182
+ Try this code in your browser it it's difficult to understand what it would look like. To see more examples on how to use these classes, check out @/tests/parts/grid.html@.
183
+
184
+ h2. The Scripts
185
+
186
+ Blueprint comes with two scripts: one for compressing and customizing the CSS, and one for validating the core CSS files, which is handy if you're making changes to these files.
187
+
188
+ h3. The Validator
189
+
190
+ The validator has a fairly simple job - validate the CSS in the core BP files. The script uses a bundled version of the W3C CSS validator to accomplish this. To run it, you'll need to have Ruby installed on your machine. You can then run the script like so: @$ ruby validate.rb@.
191
+
192
+ Note that there are a few validation errors shipping with Blueprint. These are known, and comes from a few CSS hacks needed to ensure consistent rendering across the vast browser field.
193
+
194
+ h3. The Compressor
195
+
196
+ As the files you'll include in your HTML are the compressed versions of the core CSS files, you'll have to recompress the core if you've made any changes. This is what the compressor script is for.
197
+
198
+ In addition this is where you customize the grid. To customize the grid, a special settings file is used, and the new CSS is generated once you run the compressor. The new compressed files will then reflect your settings file.
199
+
200
+ To recompress, you just have to run the script. This will parse the core CSS files and output new compressed files in the blueprint folder. As with the validator, Ruby has to be installed to use this script. In the @lib@ directory, run: @$ruby compress.rb@
201
+
202
+ Calling this file by itself will pull files from @blueprint/src@ and concatenate them into three files; @ie.css@, @print.css@, and @screen.css@. However, argument variables can be set to change how this works. Calling @$ruby compress.rb -h@ will reveal basic arguments you can pass to the script.
203
+
204
+ h3. Custom Settings
205
+
206
+ To learn how to use custom settings, read through the documentation within @lib/compress.rb@