hyaslide 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hyaslide/slide_loader.rb +15 -6
- data/lib/hyaslide/version.rb +1 -1
- data/template/project/config.ru +3 -2
- data/template/project/server.rb +10 -1
- data/template/project/views/index.haml +7 -8
- data/template/project/views/slide.haml +14 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cd7ecd098a2d95e48f5d27ca8212ba21cf4ba77
|
4
|
+
data.tar.gz: 8d42c325a89bf5b0dcd35b69f289d2cdc157d073
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbf94875daafe94bb46905a967295e170c8bf9dc969b9bcc4aacde24142bd4499857c1569afd8e2f447ce36eb6ab2a481b427f79fcb24405ef6b157d4733ab2a
|
7
|
+
data.tar.gz: e10bf17f9df85b246dd732ab6bffb88c7b309df19b9c759327af265de784356eb0e9b0ea62d44152d06b7544fbdae4a3a2fa3e0af99ba80d6bb753f90f2c69fa
|
@@ -9,14 +9,23 @@ module Hyaslide
|
|
9
9
|
class SlideLoader
|
10
10
|
MARKDOWN = Redcarpet::Markdown.new(Redcarpet::Render::Hyaslide, fenced_code_blocks: true)
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
attr_reader :slides
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@slides = []
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
18
|
+
def load_slide(name)
|
17
19
|
Dir.mkdir('app/slides') unless Dir.exist?('app/slides')
|
18
20
|
Dir.mkdir(src_path(name)) unless Dir.exist?(src_path(name))
|
19
21
|
|
22
|
+
File.foreach("data/#{name}/slide.md") do |line|
|
23
|
+
if line =~ /\A# (.+)/
|
24
|
+
@slides << {name: name, title: $1}
|
25
|
+
break
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
20
29
|
File.open("#{src_path(name)}/pages.rb", "w+") do |f|
|
21
30
|
data = File.read("data/#{name}/slide.md")
|
22
31
|
f.write MARKDOWN.render(data)
|
@@ -27,12 +36,12 @@ module Hyaslide
|
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
30
|
-
def
|
39
|
+
def src_path(name)
|
31
40
|
"app/slides/#{name}"
|
32
41
|
end
|
33
42
|
|
34
|
-
def
|
35
|
-
|
43
|
+
def add_slide(name)
|
44
|
+
load_slide(name)
|
36
45
|
|
37
46
|
EM.defer do
|
38
47
|
FSSM.monitor("data/#{@name}", "slide.md") do
|
data/lib/hyaslide/version.rb
CHANGED
data/template/project/config.ru
CHANGED
@@ -5,14 +5,15 @@ require_relative 'server'
|
|
5
5
|
|
6
6
|
dir = 'data'
|
7
7
|
|
8
|
+
slide_loader = Hyaslide::SlideLoader.new
|
8
9
|
Dir.foreach(dir) do |dir_name|
|
9
10
|
if !dir_name.start_with?('.') && File.directory?("#{dir}/#{dir_name}")
|
10
|
-
|
11
|
+
slide_loader.add_slide(dir_name)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
15
|
app = Rack::Builder.app do
|
15
|
-
server = Server.new(host: 'localhost')
|
16
|
+
server = Server.new(slide_loader, host: 'localhost')
|
16
17
|
|
17
18
|
map '/' do
|
18
19
|
run server
|
data/template/project/server.rb
CHANGED
@@ -3,6 +3,10 @@ require 'opal'
|
|
3
3
|
require 'opal/sprockets'
|
4
4
|
|
5
5
|
class Server < Sinatra::Base
|
6
|
+
def initialize(slide_loader, *args, &block)
|
7
|
+
@slide_loader = slide_loader
|
8
|
+
super(*args, &block)
|
9
|
+
end
|
6
10
|
|
7
11
|
def sprockets
|
8
12
|
settings.opal.sprockets
|
@@ -27,9 +31,14 @@ class Server < Sinatra::Base
|
|
27
31
|
enable :sessions
|
28
32
|
end
|
29
33
|
|
34
|
+
get '/' do
|
35
|
+
@slides = @slide_loader.slides
|
36
|
+
haml :index
|
37
|
+
end
|
38
|
+
|
30
39
|
get '/:slide_name' do
|
31
40
|
@slide_name = params['slide_name']
|
32
|
-
haml :
|
41
|
+
haml :slide
|
33
42
|
end
|
34
43
|
|
35
44
|
get "/favicon.ico" do
|
@@ -2,13 +2,12 @@
|
|
2
2
|
%html(lang="en" data-framework="hyalite")
|
3
3
|
%head
|
4
4
|
%meta{charset:"utf-8"}
|
5
|
-
%title
|
6
|
-
%link{rel:"stylesheet", href:"assets/css/application.css"}
|
7
|
-
%link{rel:"stylesheet", href:"assets/css/highlight.css"}
|
5
|
+
%title Index of slides
|
8
6
|
|
9
7
|
%body
|
10
|
-
%
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
%h1 Index of slides
|
9
|
+
%section
|
10
|
+
%ul
|
11
|
+
- @slides.each do |slide|
|
12
|
+
%li
|
13
|
+
%a{href: slide[:name]}= slide[:title]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
!!!
|
2
|
+
%html(lang="en" data-framework="hyalite")
|
3
|
+
%head
|
4
|
+
%meta{charset:"utf-8"}
|
5
|
+
%title= @slide_name
|
6
|
+
%link{rel:"stylesheet", href:"assets/css/application.css"}
|
7
|
+
%link{rel:"stylesheet", href:"assets/css/highlight.css"}
|
8
|
+
|
9
|
+
%body
|
10
|
+
%section.hyaslide
|
11
|
+
|
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyaslide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youchan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- template/project/data/sample/slide.md
|
253
253
|
- template/project/server.rb
|
254
254
|
- template/project/views/index.haml
|
255
|
+
- template/project/views/slide.haml
|
255
256
|
homepage: https://github.com/youchan/hyalide
|
256
257
|
licenses:
|
257
258
|
- MIT
|