hydeweb 0.0.7 → 0.0.8.pre1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ v0.0.8
2
+ ------
3
+
4
+ - Add support for subclassing. (just add a 'type' meta)
5
+ - Implement Project#all.
6
+ - Implement Page#all and Page#all(type).
7
+ - Fix binary files losing extensions on 'hyde build'.
8
+
1
9
  v0.0.7
2
10
  ------
3
11
 
data/README.md CHANGED
@@ -1,40 +1,54 @@
1
1
  Hyde
2
2
  ====
3
3
 
4
+ Hyde is a website preprocessor.
5
+
6
+ http://labs.sinefunc.com/hyde/
7
+
8
+ - __Layouts and Partials:__ Hyde lets you define your site's header and footer
9
+ layouts in a separate file, and even separate snippets of your site
10
+ into reuseable components (partials). Your code will be much cleaner and
11
+ DRYer!
12
+
13
+ - __Template languages:__ Hyde lets you write your site in any template
14
+ language you need -- the translation will be taken care of for you.
15
+ Hyde supports HAML, LessCSS, Markdown, SASS and Textile by default, and
16
+ more can be added through extensions.
17
+
18
+ - __Extendable:__ Hyde is easily customizable with extensions. You can add
19
+ new helpers, new commands, support for new languages and many more by
20
+ simply adding the extensions to your project folder. Some are even
21
+ available as simple Ruby gems!
22
+
23
+ - __Design fast:__ Hyde comes with a web server that lets you serve up
24
+ your site locally. Any changes to your files will be seen on your next
25
+ browser refresh!
26
+
27
+ - __Build your site as static HTMLs:__ You can export your site as plain
28
+ HTML files with one simple command.
29
+
30
+ Why use Hyde?
31
+ -------------
32
+
33
+ It's like building a static site, but better! You can use Hyde for:
34
+
35
+ - Building HTML prototypes
36
+ - Building sites with no dynamic logic
37
+ - Creating a blog where the entries are stored in a source repository
38
+
4
39
  Installation
5
40
  ------------
6
41
 
7
- gem install hydeweb --pre
42
+ gem install hydeweb
8
43
 
9
44
  Usage
10
45
  -----
11
46
 
12
- hyde create <project_name>
47
+ Here's how you can get started:
48
+
49
+ hyde create <project_name>
13
50
  cd <project_name>
14
51
  hyde build # <= Build the HTML files, or
15
52
  hyde start # <= Serve via a local web server
16
53
 
17
- To do
18
- -----
19
54
 
20
- - ignores
21
- - error pages
22
- - page types
23
- - _meta.yml
24
-
25
- Done:
26
-
27
- - default extensions
28
- - version checking
29
- - content_for
30
- - partials_path
31
- - last_modified
32
- - partials support
33
- - hyde build
34
- - extensions support
35
- - hyde gen
36
- - helpers
37
- - more renderers
38
- - less
39
- - markdown
40
- - textile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8.pre1
@@ -1,5 +1,5 @@
1
- #{sitename}
2
- ===========
1
+ {sitename}
2
+ ==========
3
3
 
4
4
  This is my site.
5
5
 
@@ -11,7 +11,7 @@ Instructions
11
11
  2. Install the hydeweb gem: `gem install hydeweb --pre`
12
12
  3. Build the site HTML files by typing: `hyde build`
13
13
 
14
- You may also type `hyde serve` to serve the files in a local web server.
14
+ You may also type `hyde start` to serve the files in a local web server.
15
15
 
16
16
  (If #2 fails, you may need to type `sudo gem install hydeweb` instead)
17
17
 
data/hydeweb.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hydeweb}
8
- s.version = "0.0.7"
8
+ s.version = "0.0.8.pre1"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rico Sta. Cruz", "Sinefunc, Inc."]
12
- s.date = %q{2010-11-24}
12
+ s.date = %q{2010-12-30}
13
13
  s.default_executable = %q{hyde}
14
14
  s.description = %q{Website preprocessor}
15
15
  s.email = %q{rico@sinefunc.com}
data/lib/hyde/page.rb CHANGED
@@ -69,12 +69,20 @@ module Hyde
69
69
 
70
70
  # Returns the URL path for the page.
71
71
  def path
72
- return @url unless @url.nil?
72
+ @url ||= begin
73
+ if renderer.is_a?(Renderer::Passthru)
74
+ '/' + @name
75
+ else
76
+ url = File.split(@name)
77
+ url[1] = File.basename(url[1], '.*')
78
+ url[1] = (url[1] + @renderer.default_ext) unless url[1].include?('.')
79
+ '/' + url.join('/')
80
+ end
81
+ end
82
+ end
73
83
 
74
- url = File.split(@name)
75
- url[1] = File.basename(url[1], '.*')
76
- url[1] = (url[1] + @renderer.default_ext) unless url[1].include?('.')
77
- @url = '/' + url.join('/')
84
+ def output_path
85
+ File.join(project.config.output_path, path)
78
86
  end
79
87
 
80
88
  def get_binding #(&blk)
@@ -10,6 +10,7 @@ module Hyde
10
10
  path.gsub!(project.root(:site), '')
11
11
  path.gsub!(/^\/+/, '')
12
12
 
13
+ # Try: "file.html" => "file.html", "file" [autoguess], "file/index.html"
13
14
  ext = File.extname(path)
