mg_showoff 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +532 -0
  3. data/Rakefile +7 -0
  4. data/bin/showoff +145 -0
  5. data/lib/commandline_parser.rb +67 -0
  6. data/lib/princely.rb +84 -0
  7. data/lib/showoff.rb +452 -0
  8. data/lib/showoff_utils.rb +369 -0
  9. data/public/css/fg.menu.css +114 -0
  10. data/public/css/onepage.css +60 -0
  11. data/public/css/pdf.css +12 -0
  12. data/public/css/reset.css +53 -0
  13. data/public/css/sh_style.css +66 -0
  14. data/public/css/showoff.css +361 -0
  15. data/public/css/spinner_bar.gif +0 -0
  16. data/public/css/theme/images/ui-bg_diagonals-small_100_f0efea_40x40.png +0 -0
  17. data/public/css/theme/images/ui-bg_flat_35_f0f0f0_40x100.png +0 -0
  18. data/public/css/theme/images/ui-bg_glass_55_fcf0ba_1x400.png +0 -0
  19. data/public/css/theme/images/ui-bg_glow-ball_25_2e2e28_600x600.png +0 -0
  20. data/public/css/theme/images/ui-bg_highlight-soft_100_f0efea_1x100.png +0 -0
  21. data/public/css/theme/images/ui-bg_highlight-soft_25_327E04_1x100.png +0 -0
  22. data/public/css/theme/images/ui-bg_highlight-soft_25_5A9D1A_1x100.png +0 -0
  23. data/public/css/theme/images/ui-bg_highlight-soft_95_ffedad_1x100.png +0 -0
  24. data/public/css/theme/images/ui-bg_inset-soft_22_3b3b35_1x100.png +0 -0
  25. data/public/css/theme/images/ui-icons_808080_256x240.png +0 -0
  26. data/public/css/theme/images/ui-icons_8DC262_256x240.png +0 -0
  27. data/public/css/theme/images/ui-icons_cd0a0a_256x240.png +0 -0
  28. data/public/css/theme/images/ui-icons_e7e6e4_256x240.png +0 -0
  29. data/public/css/theme/images/ui-icons_eeeeee_256x240.png +0 -0
  30. data/public/css/theme/images/ui-icons_ffffff_256x240.png +0 -0
  31. data/public/css/theme/ui.accordion.css +9 -0
  32. data/public/css/theme/ui.all.css +2 -0
  33. data/public/css/theme/ui.base.css +9 -0
  34. data/public/css/theme/ui.core.css +37 -0
  35. data/public/css/theme/ui.datepicker.css +62 -0
  36. data/public/css/theme/ui.dialog.css +13 -0
  37. data/public/css/theme/ui.progressbar.css +4 -0
  38. data/public/css/theme/ui.resizable.css +13 -0
  39. data/public/css/theme/ui.slider.css +17 -0
  40. data/public/css/theme/ui.tabs.css +9 -0
  41. data/public/css/theme/ui.theme.css +245 -0
  42. data/public/favicon.ico +0 -0
  43. data/public/js/core.js +79 -0
  44. data/public/js/fg.menu.js +645 -0
  45. data/public/js/jTypeWriter.js +26 -0
  46. data/public/js/jquery-1.4.2.min.js +154 -0
  47. data/public/js/jquery-print.js +109 -0
  48. data/public/js/jquery.batchImageLoad.js +56 -0
  49. data/public/js/jquery.cookie.js +96 -0
  50. data/public/js/jquery.cycle.all.js +1284 -0
  51. data/public/js/jquery.doubletap-0.1.js +105 -0
  52. data/public/js/jquery.uuid.js +24 -0
  53. data/public/js/jquery.ws-0.3pre.js +201 -0
  54. data/public/js/onepage.js +5 -0
  55. data/public/js/sh_lang/sh_bison.min.js +1 -0
  56. data/public/js/sh_lang/sh_c.min.js +1 -0
  57. data/public/js/sh_lang/sh_caml.min.js +1 -0
  58. data/public/js/sh_lang/sh_changelog.min.js +1 -0
  59. data/public/js/sh_lang/sh_cpp.min.js +1 -0
  60. data/public/js/sh_lang/sh_csharp.min.js +1 -0
  61. data/public/js/sh_lang/sh_css.min.js +1 -0
  62. data/public/js/sh_lang/sh_cucumber.min.js +2 -0
  63. data/public/js/sh_lang/sh_desktop.min.js +1 -0
  64. data/public/js/sh_lang/sh_diff.min.js +1 -0
  65. data/public/js/sh_lang/sh_flex.min.js +1 -0
  66. data/public/js/sh_lang/sh_glsl.min.js +1 -0
  67. data/public/js/sh_lang/sh_haxe.min.js +1 -0
  68. data/public/js/sh_lang/sh_html.min.js +1 -0
  69. data/public/js/sh_lang/sh_java.min.js +1 -0
  70. data/public/js/sh_lang/sh_javascript.min.js +1 -0
  71. data/public/js/sh_lang/sh_javascript_dom.min.js +1 -0
  72. data/public/js/sh_lang/sh_latex.min.js +1 -0
  73. data/public/js/sh_lang/sh_ldap.min.js +1 -0
  74. data/public/js/sh_lang/sh_log.min.js +1 -0
  75. data/public/js/sh_lang/sh_lsm.min.js +1 -0
  76. data/public/js/sh_lang/sh_m4.min.js +1 -0
  77. data/public/js/sh_lang/sh_makefile.min.js +1 -0
  78. data/public/js/sh_lang/sh_oracle.min.js +1 -0
  79. data/public/js/sh_lang/sh_pascal.min.js +1 -0
  80. data/public/js/sh_lang/sh_perl.min.js +1 -0
  81. data/public/js/sh_lang/sh_php.min.js +1 -0
  82. data/public/js/sh_lang/sh_prolog.min.js +1 -0
  83. data/public/js/sh_lang/sh_properties.min.js +1 -0
  84. data/public/js/sh_lang/sh_python.min.js +1 -0
  85. data/public/js/sh_lang/sh_ruby.min.js +1 -0
  86. data/public/js/sh_lang/sh_scala.min.js +1 -0
  87. data/public/js/sh_lang/sh_sh.min.js +1 -0
  88. data/public/js/sh_lang/sh_slang.min.js +1 -0
  89. data/public/js/sh_lang/sh_sml.min.js +1 -0
  90. data/public/js/sh_lang/sh_spec.min.js +1 -0
  91. data/public/js/sh_lang/sh_sql.min.js +1 -0
  92. data/public/js/sh_lang/sh_tcl.min.js +1 -0
  93. data/public/js/sh_lang/sh_xml.min.js +1 -0
  94. data/public/js/sh_lang/sh_xorg.min.js +1 -0
  95. data/public/js/sh_main.min.js +4 -0
  96. data/public/js/showoff.js +623 -0
  97. data/public/js/showoffcore.js +13 -0
  98. data/views/index.erb +85 -0
  99. data/views/onepage.erb +35 -0
  100. metadata +227 -0
