be able to create a presentation and use thor for cli
This commit is contained in:
parent
480e33d26a
commit
0bfa640774
14
README.md
14
README.md
@ -5,3 +5,17 @@ Attentive is a new take on Ruby presentation software. It provides lots of smart
|
||||
* Pygments for syntax highlighting.
|
||||
* Simple slide syntax, really really similar to how Showoff does it.
|
||||
|
||||
Here's what you can do:
|
||||
|
||||
`attentive create <presenation name>`
|
||||
|
||||
Create a new presentation.
|
||||
|
||||
`attentive`
|
||||
|
||||
Run the presentation that's in the current directory on port 9393.
|
||||
|
||||
`attentive start -p <port>`
|
||||
|
||||
Run the current presentation on another port.
|
||||
|
||||
|
@ -16,12 +16,47 @@ require 'pygments'
|
||||
require 'coffee_script'
|
||||
require 'sass'
|
||||
|
||||
begin
|
||||
load 'presentation.rb'
|
||||
rescue LoadError => e
|
||||
end
|
||||
|
||||
# make sure pygments is ready
|
||||
Pygments.highlight("attentive")
|
||||
|
||||
Rack::Handler::WEBrick.run(Attentive::Server, :Port => 9393) do |server|
|
||||
class Attentive::CLI < Thor
|
||||
include Thor::Actions
|
||||
|
||||
default_task :start
|
||||
|
||||
desc "start", "Start a Rack server for previewing the presentation"
|
||||
method_options [ :port, '-p' ] => 9393
|
||||
def start
|
||||
if Attentive.has_presentation?
|
||||
Rack::Handler::WEBrick.run(Attentive::Server, :Port => options[:port]) do |server|
|
||||
trap(:INT) { server.shutdown }
|
||||
end
|
||||
else
|
||||
raise Attentive::NoPresentationError
|
||||
end
|
||||
end
|
||||
|
||||
def self.source_root
|
||||
File.expand_path('../../skel', __FILE__)
|
||||
end
|
||||
|
||||
desc "create", "Create a new skeleton presentation"
|
||||
def create(name)
|
||||
self.destination_root = File.join(Dir.pwd, name)
|
||||
|
||||
Dir[File.join(self.class.source_root, '**/*')].each do |file|
|
||||
if File.file?(file)
|
||||
filename = file.gsub(self.class.source_root + '/', '')
|
||||
|
||||
template filename, filename
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Attentive::CLI.start
|
||||
|
@ -2,6 +2,12 @@
|
||||
#= require fathom
|
||||
|
||||
$(->
|
||||
$('#slides').fathom(displayMode: 'multi', scrollLength: 250)
|
||||
fathom = new Fathom('#slides', displayMode: 'multi', scrollLength: 250)
|
||||
|
||||
setTimeout(
|
||||
->
|
||||
$(window).trigger('resize')
|
||||
, 250
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -4,14 +4,22 @@ module Attentive
|
||||
autoload :Server, 'attentive/server'
|
||||
|
||||
class << self
|
||||
attr_accessor :title
|
||||
attr_accessor :title, :has_presentation
|
||||
|
||||
def has_presentation?
|
||||
@has_presentation == true
|
||||
end
|
||||
end
|
||||
|
||||
def self.configure
|
||||
yield self
|
||||
|
||||
Attentive.has_presentation = true
|
||||
end
|
||||
|
||||
def self.root
|
||||
Pathname(File.expand_path('../..', __FILE__))
|
||||
end
|
||||
|
||||
class NoPresentationError < StandardError ; end
|
||||
end
|
||||
|
2
skel/assets/javascripts/application.js.coffee
Normal file
2
skel/assets/javascripts/application.js.coffee
Normal file
@ -0,0 +1,2 @@
|
||||
#= require attentive
|
||||
|
5
skel/assets/stylesheets/application.css.scss
Normal file
5
skel/assets/stylesheets/application.css.scss
Normal file
@ -0,0 +1,5 @@
|
||||
@import 'attentive';
|
||||
|
||||
h1, h2, h3, li, p {
|
||||
font-family: Nunito, sans-serif;
|
||||
}
|
4
skel/presentation.rb
Normal file
4
skel/presentation.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Attentive.configure do |c|
|
||||
c.title = "My presentation"
|
||||
end
|
||||
|
32
skel/presentation/01_hello.slides
Normal file
32
skel/presentation/01_hello.slides
Normal file
@ -0,0 +1,32 @@
|
||||
!SLIDE
|
||||
# Hello! Welcome to Attentive.
|
||||
|
||||
!SLIDE
|
||||
# You can put Markdown in these slides...
|
||||
|
||||
!SLIDE
|
||||
<h1>...or HTML</h1>
|
||||
|
||||
!SLIDE
|
||||
# or code!
|
||||
|
||||
``` ruby
|
||||
class Cat
|
||||
def meow
|
||||
"meow"
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
!SLIDE
|
||||
# Easily style your slides using Sass & Compass...
|
||||
|
||||
!SLIDE
|
||||
# Add other interactivity (if you want) with CoffeeScript...
|
||||
|
||||
!SLIDE
|
||||
# Configure your presentation with Ruby!
|
||||
|
||||
!SLIDE
|
||||
## [github.com/johnbintz/attentive](http://github.com/johnbintz/attentive)
|
||||
|
4
skel/views/_header.haml
Normal file
4
skel/views/_header.haml
Normal file
@ -0,0 +1,4 @@
|
||||
- # this file gets included in the output, inside the <head> tags
|
||||
- # use it for including things like Web fonts
|
||||
%link{:href => 'http://fonts.googleapis.com/css?family=Nunito', :rel => 'stylesheet', :type => 'text/css'}/
|
||||
|
Loading…
Reference in New Issue
Block a user