14
15
  begin
15
16
  do_create path, project, def_page_class
@@ -25,11 +26,23 @@ module Hyde
25
26
  def self.do_create(path, project, def_page_class = Page)
26
27
  info = get_page_info(path, project, def_page_class)
27
28
  page_class = info[:page_class]
28
- page_class.new(path, project, info[:renderer], info[:filename])
29
+ page = page_class.new(path, project, info[:renderer], info[:filename])
30
+
31
+ # What if it wants to be a different class?
32
+ if page.meta.type
33
+ begin
34
+ klass = Hyde.const_get(page.meta.type.to_sym)
35
+ page = klass.new(path, project, info[:renderer], info[:filename])
36
+ rescue NameError #pass
37
+ end
38
+ else
39
+ page
40
+ end
29
41
  end
30
42
 
31
43
  protected
32
44
 
45
+ # Returns the renderer, filename, page class
33
46
  def self.get_page_info(path, project, page_class)
34
47
  renderer = nil
35
48
  filename = page_class.get_filename(path, project)
@@ -44,8 +57,9 @@ module Hyde
44
57
  else
45
58
  # Look for the file
46
59
  matches = Dir["#{filename}.*"]
47
- raise NotFound, "Can't find `#{path}{,.*}` -- #{filename}" \
48
- if matches.empty?
60
+ if matches.empty?
61
+ raise NotFound, "Can't find `#{path}{,.*}` -- #{filename}"
62
+ end
49
63
 
50
64
  # Check for a matching renderer
51
65
  exts = []
data/lib/hyde/project.rb CHANGED
@@ -53,6 +53,20 @@ module Hyde
53
53
  Hyde::Page[name, self, default_class]
54
54
  end
55
55
 
56
+ # Returns all pages.
57
+ #
58
+ # @example
59
+ # @project.all #=> [1, 2, 3]
60
+ # @project.all(Hyde::Post) #=> [1]
61
+ #
62
+ def all(type=nil)
63
+ unless type
64
+ @all = files.map { |f| self[f] }
65
+ else
66
+ all.select { |page| page.class == type }
67
+ end
68
+ end
69
+
56
70
  # Writes the output files.
57
71
  # @param
58
72
  # ostream - (Stream) Where to send the messages
@@ -65,12 +79,12 @@ module Hyde
65
79
  end
66
80
 
67
81
  begin
68
- files.each do |path|
69
- ostream << " * #{@config.output_path}/#{path}\n" if ostream
82
+ all.each do |page|
83
+ ostream << " * #{page.output_path}\n" if ostream
70
84
 
71
85
  begin
72
- rendered = self[path].render
73
- force_file_open(root(:output, path)) { |file| file << rendered }
86
+ rendered = page.render
87
+ force_file_open(page.output_path) { |file| file << rendered }
74
88
 
75
89
  rescue RenderError => e
76
90
  ostream << " *** Error: #{e.to_s}".gsub("\n", "\n *** ") << "\n"
@@ -85,7 +99,7 @@ module Hyde
85
99
  # Returns a list of all URL paths
86
100
  #
87
101
  def files
88
- @file_list = Dir[File.join(root(:site), '**', '*')].inject([]) do |a, match|
102
+ @files = Dir[File.join(root(:site), '**', '*')].inject([]) do |a, match|
89
103
  # Make sure its the canonical name
90
104
  path = File.expand_path(match)
91
105
  file = path.gsub /^#{Regexp.escape root(:site)}\/?/, ''
@@ -162,7 +176,7 @@ module Hyde
162
176
  #
163
177
  def load_extensions
164
178
  # Load the init.rb file
165
- require root('init.rb') if File.exists?(root 'init.rb')
179
+ require root('init.rb') if File.exists?(root('init.rb'))
166
180
 
167
181
  # Load the gems in the config file
168
182
  @config.gems.each { |gem| require gem }
data/lib/hyde.rb CHANGED
@@ -43,7 +43,10 @@ module Hyde
43
43
  extend self
44
44
 
45
45
  def version
46
- @version ||= File.open(File.join(File.dirname(__FILE__), '..', 'VERSION')) { |f| f.read.strip }
46
+ @version ||= begin
47
+ v = File.open(File.join(File.dirname(__FILE__), '..', 'VERSION')) { |f| f.read.strip }
48
+ v = v.match(/^[0-9]+(\.[0-9]+){2}/)[0] rescue v
49
+ end
47
50
  end
48
51
 
49
52
  def compatible_with?(given_version)
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydeweb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease: false
4
+ hash: -1876988224
5
+ prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ - pre1
11
+ version: 0.0.8.pre1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Rico Sta. Cruz
@@ -16,7 +17,7 @@ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2010-11-24 00:00:00 +08:00
20
+ date: 2010-12-30 00:00:00 +08:00
20
21
  default_executable: hyde
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency
@@ -200,12 +201,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
201
  required_rubygems_version: !ruby/object:Gem::Requirement
201
202
  none: false
202
203
  requirements:
203
- - - ">="
204
+ - - ">"
204
205
  - !ruby/object:Gem::Version
205
- hash: 3
206
+ hash: 25
206
207
  segments:
207
- - 0
208
- version: "0"
208
+ - 1
209
+ - 3
210
+ - 1
211
+ version: 1.3.1
209
212
  requirements: []
210
213
 
211
214
  rubyforge_project: