blueprintr 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +35 -0
  5. data/Rakefile +53 -0
  6. data/VERSION +1 -0
  7. data/bin/blueprintr +3 -0
  8. data/blueprintr.gemspec +119 -0
  9. data/lib/blueprint-css/.gitignore +5 -0
  10. data/lib/blueprint-css/AUTHORS.textile +42 -0
  11. data/lib/blueprint-css/CHANGELOG +159 -0
  12. data/lib/blueprint-css/LICENSE +314 -0
  13. data/lib/blueprint-css/README.textile +81 -0
  14. data/lib/blueprint-css/TUTORIAL.textile +206 -0
  15. data/lib/blueprint-css/blueprint/ie.css +35 -0
  16. data/lib/blueprint-css/blueprint/plugins/buttons/icons/cross.png +0 -0
  17. data/lib/blueprint-css/blueprint/plugins/buttons/icons/key.png +0 -0
  18. data/lib/blueprint-css/blueprint/plugins/buttons/icons/tick.png +0 -0
  19. data/lib/blueprint-css/blueprint/plugins/buttons/readme.txt +32 -0
  20. data/lib/blueprint-css/blueprint/plugins/buttons/screen.css +97 -0
  21. data/lib/blueprint-css/blueprint/plugins/fancy-type/readme.txt +14 -0
  22. data/lib/blueprint-css/blueprint/plugins/fancy-type/screen.css +71 -0
  23. data/lib/blueprint-css/blueprint/plugins/link-icons/icons/doc.png +0 -0
  24. data/lib/blueprint-css/blueprint/plugins/link-icons/icons/email.png +0 -0
  25. data/lib/blueprint-css/blueprint/plugins/link-icons/icons/external.png +0 -0
  26. data/lib/blueprint-css/blueprint/plugins/link-icons/icons/feed.png +0 -0
  27. data/lib/blueprint-css/blueprint/plugins/link-icons/icons/im.png +0 -0
  28. data/lib/blueprint-css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  29. data/lib/blueprint-css/blueprint/plugins/link-icons/icons/visited.png +0 -0
  30. data/lib/blueprint-css/blueprint/plugins/link-icons/icons/xls.png +0 -0
  31. data/lib/blueprint-css/blueprint/plugins/link-icons/readme.txt +18 -0
  32. data/lib/blueprint-css/blueprint/plugins/link-icons/screen.css +40 -0
  33. data/lib/blueprint-css/blueprint/plugins/rtl/readme.txt +10 -0
  34. data/lib/blueprint-css/blueprint/plugins/rtl/screen.css +110 -0
  35. data/lib/blueprint-css/blueprint/print.css +29 -0
  36. data/lib/blueprint-css/blueprint/screen.css +258 -0
  37. data/lib/blueprint-css/blueprint/src/forms.css +65 -0
  38. data/lib/blueprint-css/blueprint/src/grid.css +280 -0
  39. data/lib/blueprint-css/blueprint/src/grid.png +0 -0
  40. data/lib/blueprint-css/blueprint/src/ie.css +76 -0
  41. data/lib/blueprint-css/blueprint/src/print.css +85 -0
  42. data/lib/blueprint-css/blueprint/src/reset.css +45 -0
  43. data/lib/blueprint-css/blueprint/src/typography.css +106 -0
  44. data/lib/blueprint-css/lib/blueprint/blueprint.rb +39 -0
  45. data/lib/blueprint-css/lib/blueprint/compressor.rb +265 -0
  46. data/lib/blueprint-css/lib/blueprint/core_ext.rb +39 -0
  47. data/lib/blueprint-css/lib/blueprint/css_parser.rb +69 -0
  48. data/lib/blueprint-css/lib/blueprint/custom_layout.rb +71 -0
  49. data/lib/blueprint-css/lib/blueprint/grid.css.erb +146 -0
  50. data/lib/blueprint-css/lib/blueprint/grid_builder.rb +54 -0
  51. data/lib/blueprint-css/lib/blueprint/namespace.rb +38 -0
  52. data/lib/blueprint-css/lib/blueprint/semantic_class_names.rb +57 -0
  53. data/lib/blueprint-css/lib/blueprint/validate/COPYRIGHT.html +93 -0
  54. data/lib/blueprint-css/lib/blueprint/validate/JIGSAW_COPYRIGHT +64 -0
  55. data/lib/blueprint-css/lib/blueprint/validate/README.html +83 -0
  56. data/lib/blueprint-css/lib/blueprint/validate/XERCES_COPYING.txt +56 -0
  57. data/lib/blueprint-css/lib/blueprint/validate/css-validator-javadoc.jar +0 -0
  58. data/lib/blueprint-css/lib/blueprint/validate/css-validator.jar +0 -0
  59. data/lib/blueprint-css/lib/blueprint/validate/jigsaw.jar +0 -0
  60. data/lib/blueprint-css/lib/blueprint/validate/xerces.jar +0 -0
  61. data/lib/blueprint-css/lib/blueprint/validator.rb +49 -0
  62. data/lib/blueprint-css/lib/compress.rb +149 -0
  63. data/lib/blueprint-css/lib/settings.example.yml +33 -0
  64. data/lib/blueprint-css/lib/validate.rb +15 -0
  65. data/lib/blueprint-css/templates/psd/fixed-width.psd +0 -0
  66. data/lib/blueprint-css/tests/index.html +83 -0
  67. data/lib/blueprint-css/tests/parts/elements.html +247 -0
  68. data/lib/blueprint-css/tests/parts/forms.html +191 -0
  69. data/lib/blueprint-css/tests/parts/grid.html +163 -0
  70. data/lib/blueprint-css/tests/parts/sample.html +75 -0
  71. data/lib/blueprint-css/tests/parts/test-small.jpg +0 -0
  72. data/lib/blueprint-css/tests/parts/test.jpg +0 -0
  73. data/lib/blueprint-css/tests/parts/valid.png +0 -0
  74. data/lib/blueprintr.rb +23 -0
  75. data/test/helper.rb +9 -0
  76. data/test/test_blueprintr.rb +14 -0
  77. metadata +139 -0
