hybook 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest.txt CHANGED
@@ -3,4 +3,9 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  lib/hybook.rb
6
+ lib/hybook/std/album.rb
7
+ lib/hybook/type/album.rb
8
+ lib/hybook/type/picture.rb
9
+ lib/hybook/type/section.rb
6
10
  lib/hybook/version.rb
11
+ templates/album.md
data/README.md CHANGED
@@ -1,26 +1,114 @@
1
- # hybook
1
+ # hybook - Hyper Book (H8)
2
2
 
3
3
  hybook gem - hypertext book generator
4
4
 
5
- * home :: [github.com/rubylibs/hybook](https://github.com/rubylibs/hybook)
6
- * bugs :: [github.com/rubylibs/hybook/issues](https://github.com/rubylibs/hybook/issues)
5
+ * home :: [github.com/hybook/hybook](https://github.com/hybook/hybook)
6
+ * bugs :: [github.com/hybook/hybook/issues](https://github.com/hybook/hybook/issues)
7
7
  * gem :: [rubygems.org/gems/hybook](https://rubygems.org/gems/hybook)
8
8
  * rdoc :: [rubydoc.info/gems/hybook](http://rubydoc.info/gems/hybook)
9
9
 
10
+
10
11
  ## Usage
11
12
 
12
- TBD
13
+ Hyper Book (H8) generates pages from plain text wiki-style templates
14
+ for a hypertext book in two versions,
15
+ that is, a single-page version and a multi-page version.
16
+
17
+
18
+ ## Goals
19
+
20
+ - Hyper Book offers book models / structs
21
+ (e.g. Book, Part, Chapter, Appendix)
22
+ and types
23
+ (Album, Slide Show, etc.).
24
+
25
+ - Hyper Book offers template packs and plugins.
26
+
27
+ - Hyper Book offers a template pack and plugin manager
28
+ (e.g. `hybook install almanac`, `hybook install table`, etc.).
29
+
30
+
31
+
32
+ ## Non-Goals
33
+
34
+ - Hyper Book is **NOT** a static site generator / server.
35
+ => Use your static site generator of choice (e.g. Jekyll and friends)
36
+ to convert the generated pages into a complete hypertext book or web site.
37
+
38
+ - Hyper Book is **NOT** a HTML to PDF converter.
39
+ => Use your HTML to PDF converter of choice (e.g. print ot PDF, `wkhtmltopdf`, etc.).
40
+
41
+ - Hyper Book is **NOT** a EPUB generator or checker.
42
+ => Use your EPUB generator or checker of choice.
43
+
44
+ - Hyper Book is **NOT** a MOBI generator.
45
+ => Use your MOBI generator of choice (e.g. `kindlegen`, etc.).
46
+
47
+
48
+
49
+ ## Building Blocks
50
+
51
+ - [`textutils` gem](https://github.com/rubylibs/textutils) -- Text filters n helpers
52
+ - [`markdown` gem](https://github.com/rubylibs/markdown) -- Markdown helpers
53
+ - [`pakman` gem](https://github.com/rubylibs/pakman) -- Template Pack(age) manager
54
+ - [`props` gem](https://github.com/rubylibs/props) -- Setting Hierachies (Commandline, User, Home, Defaults, etc.)
55
+
56
+
57
+ <!-- more -->
58
+
59
+ - Jekyll -- static site generator
60
+ - `kramdown` -- Markdown converter
61
+
62
+
63
+ ## Hypertext Markup (HTML) to PDF Conversion Options
64
+
65
+ - Use Google Chrome (Print to PDF)
66
+ - `wkhtmltopdf`
67
+ - `phantom.js` Renderer
68
+
69
+
70
+ ## Real World Book Examples
71
+
72
+ - [The Free World Football Almanac](https://github.com/openfootball/book)
73
+ - [The Free World Beer Book](https://github.com/openbeer/book)
74
+ - [The Free World Fact Book](https://github.com/openmundi/book)
75
+
13
76
 
14
77
  ## Alternatives
15
78
 
16
- ### EPub, Mobi Kindle Book Generator
79
+ ### EPUB, MOBI (Kindle) Book Generator
17
80
 
18
- - [Kitabu](https://github.com/fnando/kitabu)
19
- - [Bookshop](https://github.com/blueheadpublishing/bookshop)
81
+ #### Ruby
20
82
 
83
+ - [kitabu gem](https://github.com/fnando/kitabu) - EPUB, MOBI, PDF
84
+ - [bookshop gem](https://github.com/blueheadpublishing/bookshop) - EPUB, MOBI, PDF
85
+ - [eeepub, eeepub-with-cover-support ](https://github.com/jugyo/eeepub) - by jugyo
86
+ - [git-scribe](https://github.com/schacon/git-scribe) - by Scott Chacon (aka schacon)
87
+ - [review](https://github.com/kmuto/review) - by Kenshi Muto (aka kmuto)
88
+ - [gepub](https://github.com/skoji/gepub) - by Satoshi Kojima (aka skoji)
89
+ - [peregrin](https://github.com/joseph/peregrin) - by Joseph Pearson
90
+
91
+ <!-- experimental
92
+ -->
93
+
94
+ - [bookie gem](https://github.com/sandal/bookie) - by Gregory Brown (aka sandal); experimental
95
+ - [penny](https://github.com/peterc/penny) - by Peter Cooper (aka peterc); experimental
96
+ - [eeepub3](https://github.com/bubaz/eeepub3) - by Sergey (aka bubaz)
97
+
98
+
99
+ #### Haskell
100
+
101
+ - [Pandoc](http://johnmacfarlane.net/pandoc)
21
102
 
22
103
 
23
104
  ## License
24
105
 
25
106
  The `hybook` scripts are dedicated to the public domain.
26
107
  Use it as you please with no restrictions whatsoever.
108
+
109
+
110
+ ## Questions? Comments?
111
+
112
+ Send them along to the
113
+ [Free Web Slide Show Alternatives (S5, S6, S9, Slidy And Friends) Forum/Mailing List](http://groups.google.com/group/webslideshow).
114
+ Thanks!
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ Hoe.spec 'hybook' do
5
5
 
6
6
  self.version = HyBook::VERSION
7
7
 
8
- self.summary = 'hybook - hypertext boook generator'
8
+ self.summary = 'hybook - hypertext book generator'
9
9
  self.description = summary
10
10
 
11
11
  self.urls = ['https://github.com/hybook/hybook']
@@ -23,5 +23,4 @@ Hoe.spec 'hybook' do
23
23
  :required_ruby_version => '>= 1.9.2'
24
24
  }
25
25
 
26
-
27
26
  end
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ module HyBook
4
+ module AlbumHelper
5
+
6
+ def render_pictures( pics, opts )
7
+ buf = ''
8
+ buf << 'I ' # NOTE: cannot use | used by markdown for tables (or just escape???)
9
+ pics.each do |pic|
10
+ buf << render_picture( pic, opts )
11
+ buf << ' I '
12
+ end
13
+ buf
14
+ end
15
+
16
+ def render_picture( pic, opts )
17
+
18
+ ## FIX: add pics_root or assets_root or similar as opt !!!!!!!
19
+ ## do NOT hard code
20
+
21
+ size = opts[:size]
22
+ ## puts "[picture] size=#{size}" # NOTE: opts[:size] required for now!!!
23
+
24
+ extname = File.extname( pic.path )
25
+ basename_in = File.basename( pic.path, extname ) # NB: remove extname (that is, suffix e.g. .png,.jpg,.gif etc.)
26
+
27
+ # strip leading 1-west- (optional for organizing logos)
28
+ # e.g. 3-west-austrias becomes austrias
29
+ basename_out = basename_in.gsub( /[0-9a-z]+-/, '' )
30
+
31
+ ## puts "path: #{path}, basename_in: #{basename_in}, basename_out: #{basename_out}, extname: #{extname}"
32
+
33
+ path = "vendor/assets/images/logos/#{size}x#{size}/#{basename_out}.png"
34
+
35
+ buf = ''
36
+ buf << "_#{pic.title}_{: .key} "
37
+ buf << "![#{pic.title}](#{path})"
38
+ buf
39
+ end
40
+
41
+ def render_album( album, opts )
42
+ ###
43
+ ## TODO/FIX:
44
+ ## use TextUtils::PageTemplate.read( path ).render( binding ) - one line
45
+
46
+ tmpl = File.read_utf8( "#{HyBook.templates_path}/album.md" )
47
+ TextUtils::PageTemplate.new( tmpl ).render( binding )
48
+ end
49
+
50
+ end # module AblumHelper
51
+
52
+
53
+ # make helpers available as class methods for now e.g. HyBook.render_album etc.
54
+ extend AlbumHelper
55
+ end # module HyBook
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+
3
+ module HyBook
4
+
5
+
6
+ class Album
7
+ attr_accessor :title
8
+ attr_accessor :sections
9
+
10
+ def initialize( title )
11
+ @title = title
12
+ @sections = [] # sections (for pictures)
13
+ end
14
+
15
+ def self.create_from_folder( root, opts={} )
16
+ dirs = Dir[ "#{root}/**/" ] ## get all folders n subfolder
17
+ ## pp dirs
18
+
19
+ title = opts[:title ] || 'Untitled'
20
+
21
+ album = Album.new( title )
22
+
23
+ dirs.each do |dir|
24
+ section_title = dir[ root.length+1..-2 ] # cut off ROOT_DIR plus leading and trailing /
25
+ files = Dir[ "#{dir}/*.{png,gif,jpg}" ]
26
+
27
+ ## fix: use logger
28
+ puts "dir: #{dir}, title: #{section_title}, files: #{files.size}"
29
+ next if files.size == 0 # skip if no image files in folder
30
+
31
+ section = Section.new( section_title )
32
+ album.sections << section
33
+
34
+ ## puts "files:"
35
+ ## pp files
36
+
37
+ files.each do |filename|
38
+ extname = File.extname( filename )
39
+ basename = File.basename( filename, extname ) # NB: remove extname (that is, suffix e.g. .png,.jpg,.gif etc.)
40
+
41
+ picture_title = basename # use basename
42
+ picture_path = filename # TODO/FIX: strip off leading root path ?? why? why not???
43
+ ### rename path to source or src or file or filename - why? why not??
44
+
45
+
46
+ picture = Picture.new( picture_title, picture_path )
47
+ section.pictures << picture
48
+ end
49
+ end
50
+ album # return album struct
51
+ end
52
+
53
+
54
+ end # class Album
55
+
56
+
57
+ end # module HyBook
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ module HyBook
4
+
5
+
6
+ class Picture
7
+ attr_accessor :title
8
+ attr_accessor :path
9
+
10
+ def initialize( title, path )
11
+ @title = title
12
+ @path = path
13
+ end
14
+ end
15
+
16
+
17
+ end # module HyBook
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ module HyBook
4
+
5
+
6
+ class Section
7
+ attr_accessor :title
8
+ attr_accessor :pictures
9
+
10
+ def initialize( title )
11
+ @title = title
12
+ @pictures = [] # pictures (images/logos/etec.)
13
+ end
14
+ end
15
+
16
+
17
+ end # module HyBook
@@ -1,6 +1,6 @@
1
1
 
2
2
  module HyBook
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
 
6
6
 
data/lib/hybook.rb CHANGED
@@ -1,7 +1,30 @@
1
1
 
2
+ ############
3
+ # stdlibs
4
+
5
+ require 'pp'
6
+
7
+
8
+ ###################
9
+ # 3rd party libs
10
+
11
+ require 'textutils'
12
+
13
+
14
+ ####################3
15
+ # our own code
2
16
 
3
17
  require 'hybook/version' # let it always go first
4
18
 
19
+ require 'hybook/type/album'
20
+ require 'hybook/type/picture'
21
+ require 'hybook/type/section'
22
+
23
+ ##############################################
24
+ # builtin std helpers, renderers n builders
25
+
26
+ require 'hybook/std/album'
27
+
5
28
 
6
29
  module HyBook
7
30
 
@@ -12,9 +35,15 @@ module HyBook
12
35
  def self.root
13
36
  "#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
14
37
  end
38
+
39
+ def self.templates_path
40
+ "#{root}/templates"
41
+ end
15
42
 
16
43
  end # module HyBook
17
44
 
18
45
 
19
46
  puts HyBook.banner # say hello
47
+ puts "[hybook] root: #{HyBook.root}"
48
+ puts "[hybook] templates_path: #{HyBook.templates_path}"
20
49
 
@@ -0,0 +1,9 @@
1
+
2
+ ## {{ album.title }}
3
+
4
+ {% album.sections.each do |section| %}
5
+
6
+ #### {{ section.title }} ({{ section.pictures.size }})
7
+
8
+ {{ render_pictures( section.pictures, opts ) }}
9
+ {% end %}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-16 00:00:00.000000000 Z
12
+ date: 2014-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
16
- requirement: &21243936 !ruby/object:Gem::Requirement
16
+ requirement: &21453732 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '4.0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *21243936
24
+ version_requirements: *21453732
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
27
- requirement: &21243576 !ruby/object:Gem::Requirement
27
+ requirement: &21453348 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,8 +32,8 @@ dependencies:
32
32
  version: '3.7'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *21243576
36
- description: hybook - hypertext boook generator
35
+ version_requirements: *21453348
36
+ description: hybook - hypertext book generator
37
37
  email: webslideshow@googlegroups.com
38
38
  executables: []
39
39
  extensions: []
@@ -41,13 +41,19 @@ extra_rdoc_files:
41
41
  - History.md
42
42
  - Manifest.txt
43
43
  - README.md
44
+ - templates/album.md
44
45
  files:
45
46
  - History.md
46
47
  - Manifest.txt
47
48
  - README.md
48
49
  - Rakefile
49
50
  - lib/hybook.rb
51
+ - lib/hybook/std/album.rb
52
+ - lib/hybook/type/album.rb
53
+ - lib/hybook/type/picture.rb
54
+ - lib/hybook/type/section.rb
50
55
  - lib/hybook/version.rb
56
+ - templates/album.md
51
57
  homepage: https://github.com/hybook/hybook
52
58
  licenses:
53
59
  - Public Domain
@@ -74,5 +80,5 @@ rubyforge_project: hybook
74
80
  rubygems_version: 1.8.16
75
81
  signing_key:
76
82
  specification_version: 3
77
- summary: hybook - hypertext boook generator
83
+ summary: hybook - hypertext book generator
78
84
  test_files: []