data/bin/showoff ADDED
@@ -0,0 +1,145 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'showoff'
5
+ require 'rubygems'
6
+ require 'gli'
7
+
8
+ include GLI
9
+
10
+ version ShowOff::Version
11
+
12
+ desc 'Create new showoff presentation'
13
+ arg_name 'dir_name'
14
+ long_desc 'This command helps start a new showoff presentation by setting up the proper directory structure for you. It takes the directory name you would like showoff to create for you.'
15
+ command [:create,:init] do |c|
16
+
17
+ c.desc 'Don''t create sample slides'
18
+ c.switch [:n,:nosamples]
19
+
20
+ c.desc 'sample slide directory name'
21
+ c.default_value 'one'
22
+ c.flag [:d,:slidedir]
23
+
24
+ c.action do |global_options,options,args|
25
+ raise "dir_name is required" if args.empty?
26
+ ShowOffUtils.create(args[0],!options[:n],options[:d])
27
+ end
28
+ end
29
+
30
+ desc 'Puts your showoff presentation into a gh-pages branch'
31
+ long_desc 'Generates a static version of your presentation into your gh-pages branch for publishing to GitHub Pages'
32
+ command :github do |c|
33
+ c.action do |global_options,options,args|
34
+ ShowOffUtils.github
35
+ end
36
+ end
37
+
38
+ desc 'Serves the showoff presentation in the current directory'
39
+ desc 'Setup your presentation to serve on Heroku'
40
+ arg_name 'heroku_name'
41
+ long_desc 'Creates the Gemfile and config.ru file needed to push a showoff pres to heroku. It will then run ''heroku create'' for you to register the new project on heroku and add the remote for you. Then all you need to do is commit the new created files and run ''git push heroku'' to deploy.'
42
+ command :heroku do |c|
43
+
44
+ c.desc 'add password protection to your heroku site'
45
+ c.flag [:p,:password]
46
+
47
+ c.desc 'force overwrite of existing Gemfile/.gems and config.ru files if they exist'
48
+ c.switch [:f,:force]
49
+
50
+ c.desc 'Use older-style .gems file instead of bundler-style Gemfile'
51
+ c.switch [:g,:dotgems]
52
+
53
+ c.action do |global_options,options,args|
54
+ raise "heroku_name is required" if args.empty?
55
+ ShowOffUtils.heroku(args[0],options[:f],options[:p],options[:g])
56
+ end
57
+ end
58
+
59
+ desc 'Serves the showoff presentation in the specified (or current) directory'
60
+ arg_name "[pres_dir]"
61
+ default_value "."
62
+ command :serve do |c|
63
+
64
+ c.desc 'Show verbose messaging'
65
+ c.switch :verbose
66
+
67
+ c.desc 'Port on which to run'
68
+ c.default_value "9090"
69
+ c.flag [:p,:port]
70
+
71
+ c.desc 'Host or ip to run on'
72
+ c.default_value "localhost"
73
+ c.flag [:h,:host]
74
+
75
+ c.desc 'JSON file used to describe presentation'
76
+ c.default_value "showoff.json"
77
+ c.flag [:f, :pres_file]
78
+
79
+ c.action do |global_options,options,args|
80
+ ShowOff.run! :host => options[:h], :port => options[:p].to_i, :pres_file => options[:f], :pres_dir => args[0], :verbose => options[:verbose]
81
+ end
82
+ end
83
+
84
+ desc 'Add a new slide at the end in a given dir'
85
+ arg_name '[title]'
86
+ long_desc 'Outputs or creates a new slide. With -d and -n, a new slide is created in the given dir, numbered to appear as the last slide in that dir (use -u to avoid numbering). Without those, outputs the slide markdown to stdout (useful for shelling out from your editor). You may also specify a source file to use for a code slide'
87
+ command [:add,:new] do |c|
88
+ c.desc 'Don''t number the slide, use the given name verbatim'
89
+ c.switch [:u,:nonumber]
90
+
91
+ c.desc 'Include code from the given file as the slide body'
92
+ c.arg_name 'path to file'
93
+ c.flag [:s,:source]
94
+
95
+ c.desc 'Slide Type/Style'
96
+ c.arg_name 'valid showoff style/type'
97
+ c.default_value 'title'
98
+ c.flag [:t,:type,:style]
99
+
100
+ c.desc 'Slide dir (where to put a new slide file)'
101
+ c.arg_name 'dir'
102
+ c.flag [:d,:dir]
103
+
104
+ c.desc 'Slide name (name of the new slide file)'
105
+ c.arg_name 'basename'
106
+ c.flag [:n,:name]
107
+
108
+ c.action do |global_options,options,args|
109
+ title = args.join(" ")
110
+ ShowOffUtils.add_slide(:dir => options[:d],
111
+ :name => options[:n],
112
+ :title => title,
113
+ :number => !options[:u],
114
+ :code => options[:s],
115
+ :type => options[:t])
116
+ end
117
+ end
118
+
119
+ desc 'Generate static version of presentation'
120
+ arg_name 'name'
121
+ long_desc 'Creates a static, one page version of the presentation as {name}.html'
122
+ command [:static] do |c|
123
+ c.action do |global_options,options,args|
124
+ ShowOff.do_static(args[0])
125
+ end
126
+ end
127
+
128
+ pre do |global,command,options,args|
129
+ # Pre logic here
130
+ # Return true to proceed; false to abourt and not call the
131
+ # chosen command
132
+ true
133
+ end
134
+
135
+ post do |global,command,options,args|
136
+ # Post logic here
137
+ end
138
+
139
+ on_error do |exception|
140
+ # Error logic here
141
+ # return false to skip default error handling
142
+ true
143
+ end
144
+
145
+ exit GLI.run(ARGV)
@@ -0,0 +1,67 @@
1
+ require 'parslet'
2
+
3
+ # For parsing commandline slide content.
4
+ class CommandlineParser < Parslet::Parser
5
+
6
+ rule(:prompt) do
7
+ str('$') | str('#')
8
+ end
9
+
10
+ rule(:text) do
11
+ match['[:print:]'].repeat
12
+ end
13
+
14
+ rule(:singleline_input) do
15
+ (str("\\\n").absent? >> match['[:print:]']).repeat
16
+ end
17
+
18
+ rule(:input) do
19
+ multiline_input | singleline_input
20
+ end
21
+
22
+ rule(:multiline_input) do
23
+
24
+ # some command \
25
+ # continued \
26
+ # \
27
+ # and stop
28
+ ( singleline_input >> str('\\') >> newline ).repeat(1) >> singleline_input
29
+ end
30
+
31
+ rule(:command) do
32
+
33
+ # $ some command
34
+ # some output
35
+ ( prompt.as(:prompt) >> space? >> input.as(:input) >> output? ).as(:command)
36
+ end
37
+
38
+ rule(:output) do
39
+
40
+ # output
41
+ prompt.absent? >> text
42
+ end
43
+
44
+ rule(:output?) do
45
+
46
+ #
47
+ # some text
48
+ # some text
49
+ #
50
+ # some text
51
+ ( newline >> ( ( output >> newline ).repeat >> output.maybe ).as(:output) ).maybe
52
+ end
53
+
54
+ rule(:commands) do
55
+ command.repeat
56
+ end
57
+
58
+ rule(:newline) do
59
+ str("\n") | str("\r\n")
60
+ end
61
+
62
+ rule(:space?) do
63
+ match['[:space:]'].repeat
64
+ end
65
+
66
+ root(:commands)
67
+ end
data/lib/princely.rb ADDED
@@ -0,0 +1,84 @@
1
+ # PrinceXML Ruby interface.
2
+ # http://www.princexml.com
3
+ #
4
+ # Library by Subimage Interactive - http://www.subimage.com
5
+ #
6
+ #
7
+ # USAGE
8
+ # -----------------------------------------------------------------------------
9
+ # princely = Princely.new()
10
+ # html_string = render_to_string(:template => 'some_document')
11
+ # send_data(
12
+ # princely.pdf_from_string(html_string),
13
+ # :filename => 'some_document.pdf'
14
+ # :type => 'application/pdf'
15
+ # )
16
+ #
17
+ $:.unshift(File.dirname(__FILE__))
18
+
19
+ class Princely
20
+ VERSION = "1.0.0" unless const_defined?("VERSION")
21
+
22
+ attr_accessor :exe_path, :style_sheets, :log_file
23
+
24
+ # Initialize method
25
+ #
26
+ def initialize()
27
+ # Finds where the application lives, so we can call it.
28
+ @exe_path = `which prince`.chomp
29
+ raise "Cannot find prince command-line app in $PATH" if @exe_path.length == 0
30
+ @style_sheets = ''
31
+ @log_file = "/tmp/prince.log"
32
+ end
33
+
34
+ # Sets stylesheets...
35
+ # Can pass in multiple paths for css files.
36
+ #
37
+ def add_style_sheets(*sheets)
38
+ for sheet in sheets do
39
+ @style_sheets << " -s #{sheet} "
40
+ end
41
+ end
42
+
43
+ # Returns fully formed executable path with any command line switches
44
+ # we've set based on our variables.
45
+ #
46
+ def exe_path
47
+ # Add any standard cmd line arguments we need to pass
48
+ @exe_path << " --input=html --server --log=#{@log_file} "
49
+ @exe_path << @style_sheets
50
+ return @exe_path
51
+ end
52
+
53
+ # Makes a pdf from a passed in string.
54
+ #
55
+ # Returns PDF as a stream, so we can use send_data to shoot
56
+ # it down the pipe using Rails.
57
+ #
58
+ def pdf_from_string(string, output_file = '-')
59
+ path = self.exe_path()
60
+ # Don't spew errors to the standard out...and set up to take IO
61
+ # as input and output
62
+ path << ' --silent - -o -'
63
+
64
+ # Actually call the prince command, and pass the entire data stream back.
65
+ pdf = IO.popen(path, "w+")
66
+ pdf.puts(string)
67
+ pdf.close_write
68
+ result = pdf.gets(nil)
69
+ pdf.close_read
70
+ return result
71
+ end
72
+
73
+ def pdf_from_string_to_file(string, output_file)
74
+ path = self.exe_path()
75
+ # Don't spew errors to the standard out...and set up to take IO
76
+ # as input and output
77
+ path << " --silent - -o '#{output_file}' >> '#{@log_file}' 2>> '#{@log_file}'"
78
+
79
+ # Actually call the prince command, and pass the entire data stream back.
80
+ pdf = IO.popen(path, "w+")
81
+ pdf.puts(string)
82
+ pdf.close
83
+ end
84
+ end