@@ -0,0 +1,76 @@
1
+ /* --------------------------------------------------------------
2
+
3
+ ie.css
4
+
5
+ Contains every hack for Internet Explorer,
6
+ so that our core files stay sweet and nimble.
7
+
8
+ -------------------------------------------------------------- */
9
+
10
+ /* Make sure the layout is centered in IE5 */
11
+ body { text-align: center; }
12
+ .container { text-align: left; }
13
+
14
+ /* Fixes IE margin bugs */
15
+ * html .column, * html .span-1, * html .span-2,
16
+ * html .span-3, * html .span-4, * html .span-5,
17
+ * html .span-6, * html .span-7, * html .span-8,
18
+ * html .span-9, * html .span-10, * html .span-11,
19
+ * html .span-12, * html .span-13, * html .span-14,
20
+ * html .span-15, * html .span-16, * html .span-17,
21
+ * html .span-18, * html .span-19, * html .span-20,
22
+ * html .span-21, * html .span-22, * html .span-23,
23
+ * html .span-24 { display:inline; overflow-x: hidden; }
24
+
25
+
26
+ /* Elements
27
+ -------------------------------------------------------------- */
28
+
29
+ /* Fixes incorrect styling of legend in IE6. */
30
+ * html legend { margin:0px -8px 16px 0; padding:0; }
31
+
32
+ /* Fixes wrong line-height on sup/sub in IE. */
33
+ sup { vertical-align:text-top; }
34
+ sub { vertical-align:text-bottom; }
35
+
36
+ /* Fixes IE7 missing wrapping of code elements. */
37
+ html>body p code { *white-space: normal; }
38
+
39
+ /* IE 6&7 has problems with setting proper <hr> margins. */
40
+ hr { margin:-8px auto 11px; }
41
+
42
+ /* Explicitly set interpolation, allowing dynamically resized images to not look horrible */
43
+ img { -ms-interpolation-mode:bicubic; }
44
+
45
+ /* Clearing
46
+ -------------------------------------------------------------- */
47
+
48
+ /* Makes clearfix actually work in IE */
49
+ .clearfix, .container { display:inline-block; }
50
+ * html .clearfix,
51
+ * html .container { height:1%; }
52
+
53
+
54
+ /* Forms
55
+ -------------------------------------------------------------- */
56
+
57
+ /* Fixes padding on fieldset */
58
+ fieldset { padding-top:0; }
59
+
60
+ /* Makes classic textareas in IE 6 resemble other browsers */
61
+ textarea { overflow:auto; }
62
+
63
+ /* Fixes rule that IE 6 ignores */
64
+ input.text, input.title, textarea { background-color:#fff; border:1px solid #bbb; }
65
+ input.text:focus, input.title:focus { border-color:#666; }
66
+ input.text, input.title, textarea, select { margin:0.5em 0; }
67
+ input.checkbox, input.radio { position:relative; top:.25em; }
68
+
69
+ /* Fixes alignment of inline form elements */
70
+ form.inline div, form.inline p { vertical-align:middle; }
71
+ form.inline label { position:relative;top:-0.25em; }
72
+ form.inline input.checkbox, form.inline input.radio,
73
+ form.inline input.button, form.inline button {
74
+ margin:0.5em 0;
75
+ }
76
+ button, input.button { position:relative;top:0.25em; }
@@ -0,0 +1,85 @@
1
+ /* --------------------------------------------------------------
2
+
3
+ print.css
4
+ * Gives you some sensible styles for printing pages.
5
+ * See Readme file in this directory for further instructions.
6
+
7
+ Some additions you'll want to make, customized to your markup:
8
+ #header, #footer, #navigation { display:none; }
9
+
10
+ -------------------------------------------------------------- */
11
+
12
+ body {
13
+ line-height: 1.5;
14
+ font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
15
+ color:#000;
16
+ background: none;
17
+ font-size: 10pt;
18
+ }
19
+
20
+
21
+ /* Layout
22
+ -------------------------------------------------------------- */
23
+
24
+ .container {
25
+ background: none;
26
+ }
27
+
28
+ hr {
29
+ background:#ccc;
30
+ color:#ccc;
31
+ width:100%;
32
+ height:2px;
33
+ margin:2em 0;
34
+ padding:0;
35
+ border:none;
36
+ }
37
+ hr.space {
38
+ background: #fff;
39
+ color: #fff;
40
+ visibility: hidden;
41
+ }
42
+
43
+
44
+ /* Text
45
+ -------------------------------------------------------------- */
46
+
47
+ h1,h2,h3,h4,h5,h6 { font-family: "Helvetica Neue", Arial, "Lucida Grande", sans-serif; }
48
+ code { font:.9em "Courier New", Monaco, Courier, monospace; }
49
+
50
+ a img { border:none; }
51
+ p img.top { margin-top: 0; }
52
+
53
+ blockquote {
54
+ margin:1.5em;
55
+ padding:1em;
56
+ font-style:italic;
57
+ font-size:.9em;
58
+ }
59
+
60
+ .small { font-size: .9em; }
61
+ .large { font-size: 1.1em; }
62
+ .quiet { color: #999; }
63
+ .hide { display:none; }
64
+
65
+
66
+ /* Links
67
+ -------------------------------------------------------------- */
68
+
69
+ a:link, a:visited {
70
+ background: transparent;
71
+ font-weight:700;
72
+ text-decoration: underline;
73
+ }
74
+
75
+ a:link:after, a:visited:after {
76
+ content: " (" attr(href) ")";
77
+ font-size: 90%;
78
+ }
79
+
80
+ /* If you're having trouble printing relative links, uncomment and customize this:
81
+ (note: This is valid CSS3, but it still won't go through the W3C CSS Validator) */
82
+
83
+ /* a[href^="/"]:after {
84
+ content: " (http://www.yourdomain.com" attr(href) ") ";
85
+ } */
@@ -0,0 +1,45 @@
1
+ /* --------------------------------------------------------------
2
+
3
+ reset.css
4
+ * Resets default browser CSS.
5
+
6
+ -------------------------------------------------------------- */
7
+
8
+ html, body, div, span, object, iframe,
9
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
10
+ a, abbr, acronym, address, code,
11
+ del, dfn, em, img, q, dl, dt, dd, ol, ul, li,
12
+ fieldset, form, label, legend,
13
+ table, caption, tbody, tfoot, thead, tr, th, td,
14
+ article, aside, dialog, figure, footer, header,
15
+ hgroup, nav, section {
16
+ margin: 0;
17
+ padding: 0;
18
+ border: 0;
19
+ font-weight: inherit;
20
+ font-style: inherit;
21
+ font-size: 100%;
22
+ font-family: inherit;
23
+ vertical-align: baseline;
24
+ }
25
+
26
+ article, aside, dialog, figure, footer, header,
27
+ hgroup, nav, section {
28
+ display:block;
29
+ }
30
+
31
+ body {
32
+ line-height: 1.5;
33
+ }
34
+
35
+ /* Tables still need 'cellspacing="0"' in the markup. */
36
+ table { border-collapse: separate; border-spacing: 0; }
37
+ caption, th, td { text-align: left; font-weight: normal; }
38
+ table, td, th { vertical-align: middle; }
39
+
40
+ /* Remove possible quote marks (") from <q>, <blockquote>. */
41
+ blockquote:before, blockquote:after, q:before, q:after { content: ""; }
42
+ blockquote, q { quotes: "" ""; }
43
+
44
+ /* Remove annoying border on linked images. */
45
+ a img { border: none; }
@@ -0,0 +1,106 @@
1
+ /* --------------------------------------------------------------
2
+
3
+ typography.css
4
+ * Sets up some sensible default typography.
5
+
6
+ -------------------------------------------------------------- */
7
+
8
+ /* Default font settings.
9
+ The font-size percentage is of 16px. (0.75 * 16px = 12px) */
10
+ html { font-size:100.01%; }
11
+ body {
12
+ font-size: 75%;
13
+ color: #222;
14
+ background: #fff;
15
+ font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
16
+ }
17
+
18
+
19
+ /* Headings
20
+ -------------------------------------------------------------- */
21
+
22
+ h1,h2,h3,h4,h5,h6 { font-weight: normal; color: #111; }
23
+
24
+ h1 { font-size: 3em; line-height: 1; margin-bottom: 0.5em; }
25
+ h2 { font-size: 2em; margin-bottom: 0.75em; }
26
+ h3 { font-size: 1.5em; line-height: 1; margin-bottom: 1em; }
27
+ h4 { font-size: 1.2em; line-height: 1.25; margin-bottom: 1.25em; }
28
+ h5 { font-size: 1em; font-weight: bold; margin-bottom: 1.5em; }
29
+ h6 { font-size: 1em; font-weight: bold; }
30
+
31
+ h1 img, h2 img, h3 img,
32
+ h4 img, h5 img, h6 img {
33
+ margin: 0;
34
+ }
35
+
36
+
37
+ /* Text elements
38
+ -------------------------------------------------------------- */
39
+
40
+ p { margin: 0 0 1.5em; }
41
+ p img.left { float: left; margin: 1.5em 1.5em 1.5em 0; padding: 0; }
42
+ p img.right { float: right; margin: 1.5em 0 1.5em 1.5em; }
43
+
44
+ a:focus,
45
+ a:hover { color: #000; }
46
+ a { color: #009; text-decoration: underline; }
47
+
48
+ blockquote { margin: 1.5em; color: #666; font-style: italic; }
49
+ strong { font-weight: bold; }
50
+ em,dfn { font-style: italic; }
51
+ dfn { font-weight: bold; }
52
+ sup, sub { line-height: 0; }
53
+
54
+ abbr,
55
+ acronym { border-bottom: 1px dotted #666; }
56
+ address { margin: 0 0 1.5em; font-style: italic; }
57
+ del { color:#666; }
58
+
59
+ pre { margin: 1.5em 0; white-space: pre; }
60
+ pre,code,tt { font: 1em 'andale mono', 'lucida console', monospace; line-height: 1.5; }
61
+
62
+
63
+ /* Lists
64
+ -------------------------------------------------------------- */
65
+
66
+ li ul,
67
+ li ol { margin: 0; }
68
+ ul, ol { margin: 0 1.5em 1.5em 0; padding-left: 3.333em; }
69
+
70
+ ul { list-style-type: disc; }
71
+ ol { list-style-type: decimal; }
72
+
73
+ dl { margin: 0 0 1.5em 0; }
74
+ dl dt { font-weight: bold; }
75
+ dd { margin-left: 1.5em;}
76
+
77
+
78
+ /* Tables
79
+ -------------------------------------------------------------- */
80
+
81
+ table { margin-bottom: 1.4em; width:100%; }
82
+ th { font-weight: bold; }
83
+ thead th { background: #c3d9ff; }
84
+ th,td,caption { padding: 4px 10px 4px 5px; }
85
+ tr.even td { background: #e5ecf9; }
86
+ tfoot { font-style: italic; }
87
+ caption { background: #eee; }
88
+
89
+
90
+ /* Misc classes
91
+ -------------------------------------------------------------- */
92
+
93
+ .small { font-size: .8em; margin-bottom: 1.875em; line-height: 1.875em; }
94
+ .large { font-size: 1.2em; line-height: 2.5em; margin-bottom: 1.25em; }
95
+ .hide { display: none; }
96
+
97
+ .quiet { color: #666; }
98
+ .loud { color: #000; }
99
+ .highlight { background:#ff0; }
100
+ .added { background:#060; color: #fff; }
101
+ .removed { background:#900; color: #fff; }
102
+
103
+ .first { margin-left:0; padding-left:0; }
104
+ .last { margin-right:0; padding-right:0; }
105
+ .top { margin-top:0; padding-top:0; }
106
+ .bottom { margin-bottom:0; padding-bottom:0; }
@@ -0,0 +1,39 @@
1
+ require 'fileutils'
2
+ module Blueprint
3
+ # path to the root Blueprint directory
4
+ ROOT_PATH = File.join(File.expand_path(File.dirname(__FILE__)), "../../")
5
+ # path to where the Blueprint CSS files are stored
6
+ BLUEPRINT_ROOT_PATH = File.join(Blueprint::ROOT_PATH, 'blueprint')
7
+ # path to where the Blueprint CSS raw CSS files are stored
8
+ SOURCE_PATH = File.join(Blueprint::BLUEPRINT_ROOT_PATH, 'src')
9
+ # path to where the Blueprint CSS generated test files are stored
10
+ TEST_PATH = File.join(Blueprint::ROOT_PATH, 'tests')
11
+ # path to the root of the Blueprint scripts
12
+ LIB_PATH = File.join(Blueprint::ROOT_PATH, 'lib', 'blueprint')
13
+ # path to where Blueprint plugins are stored
14
+ PLUGINS_PATH = File.join(Blueprint::BLUEPRINT_ROOT_PATH, 'plugins')
15
+ # settings YAML file where custom user settings are saved
16
+ SETTINGS_FILE = File.join(Blueprint::ROOT_PATH, 'lib', 'settings.yml')
17
+ # path to validator jar file to validate generated CSS files
18
+ VALIDATOR_FILE = File.join(Blueprint::LIB_PATH, 'validate', 'css-validator.jar')
19
+ # hash of compressed and source CSS files
20
+ CSS_FILES = {
21
+ 'screen.css' => ['reset.css', 'typography.css', 'forms.css', 'grid.css'],
22
+ 'print.css' => ['print.css'],
23
+ 'ie.css' => ['ie.css']
24
+ }
25
+
26
+ # default number of columns for Blueprint layout
27
+ COLUMN_COUNT = 24
28
+ # default column width (in pixels) for Blueprint layout
29
+ COLUMN_WIDTH = 30
30
+ # default gutter width (in pixels) for Blueprint layout
31
+ GUTTER_WIDTH = 10
32
+
33
+ INPUT_PADDING = 5
34
+ INPUT_BORDER = 1
35
+ end
36
+
37
+ Dir["#{File.join(Blueprint::LIB_PATH)}/*"].each do |file|
38
+ require "#{file}" if file =~ /\.rb$/ && file !~ /blueprint.rb/
39
+ end
@@ -0,0 +1,265 @@
1
+ require 'yaml'
2
+ require 'optparse'
3
+ module Blueprint
4
+ class Compressor
5
+ TEST_FILES = ['index.html',
6
+ 'parts/elements.html',
7
+ 'parts/forms.html',
8
+ 'parts/grid.html',
9
+ 'parts/sample.html']
10
+
11
+ attr_accessor :namespace, :custom_css, :custom_layout, :semantic_classes, :project_name, :plugins
12
+ attr_reader :custom_path, :loaded_from_settings, :destination_path, :script_name
13
+
14
+ # overridden setter method for destination_path
15
+ # also sets custom_path flag on Blueprint::Compressor instance
16
+ def destination_path=(path)
17
+ @destination_path = path
18
+ @custom_path = @destination_path != Blueprint::BLUEPRINT_ROOT_PATH
19
+ end
20
+
21
+ # constructor
22
+ def initialize
23
+ # set up defaults
24
+ @script_name = File.basename($0)
25
+ @loaded_from_settings = false
26
+ @settings_file = Blueprint::SETTINGS_FILE
27
+ self.namespace = ""
28
+ self.destination_path = Blueprint::BLUEPRINT_ROOT_PATH
29
+ self.custom_layout = CustomLayout.new
30
+ self.project_name = nil
31
+ self.custom_css = {}
32
+ self.semantic_classes = {}
33
+ self.plugins = []
34
+
35
+ self.options.parse!(ARGV)
36
+ initialize_project_from_yaml(self.project_name)
37
+ end
38
+
39
+ # generates output CSS based on any args passed in
40
+ # overwrites any existing CSS, as well as grid.png and tests
41
+ def generate!
42
+ output_header # information to the user (in the console) describing custom settings
43
+ generate_css_files # loops through Blueprint::CSS_FILES to generate output CSS
44
+ generate_tests # updates HTML with custom namespaces in order to test the generated library. TODO: have tests kick out to custom location
45
+ output_footer # informs the user that the CSS generation process is complete
46
+ end
47
+
48
+ def options #:nodoc:#
49
+ OptionParser.new do |o|
50
+ o.set_summary_indent(' ')
51
+ o.banner = "Usage: #{@script_name} [options]"
52
+ o.define_head "Blueprint Compressor"
53
+ o.separator ""
54
+ o.separator "options"
55
+ o.on( "-fSETTINGS_FILE", "--settings_file=SETTINGS_FILE", String,
56
+ "Specify a non-default settings file path.") { |file| @settings_file = file }
57
+ o.on( "-oOUTPUT_PATH", "--output_path=OUTPUT_PATH", String,
58
+ "Define a different path to output generated CSS files to. Default is current working directory.") { |path| self.destination_path = path }
59
+ o.on( "-nBP_NAMESPACE", "--namespace=BP_NAMESPACE", String,
60
+ "Define a namespace prepended to all Blueprint classes (e.g. .your-ns-span-24)") { |ns| self.namespace = ns }
61
+ o.on( "-pPROJECT_NAME", "--project=PROJECT_NAME", String,
62
+ "If using the settings.yml file, PROJECT_NAME is the project name you want to export") {|project| @project_name = project }
63
+ o.on( "--column_width=COLUMN_WIDTH", Integer,
64
+ "Set a new column width (in pixels) for the output grid") {|cw| self.custom_layout.column_width = cw }
65
+ o.on( "--gutter_width=GUTTER_WIDTH", Integer,
66
+ "Set a new gutter width (in pixels) for the output grid") {|gw| self.custom_layout.gutter_width = gw }
67
+ o.on( "--column_count=COLUMN_COUNT", Integer,
68
+ "Set a new column count for the output grid") {|cc| self.custom_layout.column_count = cc }
69
+ #o.on("-v", "--verbose", "Turn on verbose output.") { |$verbose| }
70
+ o.on("-h", "--help", "Show this help message.") { puts o; exit }
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ # attempts to load output settings from settings.yml
77
+ def initialize_project_from_yaml(project_name = nil)
78
+ # ensures project_name is set and settings.yml is present
79
+ return unless (project_name && File.exist?(@settings_file))
80
+
81
+ # loads yaml into hash
82
+ projects = YAML::load(File.path_to_string(@settings_file))
83
+
84
+ if (project = projects[project_name]) # checks to see if project info is present
85
+ self.namespace = project['namespace'] || ""
86
+ self.destination_path = (self.destination_path == Blueprint::BLUEPRINT_ROOT_PATH ? project['path'] : self.destination_path) || Blueprint::BLUEPRINT_ROOT_PATH
87
+ self.custom_css = project['custom_css'] || {}
88
+ self.semantic_classes = project['semantic_classes'] || {}
89
+ self.plugins = project['plugins'] || []
90
+
91
+ if (layout = project['custom_layout'])
92
+ self.custom_layout = CustomLayout.new(:column_count => layout['column_count'], :column_width => layout['column_width'], :gutter_width => layout['gutter_width'], :input_padding => layout['input_padding'], :input_border => layout['input_border'])
93
+ end
94
+ @loaded_from_settings = true
95
+ end
96
+ end
97
+
98
+ def generate_css_files
99
+ Blueprint::CSS_FILES.each do |output_file_name, css_source_file_names|
100
+ css_output_path = File.join(destination_path, output_file_name)
101
+ puts "\n Assembling to #{custom_path ? css_output_path : "default blueprint path"}"
102
+
103
+ # CSS file generation
104
+ css_output = css_file_header # header included on all three Blueprint-generated files
105
+ css_output += "\n\n"
106
+
107
+ # Iterate through src/ .css files and compile to individual core compressed file
108
+ css_source_file_names.each do |css_source_file|
109
+ puts " + src/#{css_source_file}"
110
+ css_output += "/* #{css_source_file} */\n" if css_source_file_names.any?
111
+
112
+ source_options = if self.custom_layout && css_source_file == 'grid.css'
113
+ self.custom_layout.generate_grid_css
114
+ else
115
+ File.path_to_string File.join(Blueprint::SOURCE_PATH, css_source_file)
116
+ end
117
+
118
+ css_output += Blueprint::CSSParser.new(source_options, :namespace => namespace).to_s
119
+ css_output += "\n"
120
+ end
121
+
122
+ #append CSS from plugins
123
+ css_output = append_plugin_css(css_output, output_file_name)
124
+
125
+ # append CSS from custom files
126
+ css_output = append_custom_css(css_output, output_file_name)
127
+
128
+ #save CSS to correct path, stripping out any extra whitespace at the end of the file
129
+ File.string_to_file(css_output.rstrip, css_output_path)
130
+ end
131
+
132
+ # append semantic class names if set
133
+ append_semantic_classes
134
+
135
+ #attempt to generate a grid.png file
136
+ if (grid_builder = GridBuilder.new(:column_width => self.custom_layout.column_width, :gutter_width => self.custom_layout.gutter_width, :output_path => File.join(self.destination_path, 'src')))
137
+ grid_builder.generate!
138
+ end
139
+ end
140
+
141
+ def append_custom_css(css, current_file_name)
142
+ # check to see if a custom (non-default) location was used for output files
143
+ # if custom path is used, handle custom CSS, if any
144
+ return css unless self.custom_path and self.custom_css[current_file_name]
145
+
146
+ self.custom_css[current_file_name].each do |custom_css|
147
+ overwrite_base = custom_css || "my-#{current_file_name}"
148
+ overwrite_path = File.join(destination_path, overwrite_base)
149
+ overwrite_css = File.exists?(overwrite_path) ? File.path_to_string(overwrite_path) : ""
150
+
151
+ # if there's CSS present, add it to the CSS output
152
+ unless overwrite_css.blank?
153
+ puts " + custom styles (#{custom_css})\n"
154
+ css += "/* #{overwrite_base} */\n"
155
+ css += CSSParser.new(overwrite_css).to_s + "\n"
156
+ end
157
+ end
158
+
159
+ css
160
+ end
161
+
162
+ def append_plugin_css(css, current_file_name)
163
+ return css unless self.plugins.any?
164
+
165
+ plugin_css = ""
166
+
167
+ self.plugins.each do |plugin|
168
+ plugin_file_specific = File.join(Blueprint::PLUGINS_PATH, plugin, current_file_name)
169
+ plugin_file_generic = File.join(Blueprint::PLUGINS_PATH, plugin, "#{plugin}.css")
170
+
171
+ file = if File.exists?(plugin_file_specific)
172
+ plugin_file_specific
173
+ elsif File.exists?(plugin_file_generic) && current_file_name =~ /^screen|print/
174
+ plugin_file_generic
175
+ end
176
+
177
+ if file
178
+ puts " + #{plugin} plugin\n"
179
+ plugin_css += "/* #{plugin} */\n"
180
+ plugin_css += CSSParser.new(File.path_to_string(file)).to_s + "\n"
181
+
182
+ Dir.glob(File.join(File.dirname(file), "**", "**")).each do |cp|
183
+ short_path = cp.gsub(/#{File.dirname(file)}./ , '')
184
+ # make directory if it doesn't exist
185
+ directory = File.dirname(short_path)
186
+ FileUtils.mkdir_p(File.join(destination_path, directory)) unless directory == "."
187
+ FileUtils.cp cp, File.join(destination_path, short_path) unless File.directory?(File.join(File.dirname(file), short_path)) || cp == file
188
+ end
189
+ end
190
+ end
191
+
192
+ css += plugin_css
193
+ end
194
+
195
+ def append_semantic_classes
196
+ screen_output_path = File.join(self.destination_path, "screen.css")
197
+ semantic_styles = SemanticClassNames.new(:namespace => self.namespace, :source_file => screen_output_path).css_from_assignments(self.semantic_classes)
198
+ return if semantic_styles.blank?
199
+
200
+ css = File.path_to_string(screen_output_path)
201
+ css += "\n\n/* semantic class names */\n"
202
+ css += semantic_styles
203
+ File.string_to_file(css.rstrip, screen_output_path)
204
+ end
205
+
206
+ def generate_tests
207
+ # puts "\n Updating namespace to \"#{namespace}\" in test files:"
208
+ # test_files = Compressor::TEST_FILES.map {|f| File.join(Blueprint::TEST_PATH, *f.split(/\//))}
209
+ #
210
+ # test_files.each do |file|
211
+ # puts " + #{file}"
212
+ # Namespace.new(file, namespace)
213
+ # end
214
+ end
215
+
216
+ def output_header
217
+ puts "\n"
218
+ puts " #{"*" * 100}"
219
+ puts " **"
220
+ puts " ** Blueprint CSS Compressor"
221
+ puts " **"
222
+ puts " ** Builds compressed files from the source directory."
223
+ puts " **"
224
+ puts " ** Loaded from settings.yml" if loaded_from_settings
225
+ puts " ** Namespace: '#{namespace}'" unless namespace.blank?
226
+ puts " ** Output to: #{destination_path}"
227
+ puts " ** Grid Settings:"
228
+ puts " ** - Column Count: #{self.custom_layout.column_count}"
229
+ puts " ** - Column Width: #{self.custom_layout.column_width}px"
230
+ puts " ** - Gutter Width: #{self.custom_layout.gutter_width}px"
231
+ puts " ** - Total Width : #{self.custom_layout.page_width}px"
232
+ puts " **"
233
+ puts " #{"*" * 100}"
234
+ end
235
+
236
+ def output_footer
237
+ puts "\n\n"
238
+ puts " #{"*" * 100}"
239
+ puts " **"
240
+ puts " ** Done!"
241
+ puts " ** Your compressed files and test files are now up-to-date."
242
+ puts " **"
243
+ puts " #{"*" * 100}\n\n"
244
+ end
245
+
246
+ def css_file_header
247
+ %(/* -----------------------------------------------------------------------
248
+
249
+
250
+ Blueprint CSS Framework 0.9
251
+ http://blueprintcss.org
252
+
253
+ * Copyright (c) 2007-Present. See LICENSE for more info.
254
+ * See README for instructions on how to use Blueprint.
255
+ * For credits and origins, see AUTHORS.
256
+ * This is a compressed file. See the sources in the 'src' directory.
257
+
258
+ ----------------------------------------------------------------------- */)
259
+ end
260
+
261
+ def putsv(str)
262
+ puts str if $verbose
263
+ end
264
+ end
265
+ end