shining 1.0.0 → 1.0.1

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.
@@ -2,6 +2,77 @@
2
2
 
3
3
  A presentation framework to be used with Webkit. Yeah, it's all in-browser.
4
4
 
5
+ # Installation
6
+
7
+ $ sudo gem install shining
8
+
9
+ # How to use
10
+
11
+ Create a new presentation by
12
+
13
+ $ shine mypreso
14
+
15
+ Where "mypreso" is the directory name you'll use for it. A base presentation has the
16
+ following base structure.
17
+
18
+ * ROOT
19
+ * config.json
20
+ * slides
21
+ * index.html
22
+
23
+ Which leads us to...
24
+
25
+ # Configuration
26
+
27
+ Presentation-wide configuration happens through the **config.json** file. The existing
28
+ parameters are what I like to call "self documenting" enough so I'll refrain from
29
+ explaining them for now. The only detail worth nothing is that the slides _have_ to be
30
+ listed in the slides array, or else Shining will ignore their existence.
31
+
32
+ # Slides
33
+
34
+ Easy way first. Change the directory to the presentation's directory first. Then
35
+
36
+ $ shine slide mynewslide
37
+
38
+ Where "mynewslide" is the name of the slide. This will create a slide in
39
+ **ROOT/slides/mynewslide.html**, and a slide script in **ROOT/slides/mynewslide.js**.
40
+ It will also automagically edit the **config.json** file for you, adding the new slide.
41
+
42
+ You can also create slides manually by adding an HTML file to **ROOT/slides**, and then
43
+ adding the file name (minus the extension) to **config.json**. Though really, just use
44
+ the generator.
45
+
46
+ # Slide templates
47
+
48
+ Shining supports Haml and ERb templates. For now, you can use it by manually dropping
49
+ a template file or either of those formats in **ROOT/slides**, and then running (from
50
+ inside the presentation's directory)
51
+
52
+ $ shine compile
53
+
54
+ Say you have a slide template named **ROOT/slides/test.haml**. Running the aforementioned
55
+ command will generate a new **test.html** from it. Note that this will _overwrite_ an
56
+ existing **test.html** slide if one exists.
57
+
58
+ # Steps to winning
59
+
60
+ Quickly outline of things I'm going to do with this project:
61
+
62
+ * More effects, because there's no such thing as visually appealing enough. Some
63
+ fine tuning of the existing ones is in order as well.
64
+ * More themes.
65
+ * Add a CSS parser, so I can build jQuery queues with the effects and order them
66
+ without the end-user needing to make sure things happen when they expect.
67
+ * Better generators. For now the requirements are simple enough so they can stay
68
+ as a single file, but I'm confident that will change.
69
+ * Better DSL for slide scripts. I know it's awesome already, but there's always
70
+ room for improvement.
71
+ * Macros, or configurable shortcuts for adding things like audio and video
72
+ without having to know how to use the tags.
73
+ * Did I say I wanna add macros, so you'll need to know next to zero HTML in order
74
+ to create *really* awesome presentations?
75
+
5
76
  # License
6
77
 
7
78
  The MIT License
data/Rakefile CHANGED
@@ -15,8 +15,10 @@ begin
15
15
  gem.email = "julio.ody@gmail.com"
16
16
  gem.homepage = "http://github.com/juliocesar/shining"
17
17
  gem.authors = "Julio Cesar Ody"
18
- gem.add_dependency 'haml', '>= 2.2.17'
19
- gem.add_dependency 'json_pure', '>= 1.1.9'
18
+ gem.add_dependency 'haml', '>= 2.2.17'
19
+ gem.add_dependency 'json_pure', '>= 1.1.9'
20
+ gem.add_dependency 'tilt', '>= 0.6'
21
+ gem.add_dependency 'rdiscount', '> 1.6.3'
20
22
  gem.add_development_dependency 'rspec', '1.3.0'
21
23
  gem.add_development_dependency 'stackdeck', '0.2.0'
22
24
  gem.add_development_dependency 'johnson', '2.0.0.pre2'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/bin/shine CHANGED
@@ -1,34 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.join(File.dirname(__FILE__), *%w(.. lib shining))
4
- require 'fileutils'
5
- require 'tilt'
6
- require 'erb'
7
- require 'json/pure'
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'shining'
8
6
 
9
7
  ACTIONS = {
10
- :new_on! => ['build'],
11
- :new_slide! => ['slide'],
8
+ :new_on! => ['build'],
9
+ :new_slide! => ['slide'],
12
10
  :compile_templates! => ['compile'],
13
11
  :vendorize => ['vendor', 'vendorize']
14
12
  }
15
- TEMPLATES = %w(haml erb)
16
-
17
- class String; def /(s) File.join(self, s) end end
18
-
19
- def doing what, &block
20
- puts what
21
- block.call if block_given?
22
- end
23
13
 
24
14
  def bail! reason
25
- STDERR.puts(reason) and exit(-2)
26
- end
27
-
28
- def vendorized?
29
- bail!("This isn't a Shining preso!") unless shining?
30
- File.exists? Dir.pwd/'vendor'/'lib'/'jquery.shining.js' and
31
- File.exists? Dir.pwd/'vendor'/'themes'
15
+ Shining.error reason
16
+ exit -2
32
17
  end
33
18
 
34
19
  def figure_what_to_do!
@@ -53,51 +38,23 @@ Shine - Generates a new Shining presentation
53
38
  end
54
39
 
55
40
  def new_on! dir
56
- target = File.expand_path(dir)
57
- doing("Creating #{target}") { FileUtils.mkdir_p target }
58
- doing("Creating #{target/'config.json'}") { FileUtils.cp SHINING_ROOT/'templates'/'config.json', target/'config.json' }
59
- doing("Creating #{target/'index.html'}") {
60
- contents = File.read(SHINING_ROOT/'templates'/'index.html')
61
- File.open(target/'index.html', 'w') do |file| file.write ERB.new(contents).result end
62
- }
63
- doing("Creating #{target/'slides'}") { FileUtils.cp_r SHINING_ROOT/'templates'/'slides', target/'slides' }
41
+ Shining::Preso.new dir
64
42
  end
65
43
 
66
- def new_slide! name
67
- bail!("This isn't a Shining preso!") unless shining?
68
- config = JSON.parse File.read(Dir.pwd/'config.json')
69
- config['slides'] << name
70
- File.open(Dir.pwd/'config.json', 'w') do |file| file.write JSON.pretty_generate(config) end
71
- doing("Creating #{Dir.pwd/'slides'/name}.html") {
72
- File.open(Dir.pwd/'slides'/"#{name}.html", 'w') do |file| file.write "<h1 class='centered'>#{name}</h1><p class='centered>♫ ♫ ♫</p>" end
73
- }
74
- doing("Creating #{Dir.pwd/'slides'/name}.js") { FileUtils.touch Dir.pwd/'slides'/name + '.js' }
44
+ def new_slide! name, format = 'html'
45
+ preso = Shining::Preso.open Dir.pwd
46
+ preso.new_slide "#{name}.#{format}", :with => ['styles', 'script']
75
47
  end
76
48
 
77
49
  def vendorize
78
- bail! 'This preso seems vendorized already.' if vendorized?
79
- FileUtils.mkdir Dir.pwd/'vendor'
80
- %w(lib css images themes).each do |required|
81
- FileUtils.cp_r SHINING_ROOT/required, Dir.pwd/'vendor/'
82
- end
83
- index = File.read SHINING_ROOT/'templates'/'index.html'
84
- Object.send(:remove_const, :SHINING_ROOT) and Object.const_set(:SHINING_ROOT, 'vendor')
85
- File.open(Dir.pwd/'index.html', 'w') do |file| file.write ERB.new(index).result end
86
- puts "Done!"
50
+ preso = Shining::Preso.open Dir.pwd
51
+ bail! 'This preso seems vendorized already.' if preso.vendorized?
52
+ preso.vendorize!
87
53
  end
88
54
 
89
55
  def compile_templates!
90
- bail!("This isn't a Shining preso!") unless shining?
91
- Dir[Dir.pwd/'slides'/'*'].reject { |f| f =~ /html|js$/ }.each do |template|
92
- begin
93
- target = File.basename(template).sub(File.extname(template), '.html')
94
- rendered = Tilt.new(template).render
95
- File.open(Dir.pwd/'slides'/target, 'w') do |file| file.write rendered end
96
- puts "Compiled: #{File.basename(template)} -> #{target}"
97
- rescue RuntimeErroor
98
- STDERR.puts "Tilt coult not compile #{File.basename template}. Skipping."
99
- end
100
- end
56
+ preso = Shining::Preso.open Dir.pwd
57
+ preso.compile_templates!
101
58
  end
102
59
 
103
60
  def shining?
@@ -122,15 +122,15 @@
122
122
  }
