hyaslide 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f56b285a8341fe0b88ef1f5ce271b6ea9853a284
4
- data.tar.gz: da9b87369da14fbd6d49e84fadd01615748f0453
3
+ metadata.gz: 22c7c4f76f12c7be2c6fb054129f7930b3242e3f
4
+ data.tar.gz: 3f512237b030db92f662c1f85661520dd57f83da
5
5
  SHA512:
6
- metadata.gz: 993f6c4905143ad13fa585ce28a4af2a176bd199fd367fd7ea19094646a086fa87cfef4b4654679fde3880f1047f9eb3dc7b6243a3f248b41b015505b9f0295c
7
- data.tar.gz: c486eeb28d03b7fb1489302dafc4bc4039183227f508feab6654d5339271e9e6db147a4c966f74928aba564fa8c3861455d10e2cc8623874a7d2c3b400e72be6
6
+ metadata.gz: e52ad7732a36b1f21fc70beb8f4c759e888cc5de9693afb58e6ac606395d9d66f096e00e40f069f6e6959e74be55401478eae43e3b8941e26905adb95f7fb0f4
7
+ data.tar.gz: be75426d0761129b76263e3303f33c983a1a9e6711bdd21ab2cb7b461db0a7b502879c16837e275470b18b28168ab36add3a91e698c413f27752362aac02cf86
@@ -7,24 +7,36 @@ require_relative './render_hyaslide'
7
7
 
8
8
  module Hyaslide
9
9
  class SlideLoader
10
- def initialize(dir)
11
- @dir = dir
10
+ MARKDOWN = Redcarpet::Markdown.new(Redcarpet::Render::Hyaslide, fenced_code_blocks: true)
11
+
12
+ def initialize(name)
13
+ @name = name
12
14
  end
13
15
 
14
- def self.load_slide(dir)
15
- markdown = Redcarpet::Markdown.new(Redcarpet::Render::Hyaslide, fenced_code_blocks: true)
16
- File.open("#{dir}/pages/pages.rb", "w+") do |f|
17
- data = File.read("#{dir}/slide.md")
18
- f.write markdown.render(data)
16
+ def self.load_slide(name)
17
+ Dir.mkdir('app/slides') unless Dir.exist?('app/slides')
18
+ Dir.mkdir(src_path(@name)) unless Dir.exist?(src_path(@name))
19
+
20
+ File.open("#{src_path(name)}/pages.rb", "w+") do |f|
21
+ data = File.read("data/#{name}/slide.md")
22
+ f.write MARKDOWN.render(data)
23
+ end
24
+
25
+ File.open("#{src_path(name)}/app.rb", "w+") do |f|
26
+ f.write Tilt::StringTemplate.new(File.expand_path('../../../template/app.rb', __FILE__)).render(Object.new, name: name)
19
27
  end
20
28
  end
21
29
 
30
+ def self.src_path(name)
31
+ "app/slides/#{name}"
32
+ end
33
+
22
34
  def run
23
- Hyaslide::SlideLoader.load_slide(@dir)
35
+ SlideLoader.load_slide(@name)
24
36
 
25
37
  EM.defer do
26
- FSSM.monitor("#{@dir}", "slide.md") do
27
- update {|base, relative| SlideLoader.load_slide }
38
+ FSSM.monitor("data/#{@name}", "slide.md") do
39
+ update {|base, relative| SlideLoader.load_slide(@name) }
28
40
  delete {|base, relative|}
29
41
  create {|base, relative|}
30
42
  end
@@ -1,3 +1,3 @@
1
1
  module Hyaslide
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'slide'
2
+ require 'page_base'
3
+ require 'slides/#{name}/pages'
4
+
5
+ Hyaslide.slide_name = '#{name}'
6
+
7
+ module App
8
+ def self.render
9
+ Hyalite.render(Hyalite.create_element(Hyaslide::Slide, nil), $document['.hyaslide'])
10
+ end
11
+ end
12
+
13
+ $document.ready do
14
+ $window.on(:resize) do
15
+ App.render
16
+ end
17
+
18
+ App.render
19
+ end
@@ -3,13 +3,6 @@ require 'opal-router'
3
3
  require 'browser/interval'
4
4
  require 'browser/location'
5
5
  require 'track_field'
6
- require 'page_base'
7
-
8
- module App
9
- def self.render
10
- Hyalite.render(Hyalite.create_element(Hyaslide::Slide, nil), $document['.hyaslide'])
11
- end
12
- end
13
6
 
14
7
  module Hyaslide
15
8
  SLIDE_WIDTH = 960
@@ -32,6 +25,14 @@ module Hyaslide
32
25
  @title = title
33
26
  end
34
27
 
28
+ def self.slide_name
29
+ @slide_name
30
+ end
31
+
32
+ def self.slide_name=(name)
33
+ @slide_name = name
34
+ end
35
+
35
36
  class Slide
36
37
  include Hyalite::Component
37
38
  include Hyalite::Component::ShortHand
