Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions lib/rabbit/command/rabbit-slide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ def merge_config_yaml

def generate_directory
create_directory(base_directory)
create_directory(File.join(base_directory, "pdf")) if @data.author_conf.markup_language == :pdf
end

def generate_template
Expand All @@ -671,12 +672,13 @@ def generate_template

def generate_dot_gitignore
create_file(".gitignore") do |dot_gitignore|
dot_gitignore.puts(<<-EOD)
.DS_Store
/.tmp/
/pkg/
/pdf/
EOD
lines = [
".DS_Store",
"/.tmp/",
"/pkg/",
]
lines << "/pdf/" unless @data.author_conf.markup_language == :pdf
dot_gitignore.puts(lines.join("\n"))
end
end

Expand Down Expand Up @@ -705,6 +707,7 @@ def generate_readme

def readme_content
markup_language = @data.markup_language
markup_language = :markdown if markup_language == :pdf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Let's add --readme-markup-language instead of reusing --markup-language. (We can use --markup-language value as the default value of --readme-markup-language.)

generator = Rabbit::SourceGenerator.find(markup_language)
Comment on lines +710 to 711
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Currently, this generator is nil and causes an error when using :pdf.


content = ""
Expand Down Expand Up @@ -764,6 +767,13 @@ def generate_rakefile
end

def generate_slide
if @data.author_conf.markup_language == :pdf
create_file(slide_path) do |slide|
slide.puts("Replace me.")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This generates a broken PDF, but I can't think of a good way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding --pdf option and copy the PDF path here?

end
return
end

source = slide_source
return if source.nil?
create_file(slide_path) do |slide|
Expand All @@ -772,7 +782,12 @@ def generate_slide
end

def slide_path
"#{@data.slide_conf.base_name}.#{slide_source_extension}"
case @data.author_conf.markup_language
when :pdf
File.join("pdf", "#{@data.slide_conf.id}-#{@data.slide_conf.base_name}.pdf")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: It would be better to unify this with the following, but I can't think of a good way to do it.

def pdf_base_path
"#{@slide.id}-#{@slide.base_name}.pdf"
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add Rabbit::SlideConfiuration#pdf_base_name?

else
"#{@data.slide_conf.base_name}.#{slide_source_extension}"
end
end

def slide_source_extension
Expand All @@ -796,6 +811,8 @@ def readme_extension
"hiki"
when :markdown
"md"
when :pdf
"md"
else
"rd"
end
Expand Down
4 changes: 4 additions & 0 deletions lib/rabbit/task/slide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ def define_gem_validate_task

def define_pdf_task
file pdf_path => [options_path, *(spec.files - [pdf_path])] do
if @slide.author.markup_language == :pdf
puts "Skipped pdf task because markup_language is PDF."
next
end
Comment on lines 147 to +151
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: We could also stop the define itself, but then we would have to fix the dependent tasks too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work?

diff --git a/lib/rabbit/task/slide.rb b/lib/rabbit/task/slide.rb
index 2e320532..69b0cac3 100644
--- a/lib/rabbit/task/slide.rb
+++ b/lib/rabbit/task/slide.rb
@@ -144,14 +144,19 @@ module Rabbit
       end
 
       def define_pdf_task
-        file pdf_path => [options_path, *(spec.files - [pdf_path])] do
-          mkdir_p(@pdf_dir)
-          rabbit("--print",
-                 "--output-filename", pdf_path)
-        end
+        if @slide.author.markup_language == :pdf
+          # Does nothing. Not list in "rake -T" but "rake pdf" is accepted..
+          task :pdf
+        else
+          file pdf_path => [options_path, *(spec.files - [pdf_path])] do
+            mkdir_p(@pdf_dir)
+            rabbit("--print",
+                   "--output-filename", pdf_path)
+          end
 
-        desc(_("Generate PDF: %{pdf_path}") % {:pdf_path => pdf_path})
-        task :pdf => pdf_path
+          desc(_("Generate PDF: %{pdf_path}") % {:pdf_path => pdf_path})
+          task :pdf => pdf_path
+        end
       end
 
       def define_publish_task

mkdir_p(@pdf_dir)
rabbit("--print",
"--output-filename", pdf_path)
Expand Down