123
123
 
124
124
  @-webkit-keyframes speeds-in-left {
125
- 0% { opacity: 0; -webkit-transform: skew(40deg); margin-left: -4em }
126
- 10% { opacity: 1; -webkit-transform: skew(0deg); margin-left: -2em }
127
- 90% { opacity: 1; -webkit-transform: skew(0deg); margin-left: 0em }
128
- 100% { opacity: 0; -webkit-transform: skew(-40deg); margin-right: -4em }
125
+ 0% { opacity: 0; -webkit-transform: skew(40deg) translate(-4em, 0) }
126
+ 10% { opacity: 1; -webkit-transform: skew(0deg) translate(-2em, 0) }
127
+ 90% { opacity: 1; -webkit-transform: skew(0deg) translate(0) }
128
+ 100% { opacity: 0; -webkit-transform: skew(-40deg) translate(4em, 0) }
129
129
  }
130
130
 
131
131
  @-webkit-keyframes speeds-in-right {
132
- 0% { opacity: 0; -webkit-transform: skew(-40deg); margin-right: -4em }
133
- 10% { opacity: 1; -webkit-transform: skew(0deg); margin-right: -2em }
134
- 90% { opacity: 1; -webkit-transform: skew(0deg); margin-right: 0em }
135
- 100% { opacity: 0; -webkit-transform: skew(40deg); margin-left: -4em }
132
+ 0% { opacity: 0; -webkit-transform: skew(-40deg) translate(4em, 0) }
133
+ 10% { opacity: 1; -webkit-transform: skew(0deg) translate(2em, 0) }
134
+ 90% { opacity: 1; -webkit-transform: skew(0deg) translate(0) }
135
+ 100% { opacity: 0; -webkit-transform: skew(40deg) translate(-4em, 0) }
136
136
  }