@@ -67,11 +68,11 @@ module Hyaslide
67
68
 
68
69
  router = Router.new
69
70
  router.route('/') { page_to(num) }
70
- router.route('/:page') {|params| p params; set_state(page_number: params[:page].to_i) }
71
+ router.route(':page') {|params| set_state(page_number: params[:page].to_i) }
71
72
  end
72
73
 
73
74
  def page_to(num)
74
- $window.location.assign("/#/#{num}")
75
+ $window.location.assign("/#{Hyaslide.slide_name}##{num}")
75
76
  end
76
77
 
77
78
  def handle_key_down(evt)
@@ -145,12 +146,3 @@ module Hyaslide
145
146
  end
146
147
  end
147
148
 
148
- require 'pages/pages'
149
-
150
- $document.ready do
151
- $window.on(:resize) do
152
- App.render
153
- end
154
-
155
- App.render
156
- end
@@ -1,12 +1,15 @@
1
1
  require 'bundler/setup'
2
2
  Bundler.require(:default)
3
3
 
4
- # require 'hyaslide'
5
4
  require_relative 'server'
6
5
 
7
6
  dir = 'data'
8
- Dir.mkdir dir + '/pages' unless Dir.exist? dir + '/pages'
9
- Hyaslide::SlideLoader.new(dir).run
7
+
8
+ Dir.foreach(dir) do |dir_name|
9
+ if !dir_name.start_with?('.') && File.directory?("#{dir}/#{dir_name}")
10
+ Hyaslide::SlideLoader.new(dir_name).run
11
+ end
12
+ end
10
13
 
11
14
  app = Rack::Builder.app do
12
15
  server = Server.new(host: 'localhost')
@@ -27,7 +27,8 @@ class Server < Sinatra::Base
27
27
  enable :sessions
28
28
  end
29
29
 
30
- get '/' do
30
+ get '/:slide_name' do
31
+ @slide_name = params['slide_name']
31
32
  haml :index
32
33
  end
33
34
 
@@ -2,12 +2,13 @@
2
2
  %html(lang="en" data-framework="hyalite")
3
3
  %head
4
4
  %meta{charset:"utf-8"}
5
- %title Writting web application in Ruby
5
+ %title= @slide_name
6
6
  %link{rel:"stylesheet", href:"assets/css/application.css"}
7
7
  %link{rel:"stylesheet", href:"assets/css/highlight.css"}
8
8
 
9
9
  %body
10
10
  %section.hyaslide
11
11
 
12
- = ::Opal::Sprockets.javascript_include_tag('application', sprockets: settings.opal.sprockets, prefix: 'assets', debug: true)
13
-
12
+ :javascript
13
+ window.slideName = '#{@slide_name}'
14
+ = ::Opal::Sprockets.javascript_include_tag('slides/sample/app', sprockets: settings.opal.sprockets, prefix: 'assets', debug: true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyaslide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - youchan
@@ -236,9 +236,10 @@ files:
236
236
  - lib/hyaslide/render_hyaslide.rb
237
237
  - lib/hyaslide/slide_loader.rb
238
238
  - lib/hyaslide/version.rb
239
+ - template/app.rb
239
240
  - template/project/Gemfile
240
- - template/project/app/application.rb
241
241
  - template/project/app/page_base.rb
242
+ - template/project/app/slide.rb
242
243
  - template/project/app/track_field.rb
243
244
  - template/project/assets/css/application.css
244
245
  - template/project/assets/css/highlight.css
@@ -247,9 +248,8 @@ files:
247
248
  - template/project/assets/images/rabbit.png
248
249
  - template/project/assets/images/turtle.png
249
250
  - template/project/config.ru
250
- - template/project/data/css/custom.css
251
- - template/project/data/pages/pages.rb
252
- - template/project/data/slide.md
251
+ - template/project/data/sample/css/custom.css
252
+ - template/project/data/sample/slide.md
253
253
  - template/project/server.rb
254
254
  - template/project/views/index.haml
255
255
  homepage: https://github.com/youchan/hyalide
@@ -1,37 +0,0 @@
1
- class Hyaslide::Page0 < Hyaslide::PageBase
2
- def header
3
- h1(nil, "Title")
4
- end
5
-
6
- def content
7
- [].tap do |children|
8
- children << p({className:"author"}, "Your Name")
9
- end
10
- end
11
- end
12
-
13
- class Hyaslide::Page1 < Hyaslide::PageBase
14
- def content
15
- [].tap do |children|
16
- children << h4(nil, "Press 's' then starting the race of rabbit and turtle.")
17
- end
18
- end
19
- end
20
-
21
- class Hyaslide::Page2 < Hyaslide::PageBase
22
- def header
23
- h2(nil, "Slide")
24
- end
25
-
26
- def content
27
- [].tap do |children|
28
- children << ul(nil,
29
- li(nil, "Listing"),
30
- li(nil, "...")
31
- )
32
- end
33
- end
34
- end
35
-
36
- Hyaslide.page_count = 3
37
- Hyaslide.title = "Title"