serve 1.5.0.pre5 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/CHANGELOG.rdoc +4 -2
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +13 -8
  4. data/VERSION +1 -1
  5. data/lib/serve/application.rb +34 -17
  6. data/lib/serve/{templates → bootstrap}/Gemfile +3 -3
  7. data/lib/serve/{templates/README.markdown → bootstrap/README.md} +0 -0
  8. data/lib/serve/{templates → bootstrap}/compass.config +0 -0
  9. data/lib/serve/{templates → bootstrap}/config.ru +1 -1
  10. data/lib/serve/{templates → bootstrap}/gitignore +0 -0
  11. data/lib/serve/export.rb +3 -12
  12. data/lib/serve/path.rb +24 -0
  13. data/lib/serve/project.rb +96 -53
  14. data/lib/serve/templates/default/public/images/serve-logo.png +0 -0
  15. data/lib/serve/templates/default/stylesheets/modules/_all.scss +3 -0
  16. data/lib/serve/templates/default/stylesheets/modules/_links.scss +15 -0
  17. data/lib/serve/templates/default/stylesheets/modules/_typography.scss +133 -0
  18. data/lib/serve/templates/default/stylesheets/modules/_utility.scss +15 -0
  19. data/lib/serve/templates/default/stylesheets/partials/_base.scss +47 -0
  20. data/lib/serve/templates/default/stylesheets/partials/_content.scss +37 -0
  21. data/lib/serve/templates/default/stylesheets/partials/_layout.scss +42 -0
  22. data/lib/serve/templates/default/stylesheets/screen.scss +7 -0
  23. data/lib/serve/templates/default/views/_layout.html.erb +1 -0
  24. data/lib/serve/templates/default/views/index.redirect +15 -0
  25. data/lib/serve/templates/default/views/layouts/default.html.erb +31 -0
  26. data/lib/serve/templates/default/views/view_helpers.rb +25 -0
  27. data/lib/serve/templates/default/views/welcome.html.erb +36 -0
  28. data/spec/application_spec.rb +21 -19
  29. data/spec/project_spec.rb +34 -34
  30. data/{lib/serve/templates → spec/stylesheets}/application.scss +0 -0
  31. data/{lib/serve/templates → spec/views}/_layout.html.erb +0 -0
  32. data/{lib/serve/templates → spec/views}/hello.html.erb +0 -0
  33. data/{lib/serve/templates → spec/views}/index.redirect +0 -0
  34. data/{lib/serve/templates → spec/views}/view_helpers.rb +0 -0
  35. metadata +31 -24
@@ -0,0 +1,3 @@
1
+ @import "utility";
2
+ @import "links";
3
+ @import "typography";
@@ -0,0 +1,15 @@
1
+ @mixin basic-link($color: $link-color, $visited: $color, $hover: $color, $decoration: "underline") {
2
+ &:link {
3
+ color: $color;
4
+ @if $decoration == "underline" { text-decoration: underline; }
5
+ @if $decoration == "plain" { text-decoration: none; }
6
+ }
7
+ &:visited {
8
+ color: $visited;
9
+ }
10
+ &:hover {
11
+ color: $hover;
12
+ @if $decoration == "underline" { text-decoration: none; }
13
+ @if $decoration == "plain" { text-decoration: underline; }
14
+ }
15
+ }
@@ -0,0 +1,133 @@
1
+ // This should be applied to the body of the document:
2
+ //
3
+ // body { @include base-font; }
4
+ //
5
+ @mixin base-font {
6
+ color: $text-color;
7
+ font-family: $base-font-family;
8
+ font-size: $base-font-size;
9
+ line-height: $base-line-height;
10
+ }
11
+
12
+ // Typically this should be applied to content portion of the document:
13
+ //
14
+ // .content { @include basic-typography; }
15
+ //
16
+ // Pass true if you would like to use indented instead of block level paragraphs:
17
+ //
18
+ // .content { @include basic-typography(true); }
19
+ //
20
+ @mixin basic-typography($indented: $indented-paragraphs) {
21
+ @include inline-elements;
22
+ @include headings;
23
+ @if $indented {
24
+ @include indented-paragraphs;
25
+ } @else {
26
+ @include block-paragraphs;
27
+ }
28
+ @include lists;
29
+ @include fixed-font-elements;
30
+ }
31
+
32
+ // Style inline elements like strong, em, abbr, etc...
33
+ @mixin inline-elements($loud-color: $loud-color) {
34
+ @include bold-italic-elements($loud-color);
35
+ @include misc-inline-elements;
36
+ }
37
+
38
+ // Basic styles for strong, b, em, and i
39
+ @mixin bold-italic-elements($loud-color: $loud-color) {
40
+ strong, b { color: $loud-color; font-weight: bold; }
41
+ em, i { font-style: italic; }
42
+ }
43
+
44
+ // Basic styles for abbr, acronym, sub, sup, and span.caps
45
+ @mixin misc-inline-elements {
46
+ abbr, acronym { border-bottom: 1px dotted soften($text-color, 2); }
47
+ sub, sup { font-size: 85%; }
48
+ sub { vertical-align: sub; }
49
+ sup { vertical-align: super; }
50
+ span.caps { font-size: 95%; }
51
+ }
52
+
53
+ // Basic styles for headings
54
+ @mixin headings($color: $header-color, $line-height: $base-line-height) {
55
+ h1, h2, h3, h4, h5, h6 {
56
+ color: $color;
57
+ margin: 1em 0;
58
+ }
59
+ h1 {
60
+ font-weight: bold;
61
+ font-size: 200%;
62
+ line-height: 0.785 * $line-height;
63
+ margin: 0.75em 0;
64
+ }
65
+ h2 {
66
+ font-weight: bold;
67
+ font-size: 170%;
68
+ line-height: 0.785 * $line-height;
69
+ }
70
+ h3 {
71
+ font-weight: bold;
72
+ font-size: 140%;
73
+ line-height: 0.835 * $line-height;
74
+ margin: 1.25em 0 0.5em;
75
+ }
76
+ h4 {
77
+ font-weight: bold;
78
+ font-size: 110%;
79
+ line-height: 0.9 * $line-height;
80
+ margin: 0.5em 0 0.5em;
81
+ }
82
+ h5 {
83
+ font-style: italic;
84
+ font-size: 110%;
85
+ line-height: $line-height;
86
+ margin: 0.65em 0;
87
+ }
88
+ h6 {
89
+ font-weight: bold;
90
+ margin-bottom: -0.75em;
91
+ }
92
+ }
93
+
94
+ // Block-level paragraphs with vertical margin
95
+ @mixin block-paragraphs {
96
+ p { margin: 1em 0; }
97
+ }
98
+
99
+ // Indented paragraphs
100
+ @mixin indented-paragraphs($indent: 1em) {
101
+ p { margin-top: 0.5; margin-bottom: 0.5; }
102
+ p + p { text-indent: $indent; }
103
+ }
104
+
105
+ // Basic styles for list elements
106
+ @mixin lists($indent: 2.25em, $ul-list-style: disc, $ol-list-style: decimal) {
107
+ ul, ol, dl { margin-top: 1em; margin-bottom: 1em; }
108
+ ul, ol, dd { padding-left: $indent; }
109
+ ul { list-style: $ul-list-style; }
110
+ ol { list-style: $ol-list-style; }
111
+ li { margin-top: 0.5em; margin-bottom: 0.5em; }
112
+ dt { margin-top: 1em; }
113
+ dd { margin-bottom: 1em; }
114
+ }
115
+
116
+ // Typewritter styles for fixed-font elements
117
+ @mixin fixed-font-elements($font-family: $fixed-font-family, $font-size: $fixed-font-size, $line-height: $fixed-line-height) {
118
+ code, dfn, kbd, samp, tt {
119
+ font-family: $font-family;
120
+ font-size: 95%;
121
+ color: soften($text-color);
122
+ }
123
+ pre {
124
+ background: soften($text-color);
125
+ color: invert($text-color);
126
+ font-family: $font-family;
127
+ font-size: 95%;
128
+ line-height: $line-height;
129
+ margin: 1.5em 0;
130
+ padding: 1em;
131
+ @include border-radius;
132
+ }
133
+ }
@@ -0,0 +1,15 @@
1
+ @function strengthen($color, $multiplier: 1, $reversed: $reversed-text) {
2
+ @if $reversed {
3
+ @return lighten($color, 20% * $multiplier);
4
+ } @else {
5
+ @return darken($color, 20% * $multiplier);
6
+ }
7
+ }
8
+
9
+ @function soften($color, $multiplier: 1, $reversed: $reversed-text) {
10
+ @if $reversed {
11
+ @return darken($color, 20% * $multiplier);
12
+ } @else {
13
+ @return lighten($color, 20% * $multiplier);
14
+ }
15
+ }
@@ -0,0 +1,47 @@
1
+ @import "compass";
2
+
3
+ // Reversed?
4
+ $reversed-text: false;
5
+ @import "modules/utility";
6
+
7
+ // Base Font
8
+ $base-font-family: "Helvetica Neue", Hevetica, Arial, sans-serif;
9
+ $base-font-size: 110%;
10
+ $base-line-height: 1.4;
11
+
12
+ // Fixed Font
13
+ $fixed-font-family: Monaco, "Andale Mono", "Lucida Console", monospace;
14
+ $fixed-font-size: 85%;
15
+ $fixed-line-height: $base-line-height;
16
+
17
+ // Text Colors
18
+ $text-color: #333333;
19
+ $loud-color: strengthen($text-color);
20
+ $quiet-color: soften($text-color, 1.5);
21
+ $header-color: strengthen($text-color, 0.66);
22
+
23
+ // Link Colors
24
+ $link-color: #bb3a08;
25
+ $link-visited-color: #a72;
26
+ $link-hover-color: #f66933;
27
+
28
+ // Theme Colors
29
+ $background-color: white;
30
+ $banner-color: #973b12;
31
+
32
+ // Paragraphs
33
+ $indented-paragraphs: false;
34
+
35
+ // Layout
36
+ $body-margin-x: 15%;
37
+
38
+ // Border Radius
39
+ $default-border-radius: 8px;
40
+
41
+ @import "modules/all";
42
+
43
+ @include global-reset;
44
+ @include reset-html5;
45
+
46
+ html, body { background: $background-color; }
47
+ body { @include base-font; }
@@ -0,0 +1,37 @@
1
+ //
2
+ // Virtual Content Classes
3
+ //
4
+
5
+ .links {
6
+ a { @include basic-link($link-color, $link-visited-color, $link-hover-color); }
7
+ a.more {
8
+ white-space: nowrap;
9
+ &:after { content: " »"; }
10
+ }
11
+ }
12
+
13
+ .typography {
14
+ @include basic-typography;
15
+ }
16
+
17
+ .content {
18
+ @extend .links;
19
+ @extend .typography;
20
+
21
+ .box {
22
+ background: #efeacf;
23
+ border: 1px solid darken(#efeacf, 10);
24
+ @include border-radius;
25
+ margin: 1.5em -1em;
26
+ padding: 1px 1em;
27
+ }
28
+ }
29
+
30
+
31
+ //
32
+ // Applied to appropriate elements
33
+ //
34
+
35
+ section[role=main] > article {
36
+ @extend .content
37
+ }
@@ -0,0 +1,42 @@
1
+ //
2
+ // Basic layout and styles for site
3
+ //
4
+
5
+
6
+ header[role=banner] {
7
+ background: $banner-color;
8
+ @include background-image(
9
+ linear-gradient(rgba(black, 0) 0%, rgba(black, 0) 80%, rgba(black, 0.15) 100%),
10
+ radial-gradient(30% 50px, $banner-color, darken($banner-color, 11) 400px)
11
+ );
12
+ padding: 20px $body-margin-x;
13
+ position: relative;
14
+
15
+ a { @include basic-link(mix($banner-color, white, 20%), $hover: white, $decoration: "plain"); }
16
+
17
+ .action-link {
18
+ position: absolute;
19
+ right: $body-margin-x;
20
+ top: 55px;
21
+ a {
22
+ background: rgba(white, 0.1);
23
+ @include border-radius;
24
+ display: block;
25
+ padding: 0.5em 1em;
26
+ @include text-shadow(mix($banner-color, black, 50%) 0 1px 0);
27
+ &:after { content: " ⇢"; }
28
+ }
29
+ }
30
+ }
31
+
32
+ section[role=main] {
33
+ padding: 1px $body-margin-x;
34
+ }
35
+
36
+ body > footer {
37
+ padding: 0 $body-margin-x 20px;
38
+ font-size: 90%;
39
+ color: $quiet-color;
40
+ a { @include basic-link($text-color); }
41
+ p { margin: 1em 0; }
42
+ }
@@ -0,0 +1,7 @@
1
+ //
2
+ // Application Stylesheet
3
+ //
4
+
5
+ @import "partials/base";
6
+ @import "partials/content";
7
+ @import "partials/layout";
@@ -0,0 +1 @@
1
+ <%= render :template => "/layouts/default" %>
@@ -0,0 +1,15 @@
1
+ Serve has a special file type for mapping HTTP redirects. Redirects make nice
2
+ end points for form posts or short URLs.
3
+
4
+ Redirect URLs can be fully formed, like this:
5
+
6
+ http://wiseheartdesign.com/
7
+
8
+ Or, relative to the site root, like this:
9
+
10
+ /action
11
+
12
+ Extra lines at the beginning of a redirect file are ignored. By convention,
13
+ the last line of a redirect file is the URL to redirect to:
14
+
15
+ /welcome
@@ -0,0 +1,31 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title><%= @title %></title>
6
+ <link rel="stylesheet" href="/stylesheets/screen.css">
7
+ <!--[if IE]>
8
+ <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
9
+ <![endif]-->
10
+ </head>
11
+ <body>
12
+ <header role="banner">
13
+ <h1><a href="/"><%= image "serve-logo" %></a></h1>
14
+ <div class="action-link"><a href="http://get-serve.com/documentation">Documentation</a></div>
15
+ </header>
16
+ <section role="main">
17
+ <article>
18
+ <header><h1><%= @title %></h1></header>
19
+ <%= yield %>
20
+ </article>
21
+ </section>
22
+ <footer>
23
+ <small>
24
+ <p>Serve is copyright © 2007-2011 John W. Long and Adam I. Williams. Portions have
25
+ been contributed by Robert Evans and others. Serve is distributed under a MIT-style
26
+ license and is open source software. Enjoy!</p>
27
+ <p>Questions? <a href="http://get-serve.com/mailing-list">Join the mailing list.</a></p>
28
+ </small>
29
+ </footer>
30
+ </body>
31
+ </html>
@@ -0,0 +1,25 @@
1
+ #
2
+ # Methods placed in this module can be used inside of any view.
3
+ # View helpers allow you to encapsalate complex logic and keep your
4
+ # views pristine.
5
+ #
6
+ module ViewHelpers
7
+
8
+ # Calculate the years for a copyright
9
+ def copyright_years(start_year)
10
+ end_year = Date.today.year
11
+ if start_year == end_year
12
+ "\#{start_year}"
13
+ else
14
+ "\#{start_year}&#8211;\#{end_year}"
15
+ end
16
+ end
17
+
18
+ # Handy for hiding a block of unfinished code
19
+ def hidden(&block)
20
+ #no-op
21
+ end
22
+
23
+ # Add your own helpers below...
24
+
25
+ end
@@ -0,0 +1,36 @@
1
+ <% @title = "You created a structured Serve project!" %>
2
+
3
+ <dl>
4
+ <dt><strong>Views &amp; Layouts</strong></dt>
5
+ <dd>
6
+ Your views are stored in the <kbd>views</kbd> folder. Coming from a page-based
7
+ scripting language like PHP? Views are just like regular pages. The main layout
8
+ file for this project is stored in <kbd>layouts/default</kbd>.
9
+ </dd>
10
+
11
+ <dt><strong>Stylesheets, Sass &amp; Compass</strong></dt>
12
+ <dd>
13
+ This project is pre-configured for <a href="http://sass-lang.com">Sass</a> and
14
+ <a href="http://compass-style.org">Compass</a>. Store your <kbd>sass</kbd> and
15
+ <kbd>scss</kbd> files in the root <kbd>stylesheets</kbd> folder. Sass
16
+ stylesheets will be automatically compiled to CSS and stored in
17
+ <kbd>public/stylesheets</kbd>.
18
+ </dd>
19
+
20
+ <dt><strong>Static Assets</strong></dt>
21
+ <dd>
22
+ Static assets like images, javascripts, and downloads are stored in the
23
+ <kbd>public</kbd> folder. Put files here that don&#8217;t need special
24
+ processing by Serve.
25
+ </dd>
26
+ </dl>
27
+
28
+ <div class="box">
29
+ <h6>Other Template Languages</h6>
30
+ <p>
31
+ If you are interested in using Serve with other template languages like Haml,
32
+ Slim, Markdown, or Textile, remember to edit the project <kbd>Gemfile</kbd>
33
+ to include the appropriate gems. Then use
34
+ <a href="http://gembundler.com/">Bundler</a> to install them.
35
+ </p>
36
+ </div>
@@ -12,7 +12,7 @@ describe Serve::Application do
12
12
 
13
13
  :port => 4000,
14
14
  :address => '0.0.0.0',
15
- :root => Dir.pwd,
15
+ :root => ".",
16
16
 
17
17
  :convert => nil,
18
18
  :create => nil,
@@ -59,35 +59,37 @@ describe Serve::Application do
59
59
  end
60
60
 
61
61
  it "working directory" do
62
- parse('')[:root].should == Dir.pwd
62
+ parse('')[:root].should == '.'
63
63
  dir = File.dirname(__FILE__)
64
64
  parse(dir)[:root].should == File.expand_path(dir)
65
65
  end
66
66
 
67
67
  describe "create" do
68
68
  it "with standard arguments" do
69
- params = parse('create newapp /Users/user')[:create]
70
- params[:name].should == 'newapp'
71
- params[:directory].should == '/Users/user'
72
- params[:framework].should be_nil
73
- end
74
-
75
- it "without parent directory" do
76
69
  params = parse('create newapp')[:create]
77
- params[:name].should == 'newapp'
78
- params[:directory].should == Dir.pwd
70
+ params[:directory].should == 'newapp'
71
+ params[:framework].should be_nil
72
+ params[:template].should be_nil
79
73
  end
80
74
 
81
75
  it "with no arguments" do
82
- lambda { parse('create') }.should raise_error(Serve::Application::InvalidArgumentsError)
76
+ params = parse('create')[:create]
77
+ params[:directory].should == '.'
78
+ params[:framework].should be_nil
79
+ params[:template].should be_nil
83
80
  end
84
81
 
85
82
  it "with a javascript framework" do
86
- params = parse('create newapp /Users/user -j jquery')[:create]
87
- params[:name].should == 'newapp'
88
- params[:directory].should == '/Users/user'
83
+ params = parse('create newapp -j jquery')[:create]
84
+ params[:directory].should == 'newapp'
89
85
  params[:framework].should == 'jquery'
90
86
  end
87
+
88
+ it "with a template" do
89
+ params = parse('create newapp --template blank')[:create]
90
+ params[:directory].should == 'newapp'
91
+ params[:template].should == 'blank'
92
+ end
91
93
  end
92
94
 
93
95
  describe "convert" do
@@ -99,7 +101,7 @@ describe Serve::Application do
99
101
 
100
102
  it "with no arguments" do
101
103
  params = parse('convert')[:convert]
102
- params[:directory].should == Dir.pwd
104
+ params[:directory].should == '.'
103
105
  params[:framework].should be_nil
104
106
  end
105
107
 
@@ -119,13 +121,13 @@ describe Serve::Application do
119
121
 
120
122
  it "export with just an output directory" do
121
123
  params = parse('export output')[:export]
122
- params[:input].should == Dir.pwd
124
+ params[:input].should == '.'
123
125
  params[:output].should == 'output'
124
126
  end
125
127
 
126
128
  it "export with no arguments" do
127
129
  params = parse('export')[:export]
128
- params[:input].should == Dir.pwd
130
+ params[:input].should == '.'
129
131
  params[:output].should == 'html'
130
132
  end
131
133
  end
@@ -141,7 +143,7 @@ describe Serve::Application do
141
143
  args = args.split(' ')
142
144
  @app.parse(*args)
143
145
  end
144
-
146
+
145
147
  end
146
148
 
147
149
  describe "running" do