@@ -0,0 +1,72 @@
1
+ require 'fileutils'
2
+ require 'erb'
3
+
4
+ module Shining
5
+
6
+ module FileMethods
7
+ def file? file
8
+ File.exists? file
9
+ end
10
+
11
+ def dir? dir
12
+ File.directory? dir
13
+ end
14
+
15
+ def copy from, to
16
+ Shining.say("Copying #{from} to #{to}") { File.directory?(from) ? FileUtils.cp_r(from, to) : FileUtils.cp(from, to) }
17
+ end
18
+
19
+ def new_dir dir, careful = true
20
+ confirm "#{dir} already exists. Proceed?" if careful and dir?(dir)
21
+ Shining.say("Creating directory #{dir}") { FileUtils.mkdir_p dir }
22
+ end
23
+
24
+ def read_file file
25
+ File.read file
26
+ end
27
+
28
+ def erb file
29
+ ERB.new(read_file(file)).result(binding)
30
+ end
31
+
32
+ def json file
33
+ JSON.parse read_file(file)
34
+ end
35
+
36
+ def expand path
37
+ File.expand_path path
38
+ end
39
+
40
+ def dirname file
41
+ File.dirname file
42
+ end
43
+
44
+ def extname file
45
+ File.extname file
46
+ end
47
+
48
+ def basename file, take = ''
49
+ File.basename file, take
50
+ end
51
+
52
+ def delete! file
53
+ dir?(file) ? FileUtils.rm_rf(file) : FileUtils.rm(file)
54
+ end
55
+
56
+ def new_file path
57
+ Shining.say "Creating file #{path}" do
58
+ File.open path, 'w' do |file|
59
+ yieldage = yield if block_given?
60
+ file.write yieldage unless yieldage.empty? or not yieldage.is_a?(String)
61
+ end
62
+ end
63
+ end
64
+
65
+ private
66
+ def confirm text
67
+ Shining.say text
68
+ !!(STDIN.gets =~ /yes|y/i) ? true : exit(-2)
69
+ end
70
+ end
71
+
72
+ end
@@ -0,0 +1 @@
1
+ class String; def /(s) File.join(self, s) end end
@@ -39,7 +39,19 @@
39
39
  $('#stage').centralize();
40
40
  });
41
41
  $(window).resize(function() { $('#stage').centralize() });
42
- loadConfig(function() { getSlide($.shining.slides.current) });
42
+ $(document).click(function(event) {
43
+ if ($(event.target).is('a')) return false;
44
+ if (event.pageX < ($(window).width() / 2)) {
45
+ $.shining.previousSlide();
46
+ } else {
47
+ $.shining.nextSlide();
48
+ }
49
+ })
50
+ loadConfig(function() {
51
+ getSlide($.shining.slides.current);
52
+ setTitle($.shining.config.title);
53
+ setTheme($.shining.config.theme);
54
+ });
43
55
  }
44
56
 
45
57
  function getSlide(name) {
@@ -60,12 +72,27 @@
60
72
  loadSlide(name);
61
73
  }
62
74
  }
75
+
76
+ function setTitle(title) {
77
+ if (!title) { return false };
78
+ $('title').text(title);
79
+ }
80
+
81
+ function setTheme(name) {
82
+ if (!name || name == "default") { return false };
83
+ var path = $('link.theme').attr('href').replace('default.css', name + 'css');
84
+ return $('link.theme').attr('href', path);
85
+ }
63
86
 
64
87
  // private
65
88
  function slide(name) {
66
89
  return 'slides/' + name;
67
90
  }
68
91
 
92
+ function vendored() {
93
+ return $('script:first').attr('src').match(/^vendor/);
94
+ }
95
+
69
96
  function loadSlide(name) {
70
97
  $('#stage').load(
71
98
  slide(name).markup(),
@@ -1,7 +1,47 @@
1
+ $:.unshift File.join(File.dirname(__FILE__))
2
+
1
3
  require 'rubygems'
2
- require 'tilt'
3
- require 'haml'
4
- require 'tmpdir'
5
- require 'fileutils'
4
+ require 'ext/string'
5
+ require 'ext/filemethods'
6
+ require 'shining/preso'
7
+
8
+ module Shining
9
+ class << self
10
+ def say something
11
+ STDOUT.puts(something) unless defined?(Spec) # shush when running tests
12
+ yield if block_given?
13
+ end
14
+
15
+ def error message
16
+ STDERR.puts message
17
+ end
18
+
19
+ def root
20
+ @root ||= File.expand_path File.dirname(__FILE__)/'..'
21
+ end
22
+
23
+ def templates_path
24
+ root/'templates'
25
+ end
6
26
 
7
- SHINING_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
27
+ def sample_content_for format = 'html'
28
+ case format
29
+ when 'markdown'
30
+ <<-CONTENTS
31
+ # #{name}
32
+ This is a new slide. It needs some lovin'!
33
+ CONTENTS
34
+ when 'haml'
35
+ <<-CONTENTS
36
+ %h1.centered #{name}
37
+ %p.centered This is a new slide. It needs some lovin'!
38
+ CONTENTS
39
+ when 'html'
40
+ <<-CONTENTS
41
+ <h1 class="centered">#{name}</h1>
42
+ <p class="centered">This is a new slide. It needs some lovin'!</p>
43
+ CONTENTS
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,108 @@
1
+ require 'fileutils'
2
+ require 'json/pure'
3
+ require 'tilt'
4
+
5
+ module Shining
6
+
7
+ class Preso
8
+ include FileMethods and extend FileMethods
9
+ attr_accessor :path
10
+
11
+ SLIDE_FORMATS = %w(haml markdown html)
12
+ TEMPLATE_FORMATS = SLIDE_FORMATS - ['html']
13
+
14
+ def initialize dir, fresh = true
15
+ @path = expand(dir)
16
+ if fresh
17
+ new_dir dir
18
+ copy_templates
19
+ end
20
+ @config = json(@path/'config.json')
21
+ end
22
+
23
+ def self.open dir
24
+ begin
25
+ new dir, false
26
+ rescue
27
+ raise "#{dir} is not a Shining presentation!"
28
+ end
29
+ end
30
+
31
+ def config refresh = false
32
+ refresh ? @config = json(path/'config.json') : @config
33
+ end
34
+
35
+ def save_config!
36
+ new_file path/'config.json' do JSON.pretty_generate(@config) end
37
+ true
38
+ end
39
+
40
+ def copy_templates
41
+ %w(config.json slides).each do |template|
42
+ copy Shining.templates_path/template, @path + '/'
43
+ end
44
+ new_file @path/'index.html' do erb(Shining.templates_path/'index.html') end
45
+ true
46
+ end
47
+
48
+ def templates
49
+ Dir[path/'slides'/"*.{#{TEMPLATE_FORMATS.join(',')}}"].map { |template| basename(template) }
50
+ end
51
+
52
+ def new_slide file, options = {}
53
+ file = basename(file)
54
+ name, format = basename(file, extname(file)), extname(file).sub(/^./, '')
55
+ raise ArgumentError, "Format needs to be #{SLIDE_FORMATS.join(' or ')}." unless SLIDE_FORMATS.include? format
56
+ new_file path/'slides'/file do Shining.sample_content_for(format) end
57
+ new_file path/'slides'/"#{name}.css" if options[:with].include?('styles') rescue nil
58
+ new_file path/'slides'/"#{name}.js" if options[:with].include?('script') rescue nil
59
+ config['slides'] << name and save_config!
60
+ end
61
+
62
+ def slides
63
+ @config['slides']
64
+ end
65
+
66
+ def templates
67
+ Dir[path/'slides'/"*.{#{TEMPLATE_FORMATS.join(',')}}"].map { |t| basename(t) }
68
+ end
69
+
70
+ def compile_templates!
71
+ templates.each do |template|
72
+ begin
73
+ target = basename(template).sub(extname(template), '.html')
74
+ rendered = Tilt.new(path/'slides'/template).render
75
+ new_file path/'slides'/target do rendered end
76
+ rescue RuntimeError
77
+ Shining.error "Tilt coult not compile #{File.basename template}. Skipping."
78
+ end
79
+ end
80
+ end
81
+
82
+ def vendorize!
83
+ new_dir @path/'vendor'
84
+ %w(lib css images themes).each do |required|
85
+ copy Shining.root/required, @path/'vendor/'
86
+ end
87
+ new_file @path/'index.html' do erb(Shining.templates_path/'index.html') end
88
+ true
89
+ end
90
+
91
+ def vendorized?
92
+ dir? @path/'vendor'
93
+ end
94
+
95
+ def unvendorize!
96
+ delete! @path/'vendor'
97
+ copy_templates
98
+ end
99
+
100
+ def vendorized?
101
+ dir? @path/'vendor'/'lib' and
102
+ dir? @path/'vendor'/'themes' and
103
+ dir? @path/'vendor'/'css' and
104
+ dir? @path/'vendor'/'images'
105
+ end
106
+ end
107
+
108
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{shining}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Julio Cesar Ody"]
12
- s.date = %q{2010-03-08}
12
+ s.date = %q{2010-03-11}
13
13
  s.description = %q{Webkit + CSS + Javascript = awesome presos}
14
14
  s.email = %q{julio.ody@gmail.com}
15
15
  s.executables = ["console", "shine"]
@@ -31,13 +31,19 @@ Gem::Specification.new do |s|
31
31
  "images/page_white_code.png",
32
32
  "images/page_white_copy.png",
33
33
  "images/printer.png",
34
+ "lib/ext/filemethods.rb",
35
+ "lib/ext/string.rb",
34
36
  "lib/jquery-1.4.1.min.js",
35
37
  "lib/jquery.shining.js",
38
+ "lib/plugins/jquery.shining-audio-0.0.1.js",
36
39
  "lib/shBrushAll.js",
37
40
  "lib/shCore.js",
38
41
  "lib/shining.rb",
42
+ "lib/shining/preso.rb",
39
43
  "shining.gemspec",
40
44
  "spec/cli_spec.rb",
45
+ "spec/generators_spec.rb",
46
+ "spec/preso_spec.rb",
41
47
  "spec/sample/base.css",
42
48
  "spec/sample/config.json",
43
49
  "spec/sample/effects.css",
@@ -62,6 +68,8 @@ Gem::Specification.new do |s|
62
68
  s.summary = %q{Webkit + CSS + Javascript = awesome presos}
63
69
  s.test_files = [
64
70
  "spec/cli_spec.rb",
71
+ "spec/generators_spec.rb",
72
+ "spec/preso_spec.rb",
65
73
  "spec/shining_spec.rb",
66
74
  "spec/spec_helper.rb"
67
75
  ]
@@ -73,6 +81,8 @@ Gem::Specification.new do |s|
73
81
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
74
82
  s.add_runtime_dependency(%q<haml>, [">= 2.2.17"])
75
83
  s.add_runtime_dependency(%q<json_pure>, [">= 1.1.9"])
84
+ s.add_runtime_dependency(%q<tilt>, [">= 0.6"])
85
+ s.add_runtime_dependency(%q<rdiscount>, ["> 1.6.3"])
76
86
  s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
77
87
  s.add_development_dependency(%q<stackdeck>, ["= 0.2.0"])
78
88
  s.add_development_dependency(%q<johnson>, ["= 2.0.0.pre2"])
@@ -83,6 +93,8 @@ Gem::Specification.new do |s|
83
93
  else
84
94
  s.add_dependency(%q<haml>, [">= 2.2.17"])
85
95
  s.add_dependency(%q<json_pure>, [">= 1.1.9"])
96
+ s.add_dependency(%q<tilt>, [">= 0.6"])
97
+ s.add_dependency(%q<rdiscount>, ["> 1.6.3"])
86
98
  s.add_dependency(%q<rspec>, ["= 1.3.0"])
87
99
  s.add_dependency(%q<stackdeck>, ["= 0.2.0"])
88
100
  s.add_dependency(%q<johnson>, ["= 2.0.0.pre2"])
@@ -94,6 +106,8 @@ Gem::Specification.new do |s|
94
106
  else
95
107
  s.add_dependency(%q<haml>, [">= 2.2.17"])
96
108
  s.add_dependency(%q<json_pure>, [">= 1.1.9"])
109
+ s.add_dependency(%q<tilt>, [">= 0.6"])
110
+ s.add_dependency(%q<rdiscount>, ["> 1.6.3"])
97
111
  s.add_dependency(%q<rspec>, ["= 1.3.0"])
98
112
  s.add_dependency(%q<stackdeck>, ["= 0.2.0"])
99
113
  s.add_dependency(%q<johnson>, ["= 2.0.0.pre2"])
@@ -2,68 +2,72 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
3
  describe 'shine' do
4
4
  PRESO = Dir.tmpdir/'shining-tmp'/'preso'
5
- SHINE = ROOT/'bin'/'shine'
6
-
5
+ SHINE = Shining.root/'bin'/'shine'
6
+
7
7
  def new_preso
8
8
  system "#{SHINE} #{PRESO}"
9
9
  end
10
-
10
+
11
11
  def vendorize
12
12
  system "cd #{PRESO} && #{SHINE} vendor"
13
13
  end
14
-
15
- def new_slide(name)
16
- system "cd #{PRESO} && #{SHINE} slide #{name}"
14
+
15
+ def new_slide(name, format = 'html')
16
+ system "cd #{PRESO} && #{SHINE} slide #{name} #{format}"
17
17
  end
18
-
18
+
19
19
  def compile_templates
20
20
  system "cd #{PRESO} && #{SHINE} compile"
21
21
  end
22
-
22
+
23
23
  def make_haml_template!(name)
24
24
  File.open(PRESO/'slides'/"#{name}.haml", 'w') { |f| f << "%p LOOK MA" }
25
25
  end
26
-
26
+
27
27
  before :all do
28
28
  FileUtils.rm_rf Dir.tmpdir/'shining-tmp'
29
29
  FileUtils.mkdir_p Dir.tmpdir/'shining-tmp'
30
30
  end
31
-
31
+
32
32
  before :each do
33
33
  FileUtils.rm_rf PRESO
34
34
  new_preso
35
35
  end
36
-
36
+
37
37
  it "creates a new shining preso when passing an argument thats not 'build', 'compile', or 'slide'" do
38
38
  File.directory?(PRESO).should == true
39
39
  end
40
-
40
+
41
41
  describe 'the slide option' do
42
42
  it "creates a new slide and slide script named 'foo' on 'shine slide foo'" do
43
43
  new_slide 'foo'
44
44
  File.exists?(PRESO/'slides'/'foo.html').should be_true
45
45
  File.exists?(PRESO/'slides'/'foo.js').should be_true
46
46
  end
47
-
47
+
48
+ it "creates a new slide template named 'test.haml' on 'shine slide test haml'" do
49
+ new_slide 'test', 'haml'
50
+ File.exists?(PRESO/'slides'/'test.haml').should be_true
51
+ File.exists?(PRESO/'slides'/'test.js').should be_true
52
+ end
53
+
48
54
  it "updates the presentation's config file with the slide added" do
49
55
  new_slide 'test'
50
56
  config = JSON.parse(File.read(PRESO/'config.json'))
51
57
  config['slides'].should include('test')
52
58
  end
53
-
54
- it "won't let you create a slide with the same name of an already existing one"
55
59
  end
56
-
60
+
57
61
  it "vendorizes Shining to #{PRESO/'vendor'} with the 'vendor' option" do
58
62
  vendorize
59
63
  %w(lib themes css).each do |required|
60
64
  File.exists?(PRESO/'vendor'/required).should be_true
61
65
  end
62
66
  end
63
-
67
+
64
68
  it "compiles a Haml template if there is one in #{'PRESO_ROOT'/'slides'/'test.haml'} with the 'compile' option" do
65
69
  make_haml_template! 'test'
66
- compile_templates
70
+ compile_templates
67
71
  File.read(PRESO/'slides'/'test.html').should == "<p>LOOK MA</p>\n"
68
- end
72
+ end
69
73
  end
File without changes
@@ -0,0 +1,115 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ describe 'Shining::Preso' do
4
+
5
+ before :all do
6
+ TMP = Dir.tmpdir/'shining-tmp' unless defined?(TMP)
7
+ FileUtils.rm_rf TMP
8
+ FileUtils.mkdir_p TMP
9
+ end
10
+
11
+ before :each do
12
+ FileUtils.rm_rf TMP/'temp'
13
+ @preso = Shining::Preso.new TMP/'temp'
14
+ end
15
+
16
+ describe '#new' do
17
+ it "creates a folder for the presentation on #new" do
18
+ File.directory?(TMP/'temp').should be_true
19
+ end
20
+
21
+ it "copies an initial set of templates to the presentation folder" do
22
+ (File.exists?(TMP/'temp'/'config.json')
23
+ File.exists?(TMP/'temp'/'index.html')
24
+ File.directory?(TMP/'temp'/'slides')
25
+ File.exists?(TMP/'temp'/'slides'/'welcome.html')).should be_true
26
+ end
27
+ end
28
+
29
+ describe "#open" do
30
+ it "opens an existing presentation" do
31
+ preso = Shining::Preso.open TMP/'temp'
32
+ preso.should be_an_instance_of(Shining::Preso)
33
+ end
34
+
35
+ it "errors out if the directory is not a Shining presentation" do
36
+ lambda do Shining::preso.open TMP end.should raise_error
37
+ end
38
+ end
39
+
40
+ describe 'vendorization' do
41
+ before do
42
+ @preso.vendorize!
43
+ end
44
+
45
+ it "#vendorize! copies everything necessary for the presentation to run without the gem being installed" do
46
+ (File.directory?(@preso.path/'vendor'/'lib') and
47
+ File.directory?(@preso.path/'vendor'/'themes') and
48
+ File.directory?(@preso.path/'vendor'/'css') and
49
+ File.directory?(@preso.path/'vendor'/'images')).should be_true
50
+ end
51
+
52
+ it "returns true on #vendorized? if a presentation is vendorized, false when not" do
53
+ @preso.vendorized?.should be_true
54
+ File.read(@preso.path/'index.html').should =~ /vendor\/lib/
55
+ end
56
+
57
+ it "\"unvendorizes\" a gem on #unvendorize!" do
58
+ @preso.unvendorize!
59
+ (File.directory?(@preso.path/'vendor'/'lib') and
60
+ File.directory?(@preso.path/'vendor'/'themes') and
61
+ File.directory?(@preso.path/'vendor'/'css') and
62
+ File.directory?(@preso.path/'vendor'/'images')).should be_false
63
+ File.read(@preso.path/'index.html').should_not =~ /vendor\/lib/
64
+ end
65
+ end
66
+
67
+ describe 'config' do
68
+ it "#config(true) force loads from config.json" do
69
+ @preso.should_receive :json
70
+ @preso.config(true)
71
+ end
72
+
73
+ it "#config simply returns the in-memory config Hash" do
74
+ @preso.should_not_receive :json
75
+ @preso.config
76
+ end
77
+ end
78
+
79
+ describe 'slides' do
80
+ before do
81
+ FileUtils.rm_f @preso.path/'slides'/'*.haml'
82
+ FileUtils.rm_f @preso.path/'slides'/'*.markdown'
83
+ end
84
+
85
+ it "raises an error if the format is not in the allowed formats list" do
86
+ lambda do @preso.new_slide 'foo.erb' end.should raise_error(ArgumentError)
87
+ end
88
+
89
+ it "#new_slide creates a new Markdown/Haml/HTML template and adds it's name to the config file" do
90
+ @preso.new_slide 'foo.haml'
91
+ JSON.parse(File.read(@preso.path/'config.json'))['slides'].should include('foo')
92
+ end
93
+ end
94
+
95
+ describe 'templates' do
96
+ it "#templates returns exclusively these template formats: #{Shining::Preso::TEMPLATE_FORMATS.join(', ')}." do
97
+ @preso.new_slide 'foo.haml'
98
+ @preso.new_slide 'test.markdown'
99
+ @preso.templates.should include('foo.haml', 'test.markdown')
100
+ @preso.templates.should_not include('welcome.html')
101
+ end
102
+
103
+ it "#compile_templates! compiles either Markdown/Haml templates into HTML (slides)" do
104
+ @preso.new_slide 'test2.haml'
105
+ @preso.new_slide 'test3.markdown'
106
+ @preso.compile_templates!
107
+ (File.exists?(@preso.path/'slides'/'test2.html') and
108
+ File.exists?(@preso.path/'slides'/'test3.html')).should be_true
109
+ end
110
+ end
111
+
112
+ it "returns a collection of slides on #slides, which is what's in @config['slides']" do
113
+ @preso.slides.should include('welcome')
114
+ end
115
+ end
@@ -2,8 +2,8 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
3
  describe 'Shining' do
4
4
  before do
5
- Dir.chdir File.join(ROOT, *%w(spec sample))
6
- @page = Harmony::Page.fetch("file:////#{ROOT}/spec/sample/index.html")
5
+ Dir.chdir File.join(Shining.root, *%w(spec sample))
6
+ @page = Harmony::Page.fetch("file:////#{Shining.root}/spec/sample/index.html")
7
7
  end
8
8
 
9
9
  it "has a stage" do
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'tmpdir'
2
3
  require File.join(File.dirname(__FILE__), *%w(.. lib shining))
3
4
 
4
5
  gem 'stackdeck', '0.2.0'; require 'stackdeck'
@@ -7,8 +8,4 @@ gem 'rspec', '1.3.0'; require 'spec'
7
8
  gem 'rake', '0.8.7'; require 'rake'
8
9
  gem 'envjs', '0.1.4'; require 'envjs'
9
10
  gem 'juliocesar-harmony', '0.5.2'; require 'harmony'
10
- gem 'json_pure', '1.1.9'; require 'json/pure'
11
-
12
- ROOT = File.expand_path File.join(File.dirname(__FILE__), '..')
13
-
14
- class String; def /(s) File.join(self, s) end end
11
+ gem 'json_pure', '1.1.9'; require 'json/pure'
@@ -3,15 +3,15 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5
5
  <title>Genesis</title>
6
- <link rel="stylesheet" type="text/css" href="<%= SHINING_ROOT %>/css/base.css" media="all"/>
7
- <link rel="stylesheet" type="text/css" href="<%= SHINING_ROOT %>/css/effects.css" media="all"/>
8
- <link rel="stylesheet" type="text/css" href="<%= SHINING_ROOT %>/css/shCore.css" media="all"/>
9
- <link rel="stylesheet" type="text/css" href="<%= SHINING_ROOT %>/css/shThemeFadeToGrey.css" media="all"/>
10
- <link rel="stylesheet" type="text/css" href="<%= SHINING_ROOT %>/themes/default.css" media="all"/>
11
- <script type="text/javascript" charset="utf-8" src="<%= SHINING_ROOT %>/lib/jquery-1.4.1.min.js"></script>
12
- <script type="text/javascript" charset="utf-8" src="<%= SHINING_ROOT %>/lib/shCore.js"></script>
13
- <script type="text/javascript" charset="utf-8" src="<%= SHINING_ROOT %>/lib/shBrushAll.js"></script>
14
- <script type="text/javascript" charset="utf-8" src="<%= SHINING_ROOT %>/lib/jquery.shining.js"></script>
6
+ <link rel="stylesheet" type="text/css" href="<%= vendorized? ? 'vendor' : Shining.root %>/css/base.css" media="all"/>
7
+ <link rel="stylesheet" type="text/css" href="<%= vendorized? ? 'vendor' : Shining.root %>/css/effects.css" media="all"/>
8
+ <link rel="stylesheet" type="text/css" href="<%= vendorized? ? 'vendor' : Shining.root %>/css/shCore.css" media="all"/>
9
+ <link rel="stylesheet" type="text/css" href="<%= vendorized? ? 'vendor' : Shining.root %>/css/shThemeFadeToGrey.css" media="all"/>
10
+ <link rel="stylesheet" type="text/css" href="<%= vendorized? ? 'vendor' : Shining.root %>/themes/default.css" media="all"/>
11
+ <script type="text/javascript" charset="utf-8" src="<%= vendorized? ? 'vendor' : Shining.root %>/lib/jquery-1.4.1.min.js"></script>
12
+ <script type="text/javascript" charset="utf-8" src="<%= vendorized? ? 'vendor' : Shining.root %>/lib/shCore.js"></script>
13
+ <script type="text/javascript" charset="utf-8" src="<%= vendorized? ? 'vendor' : Shining.root %>/lib/shBrushAll.js"></script>
14
+ <script type="text/javascript" charset="utf-8" src="<%= vendorized? ? 'vendor' : Shining.root %>/lib/jquery.shining.js"></script>
15
15
  </head>
16
16
  <body>
17
17
  <section id="stage"></section>
@@ -5,7 +5,7 @@ body { background-color: rgb(48, 48, 48) }
5
5
  }
6
6
 
7
7
  h1, h2, h3, p, li { color: rgb(238, 238, 238); text-shadow: rgb(0, 0, 0) 2px 2px 4px }
8
- a { color: rgb(255, 255, 255) }
8
+ a { color: rgb(73, 157, 255) }
9
9
  ul { list-style-type: disc }
10
10
 
11
11
  #controls {
@@ -17,5 +17,6 @@ ul { list-style-type: disc }
17
17
  -webkit-border-top-left-radius: 5px;
18
18
  -webkit-border-top-right-radius: 5px;
19
19
  }
20
- #controls a { display: inline-block; width: 75px; padding: 5px 0; font-weight: bold }
21
- em { font-weight: bold; color: rgb(167, 213, 32) }
20
+ #controls a { display: inline-block; width: 75px; padding: 5px 0; font-weight: bold; color: #fff; }
21
+ em { color: rgb(73, 255, 80) }
22
+ strong { color: rgb(255, 171, 73); font-weight: bold }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shining
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julio Cesar Ody
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-08 00:00:00 +11:00
12
+ date: 2010-03-11 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,26 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.1.9
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: tilt
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0.6"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: rdiscount
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">"
52
+ - !ruby/object:Gem::Version
53
+ version: 1.6.3
54
+ version:
35
55
  - !ruby/object:Gem::Dependency
36
56
  name: rspec
37
57
  type: :development
@@ -126,13 +146,19 @@ files:
126
146
  - images/page_white_code.png
127
147
  - images/page_white_copy.png
128
148
  - images/printer.png
149
+ - lib/ext/filemethods.rb
150
+ - lib/ext/string.rb
129
151
  - lib/jquery-1.4.1.min.js
130
152
  - lib/jquery.shining.js
153
+ - lib/plugins/jquery.shining-audio-0.0.1.js
131
154
  - lib/shBrushAll.js
132
155
  - lib/shCore.js
133
156
  - lib/shining.rb
157
+ - lib/shining/preso.rb
134
158
  - shining.gemspec
135
159
  - spec/cli_spec.rb
160
+ - spec/generators_spec.rb
161
+ - spec/preso_spec.rb
136
162
  - spec/sample/base.css
137
163
  - spec/sample/config.json
138
164
  - spec/sample/effects.css
@@ -179,5 +205,7 @@ specification_version: 3
179
205
  summary: Webkit + CSS + Javascript = awesome presos
180
206
  test_files:
181
207
  - spec/cli_spec.rb
208
+ - spec/generators_spec.rb
209
+ - spec/preso_spec.rb
182
210
  - spec/shining_spec.rb
183
211
  - spec/spec_helper.rb