diff --git a/lib/powerpoint.rb b/lib/powerpoint.rb index 71fb5f68..182fbfda 100644 --- a/lib/powerpoint.rb +++ b/lib/powerpoint.rb @@ -1,13 +1,23 @@ require "powerpoint/version" require 'powerpoint/util' require 'powerpoint/slide/intro' +require 'powerpoint/slide/extended_intro' +require 'powerpoint/slide/multiple_image' +require 'powerpoint/slide/comment' +require 'powerpoint/slide/gallery' +require 'powerpoint/slide/concept' +require 'powerpoint/slide/collage' +require 'powerpoint/slide/image' require 'powerpoint/slide/textual' require 'powerpoint/slide/pictorial' require 'powerpoint/slide/text_picture_split' require 'powerpoint/slide/picture_description' +require 'powerpoint/slide/dashboard_user' +require 'powerpoint/slide/dashboard' require 'powerpoint/compression' require 'powerpoint/presentation' + module Powerpoint ROOT_PATH = File.expand_path("../..", __FILE__) TEMPLATE_PATH = "#{ROOT_PATH}/template/" diff --git a/lib/powerpoint/presentation.rb b/lib/powerpoint/presentation.rb index c8a75d98..55ead7da 100644 --- a/lib/powerpoint/presentation.rb +++ b/lib/powerpoint/presentation.rb @@ -22,6 +22,16 @@ def add_intro(title, subtitile = nil) end end + def add_extended_intro(title, image_path, image_path_2,subtitle = nil,subtitle_2 = nil, coords = {}) + existing_intro_slide = @slides.select {|s| s.class == Powerpoint::Slide::ExtendedIntro}[0] + slide = Powerpoint::Slide::ExtendedIntro.new(presentation: self, title: title, subtitle: subtitle, image_path: image_path, image_path_2: image_path_2, subtitle_2: subtitle_2, coords: coords) + if existing_intro_slide + @slides[@slides.index(existing_intro_slide)] = slide + else + @slides.insert 0, slide + end + end + def add_textual_slide(title, content = []) @slides << Powerpoint::Slide::Textual.new(presentation: self, title: title, content: content) end @@ -38,6 +48,38 @@ def add_picture_description_slide(title, image_path, content = []) @slides << Powerpoint::Slide::DescriptionPic.new(presentation: self, title: title, image_path: image_path, content: content) end + def add_multiple_image_slide(title, subtitle = nil, page_number, logo, task_icon ,images) + @slides << Powerpoint::Slide::MultipleImage.new(presentation: self, title: title, subtitle: subtitle, page_number: page_number, task_icon: task_icon, logo: logo, images: images) + end + + def add_comment_slide(title, subtitle = nil, user, page_number, logo, task_icon ,comments) + @slides << Powerpoint::Slide::Comment.new(presentation: self, title: title, subtitle: subtitle, user: user, page_number: page_number, task_icon: task_icon, logo: logo, comments: comments) + end + + def add_gallery_slide(title, subtitle = nil, question, page_number, logo, task_icon ,images) + @slides << Powerpoint::Slide::Gallery.new(presentation: self, title: title, subtitle: subtitle, question: question, page_number: page_number, task_icon: task_icon, logo: logo, images: images) + end + + def add_concept_slide(title, subtitle = nil, page_number, logo, task_icon, image_information ,images, legend) + @slides << Powerpoint::Slide::Concept.new(presentation: self, title: title, subtitle: subtitle, page_number: page_number, logo: logo, task_icon: task_icon, image_information: image_information, images: images, legend: legend) + end + + def add_collage_slide(title, subtitle = nil, page_number, logo, task_icon, image_information ,images) + @slides << Powerpoint::Slide::Collage.new(presentation: self, title: title, subtitle: subtitle, page_number: page_number, logo: logo, task_icon: task_icon, image_information: image_information, images: images) + end + + def add_image_slide(title, subtitle = nil,images) + @slides << Powerpoint::Slide::Image.new(presentation: self, title: title, subtitle: subtitle) + end + + def add_dashboard_slide(title, subtitle = nil, page_number, graph_1_title, graph_1_subtitle, graph_2_title, image_1, image_2, image_3, image_4, logo, data) + @slides << Powerpoint::Slide::Dashboard.new(presentation: self, title: title, subtitle: subtitle, page_number: page_number, graph_1_title: graph_1_title, graph_1_subtitle: graph_1_subtitle, graph_2_title: graph_2_title, image_path: image_1, image_path_2: image_2, image_path_3: image_3, image_path_4: image_4, logo: logo, data: data) + end + + def add_dashboard_user_slide(title, subtitle = nil, page_number, logo, images) + @slides << Powerpoint::Slide::DashboardUser.new(presentation: self, title: title, subtitle: subtitle,page_number: page_number, logo: logo, images: images) + end + def save(path) Dir.mktmpdir do |dir| extract_path = "#{dir}/extract_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}" @@ -70,7 +112,7 @@ def save(path) end def file_types - slides.map {|slide| slide.file_type if slide.respond_to? :file_type }.compact.uniq + end end end diff --git a/lib/powerpoint/slide/collage.rb b/lib/powerpoint/slide/collage.rb new file mode 100644 index 00000000..13dc8e44 --- /dev/null +++ b/lib/powerpoint/slide/collage.rb @@ -0,0 +1,47 @@ +require 'zip/filesystem' +require 'fileutils' +require 'fastimage' +require 'erb' + +module Powerpoint + module Slide + class Collage + include Powerpoint::Util + + attr_reader :title, :subtitle,:page_number,:logo, :task_icon, :image_information, :images + + def initialize(options={}) + require_arguments [:title, :subtitle,:page_number,:logo, :task_icon, :image_information, :images], options + options.each {|k, v| instance_variable_set("@#{k}", v)} + @images = images + @image_y_scale = image_information[1] + @image_x_scale = image_information[0] + @image_x_offset = image_information[2] + @image_y_offset = image_information[3] + end + + def save(extract_path, index) + @images.each do |image| + copy_media(extract_path, image) + end + + copy_media(extract_path, logo) + copy_media(extract_path, task_icon) + + save_rel_xml(extract_path, index) + save_slide_xml(extract_path, index) + end + + + def save_rel_xml(extract_path, index) + render_view('collage_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index) + end + private :save_rel_xml + + def save_slide_xml(extract_path, index) + render_view('collage.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml") + end + private :save_slide_xml + end + end +end \ No newline at end of file diff --git a/lib/powerpoint/slide/comment.rb b/lib/powerpoint/slide/comment.rb new file mode 100644 index 00000000..6cda5602 --- /dev/null +++ b/lib/powerpoint/slide/comment.rb @@ -0,0 +1,39 @@ +require 'zip/filesystem' +require 'fileutils' +require 'fastimage' +require 'erb' + +module Powerpoint + module Slide + class Comment + include Powerpoint::Util + + attr_reader :title, :subtitle, :user, :page_number, :logo, :task_icon, :comments + + def initialize(options={}) + require_arguments [:title, :subtitle, :user, :page_number, :logo, :task_icon, :comments], options + options.each {|k, v| instance_variable_set("@#{k}", v)} + + end + + def save(extract_path, index) + + copy_media(extract_path, logo) + copy_media(extract_path, task_icon) + + save_rel_xml(extract_path, index) + save_slide_xml(extract_path, index) + end + + def save_rel_xml(extract_path, index) + render_view('comment_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index) + end + private :save_rel_xml + + def save_slide_xml(extract_path, index) + render_view('comment.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml") + end + private :save_slide_xml + end + end +end \ No newline at end of file diff --git a/lib/powerpoint/slide/concept.rb b/lib/powerpoint/slide/concept.rb new file mode 100644 index 00000000..8327b2b5 --- /dev/null +++ b/lib/powerpoint/slide/concept.rb @@ -0,0 +1,48 @@ +require 'zip/filesystem' +require 'fileutils' +require 'fastimage' +require 'erb' + +module Powerpoint + module Slide + class Concept + include Powerpoint::Util + + attr_reader :title, :subtitle,:page_number,:logo, :task_icon, :image_information, :images, :legend + + def initialize(options={}) + require_arguments [:title, :subtitle, :page_number, :logo, :task_icon, :image_information, :images, :legend], options + options.each {|k, v| instance_variable_set("@#{k}", v)} + @legend = legend + @images = images + @image_y_scale = image_information[1] + @image_x_scale = image_information[0] + @image_x_offset = image_information[2] + @image_y_offset = image_information[3] + end + + def save(extract_path, index) + @images.each do |image| + copy_media(extract_path, image) + end + + copy_media(extract_path, logo) + copy_media(extract_path, task_icon) + + save_rel_xml(extract_path, index) + save_slide_xml(extract_path, index) + end + + + def save_rel_xml(extract_path, index) + render_view('concept_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index) + end + private :save_rel_xml + + def save_slide_xml(extract_path, index) + render_view('concept.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml") + end + private :save_slide_xml + end + end +end \ No newline at end of file diff --git a/lib/powerpoint/slide/dashboard.rb b/lib/powerpoint/slide/dashboard.rb new file mode 100644 index 00000000..beef65bb --- /dev/null +++ b/lib/powerpoint/slide/dashboard.rb @@ -0,0 +1,45 @@ +require 'zip/filesystem' +require 'fileutils' +require 'fastimage' +require 'erb' + +module Powerpoint + module Slide + class Dashboard + include Powerpoint::Util + + attr_reader :title, :subtitle,:page_number, :graph_1_title, :graph_1_subtitle, :graph_2_title, :image_path, :image_path_2,:image_path_3,:image_path_4, :image_name, :logo, :data + + def initialize(options={}) + require_arguments [:title, :subtitle,:page_number, :graph_1_title, :graph_1_subtitle, :graph_2_title, :image_path, :image_path_2,:image_path_3, :image_path_4, :logo, :data], options + options.each {|k, v| instance_variable_set("@#{k}", v)} + @data = data + @image_name = File.basename(image_path) + @image_name_2 = File.basename(image_path_2) + @image_name_3 = File.basename(image_path_3) + @image_name_4 = File.basename(image_path_4) + @logo_name = File.basename(logo) + end + + def save(extract_path, index) + copy_media(extract_path, image_path) + copy_media(extract_path, image_path_2) + copy_media(extract_path, image_path_3) + copy_media(extract_path, image_path_4) + copy_media(extract_path, logo) + save_rel_xml(extract_path, index) + save_slide_xml(extract_path, index) + end + + def save_rel_xml(extract_path, index) + render_view('dashboard_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index) + end + private :save_rel_xml + + def save_slide_xml(extract_path, index) + render_view('dashboard.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml") + end + private :save_slide_xml + end + end +end \ No newline at end of file diff --git a/lib/powerpoint/slide/dashboard_user.rb b/lib/powerpoint/slide/dashboard_user.rb new file mode 100644 index 00000000..e483196c --- /dev/null +++ b/lib/powerpoint/slide/dashboard_user.rb @@ -0,0 +1,40 @@ +require 'zip/filesystem' +require 'fileutils' +require 'fastimage' +require 'erb' + +module Powerpoint + module Slide + class DashboardUser + include Powerpoint::Util + + attr_reader :title, :subtitle,:page_number,:logo, :images + + def initialize(options={}) + require_arguments [:title, :subtitle,:page_number,:logo, :images], options + options.each {|k, v| instance_variable_set("@#{k}", v)} + @images = images + @logo_name = File.basename(logo) + end + + def save(extract_path, index) + @images.each do |image| + copy_media(extract_path, image[1]) + end + copy_media(extract_path, logo) + save_rel_xml(extract_path, index) + save_slide_xml(extract_path, index) + end + + def save_rel_xml(extract_path, index) + render_view('dashboard_user_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index) + end + private :save_rel_xml + + def save_slide_xml(extract_path, index) + render_view('dashboard_user.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml") + end + private :save_slide_xml + end + end +end \ No newline at end of file diff --git a/lib/powerpoint/slide/extended_intro.rb b/lib/powerpoint/slide/extended_intro.rb new file mode 100644 index 00000000..80e5d2d1 --- /dev/null +++ b/lib/powerpoint/slide/extended_intro.rb @@ -0,0 +1,38 @@ +require 'zip/filesystem' +require 'fileutils' +require 'fastimage' +require 'erb' + +module Powerpoint + module Slide + class ExtendedIntro + include Powerpoint::Util + + attr_reader :title, :subtitle, :subtitle_2, :coords, :image_path, :image_path_2, :image_name + + def initialize(options={}) + require_arguments [:title, :subtitle, :image_path, :image_path_2, :subtitle_2], options + options.each {|k, v| instance_variable_set("@#{k}", v)} + @image_name = File.basename(@image_path) + @image_name_2 = File.basename(@image_path_2) + end + + def save(extract_path, index) + copy_media(extract_path, @image_path) + copy_media(extract_path, @image_path_2) + save_rel_xml(extract_path, index) + save_slide_xml(extract_path, index) + end + + def save_rel_xml(extract_path, index) + render_view('extended_intro_slide_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index) + end + private :save_rel_xml + + def save_slide_xml(extract_path, index) + render_view('extended_intro_slide.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml") + end + private :save_slide_xml + end + end +end \ No newline at end of file diff --git a/lib/powerpoint/slide/gallery.rb b/lib/powerpoint/slide/gallery.rb new file mode 100644 index 00000000..71446559 --- /dev/null +++ b/lib/powerpoint/slide/gallery.rb @@ -0,0 +1,42 @@ +require 'zip/filesystem' +require 'fileutils' +require 'fastimage' +require 'erb' + +module Powerpoint + module Slide + class Gallery + include Powerpoint::Util + + attr_reader :title, :subtitle, :question, :page_number, :logo, :task_icon, :images + + def initialize(options={}) + require_arguments [:title, :subtitle, :question, :page_number, :logo, :task_icon, :images], options + options.each {|k, v| instance_variable_set("@#{k}", v)} + @images = images + end + + def save(extract_path, index) + @images.each do |image| + copy_media(extract_path, image[0]) + end + + copy_media(extract_path, logo) + copy_media(extract_path, task_icon) + + save_rel_xml(extract_path, index) + save_slide_xml(extract_path, index) + end + + def save_rel_xml(extract_path, index) + render_view('gallery_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index) + end + private :save_rel_xml + + def save_slide_xml(extract_path, index) + render_view('gallery.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml") + end + private :save_slide_xml + end + end +end \ No newline at end of file diff --git a/lib/powerpoint/slide/image.rb b/lib/powerpoint/slide/image.rb new file mode 100644 index 00000000..1ba3f557 --- /dev/null +++ b/lib/powerpoint/slide/image.rb @@ -0,0 +1,54 @@ +require 'zip/filesystem' +require 'fileutils' +require 'fastimage' +require 'erb' + +module Powerpoint + module Slide + class Image + include Powerpoint::Util + + attr_reader :title, :subtitle, :images + + def initialize(options={}) + require_arguments [:title, :subtitle, :images], options + options.each {|k, v| instance_variable_set("@#{k}", v)} + @coords = default_coords unless @coords.any? + images + end + + def save(extract_path, index) + copy_media(extract_path, @image_path) + save_rel_xml(extract_path, index) + save_slide_xml(extract_path, index) + end + + def file_type + File.extname(image_name).gsub('.', '') + end + + def default_coords + slide_width = pixle_to_pt(720) + default_width = pixle_to_pt(550) + + return {} unless dimensions = FastImage.size(image_path) + image_width, image_height = dimensions.map {|d| pixle_to_pt(d)} + new_width = default_width < image_width ? default_width : image_width + ratio = new_width / image_width.to_f + new_height = (image_height.to_f * ratio).round + {x: (slide_width / 2) - (new_width/2), y: pixle_to_pt(120), cx: new_width, cy: new_height} + end + private :default_coords + + def save_rel_xml(extract_path, index) + render_view('image_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index) + end + private :save_rel_xml + + def save_slide_xml(extract_path, index) + render_view('image.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml") + end + private :save_slide_xml + end + end +end \ No newline at end of file diff --git a/lib/powerpoint/slide/multiple_image.rb b/lib/powerpoint/slide/multiple_image.rb new file mode 100644 index 00000000..1cd7350c --- /dev/null +++ b/lib/powerpoint/slide/multiple_image.rb @@ -0,0 +1,42 @@ +require 'zip/filesystem' +require 'fileutils' +require 'fastimage' +require 'erb' + +module Powerpoint + module Slide + class MultipleImage + include Powerpoint::Util + + attr_reader :title, :subtitle, :page_number, :logo, :task_icon, :images + + def initialize(options={}) + require_arguments [:title, :subtitle, :page_number, :logo, :task_icon, :images], options + options.each {|k, v| instance_variable_set("@#{k}", v)} + @images = images + end + + def save(extract_path, index) + @images.each do |image| + copy_media(extract_path, image[0]) + end + + copy_media(extract_path, logo) + copy_media(extract_path, task_icon) + + save_rel_xml(extract_path, index) + save_slide_xml(extract_path, index) + end + + def save_rel_xml(extract_path, index) + render_view('multiple_image_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index) + end + private :save_rel_xml + + def save_slide_xml(extract_path, index) + render_view('multiple_image.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml") + end + private :save_slide_xml + end + end +end \ No newline at end of file diff --git a/lib/powerpoint/util.rb b/lib/powerpoint/util.rb index fbee597e..884ca044 100644 --- a/lib/powerpoint/util.rb +++ b/lib/powerpoint/util.rb @@ -11,15 +11,15 @@ def render_view(template_name, path, variables = {}) b = merge_variables(binding, variables) data = renderer.result(b) - File.open(path, 'w') { |f| f << data } + File.open(path, 'w') { |f| f << data.squish!.gsub('> <', '><') } end def read_template(filename) File.read("#{Powerpoint::VIEW_PATH}/#{filename}") end - def require_arguments(required_argements, argements) - raise ArgumentError unless required_argements.all? {|required_key| argements.keys.include? required_key} + def require_arguments(required_arguements, arguements) + raise ArgumentError unless required_arguements.all? {|required_key| arguements.keys.include? required_key} end def copy_media(extract_path, image_path) diff --git a/lib/powerpoint/views/collage.xml.erb b/lib/powerpoint/views/collage.xml.erb new file mode 100644 index 00000000..ede1502a --- /dev/null +++ b/lib/powerpoint/views/collage.xml.erb @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= title %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= subtitle %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= page_number %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% images.each_with_index do |image, index| %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% end %> + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/powerpoint/views/collage_rel.xml.erb b/lib/powerpoint/views/collage_rel.xml.erb new file mode 100644 index 00000000..741e4c9b --- /dev/null +++ b/lib/powerpoint/views/collage_rel.xml.erb @@ -0,0 +1,9 @@ + + + + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + <% images.each_with_index do |image, index| %> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + <% end %> + \ No newline at end of file diff --git a/lib/powerpoint/views/comment.xml.erb b/lib/powerpoint/views/comment.xml.erb new file mode 100644 index 00000000..ece02274 --- /dev/null +++ b/lib/powerpoint/views/comment.xml.erb @@ -0,0 +1,257 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= title %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= subtitle %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= page_number %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= user %> + + + + + <% y_coords = 621510 %> + <% x_coords = 145000 %> + <% comments.each_with_index do |comment, index| %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= comment[0] %> + + + + + + + + + + + <%= comment[1] %> + + + + + <% end %> + + + + + + + + + + + \ No newline at end of file diff --git a/lib/powerpoint/views/comment_rel.xml.erb b/lib/powerpoint/views/comment_rel.xml.erb new file mode 100644 index 00000000..b1b7a2f9 --- /dev/null +++ b/lib/powerpoint/views/comment_rel.xml.erb @@ -0,0 +1,6 @@ + + + + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + \ No newline at end of file diff --git a/lib/powerpoint/views/concept.xml.erb b/lib/powerpoint/views/concept.xml.erb new file mode 100644 index 00000000..8a2364dc --- /dev/null +++ b/lib/powerpoint/views/concept.xml.erb @@ -0,0 +1,271 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= title %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= subtitle %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= page_number %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% images.each_with_index do |image, index| %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% end %> + <% x_pos_legend = 1000000 %> + <% legend.each_with_index do |graph_key, index| %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= graph_key['label'] %> + + + + + + <% end %> + + + + + + + + + + + \ No newline at end of file diff --git a/lib/powerpoint/views/concept_rel.xml.erb b/lib/powerpoint/views/concept_rel.xml.erb new file mode 100644 index 00000000..741e4c9b --- /dev/null +++ b/lib/powerpoint/views/concept_rel.xml.erb @@ -0,0 +1,9 @@ + + + + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + <% images.each_with_index do |image, index| %> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + <% end %> + \ No newline at end of file diff --git a/lib/powerpoint/views/content_type.xml.erb b/lib/powerpoint/views/content_type.xml.erb index 2798d86d..5ef19eda 100644 --- a/lib/powerpoint/views/content_type.xml.erb +++ b/lib/powerpoint/views/content_type.xml.erb @@ -2,9 +2,10 @@ - <% file_types.each do |type| %> - - <% end %> + + + + <% slides.each_with_index do |slide, index| %> @@ -12,7 +13,7 @@ <% end %> - + diff --git a/lib/powerpoint/views/dashboard.xml.erb b/lib/powerpoint/views/dashboard.xml.erb new file mode 100644 index 00000000..d61f4191 --- /dev/null +++ b/lib/powerpoint/views/dashboard.xml.erb @@ -0,0 +1,936 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= title %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= subtitle %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= page_number %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= graph_1_title %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= graph_1_subtitle %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Male + + + + + + + <%= @data[:genders]['m'] %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Female + + + + + + + + <%= @data[:genders]['f'] %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Other + + + + + + + <%= @data[:genders][nil] %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= graph_2_title %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Total posts in market + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Time spent in market + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Image posts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Video posts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Text posts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= @data[:total_posts] %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= @data[:log_time] %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= @data[:post_types][:image] %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= @data[:post_types][:video] %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= @data[:post_types][:text] %> + + + + + + + + + + + + + + + diff --git a/lib/powerpoint/views/dashboard_rel.xml.erb b/lib/powerpoint/views/dashboard_rel.xml.erb new file mode 100644 index 00000000..c7583ca0 --- /dev/null +++ b/lib/powerpoint/views/dashboard_rel.xml.erb @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/lib/powerpoint/views/dashboard_user.xml.erb b/lib/powerpoint/views/dashboard_user.xml.erb new file mode 100644 index 00000000..56f37e98 --- /dev/null +++ b/lib/powerpoint/views/dashboard_user.xml.erb @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= title %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= subtitle %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= page_number %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% y_coords = 2664490 %> + <% x_coords = 3849630 %> + <% images.each_with_index do |image, index| %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= image[0] %> + + + + + <% end %> + + + + + + + + + + + \ No newline at end of file diff --git a/lib/powerpoint/views/dashboard_user_rel.xml.erb b/lib/powerpoint/views/dashboard_user_rel.xml.erb new file mode 100644 index 00000000..3045322e --- /dev/null +++ b/lib/powerpoint/views/dashboard_user_rel.xml.erb @@ -0,0 +1,8 @@ + + + + + <% images.each_with_index do |image, index| %> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + <% end %> + \ No newline at end of file diff --git a/lib/powerpoint/views/extended_intro_slide.xml.erb b/lib/powerpoint/views/extended_intro_slide.xml.erb new file mode 100644 index 00000000..28ab9e07 --- /dev/null +++ b/lib/powerpoint/views/extended_intro_slide.xml.erb @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= title %> + + + + + <% if subtitle.present? %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= subtitle %> + + + + + <% end %> + <% if subtitle_2.present? %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= subtitle_2 %> + + + + + <% end %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= Date.today %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/powerpoint/views/extended_intro_slide_rel.xml.erb b/lib/powerpoint/views/extended_intro_slide_rel.xml.erb new file mode 100644 index 00000000..81da0412 --- /dev/null +++ b/lib/powerpoint/views/extended_intro_slide_rel.xml.erb @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/lib/powerpoint/views/gallery.xml.erb b/lib/powerpoint/views/gallery.xml.erb new file mode 100644 index 00000000..6540ef32 --- /dev/null +++ b/lib/powerpoint/views/gallery.xml.erb @@ -0,0 +1,340 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= title %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= subtitle %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= page_number %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= question %> + + + + + <% y_coords = 2664490 %> + <% x_coords = 2392098 %> + <% images.each_with_index do |image, index| %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% if image[1].present? %> + + + + + + + + + <%= image[1] %> + + + + + <% end %> + <% if image[2].present? %> + <% image[2].each do |questions| %> + + + + + + + + + <%= questions[0] %> + + + + + <% questions[1].each do |answer| %> + + + + + + + + + <%= answer %> + + + + + <% end %> + <% end %> + <% end %> + + + <% end %> + + + + + + + + + + + \ No newline at end of file diff --git a/lib/powerpoint/views/gallery_rel.xml.erb b/lib/powerpoint/views/gallery_rel.xml.erb new file mode 100644 index 00000000..d64f0607 --- /dev/null +++ b/lib/powerpoint/views/gallery_rel.xml.erb @@ -0,0 +1,9 @@ + + + + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + <% images.each_with_index do |image, index| %> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + <% end %> + \ No newline at end of file diff --git a/lib/powerpoint/views/image.xml.erb b/lib/powerpoint/views/image.xml.erb new file mode 100644 index 00000000..c3dad1bd --- /dev/null +++ b/lib/powerpoint/views/image.xml.erb @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + <% images.each_with_index do |image, index| %> + + + + + + + + + + + + + + + + + + <%= image['title'] %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% if coords.any? %> + + + + + + + + + + <% else %> + + <% end %> + + <% end %> + + + + + + + + + + + \ No newline at end of file diff --git a/lib/powerpoint/views/image_rel.xml.erb b/lib/powerpoint/views/image_rel.xml.erb new file mode 100644 index 00000000..608e80ea --- /dev/null +++ b/lib/powerpoint/views/image_rel.xml.erb @@ -0,0 +1,7 @@ + + + + <% images.each_with_index do |image, index| %> + + <% end %> + \ No newline at end of file diff --git a/lib/powerpoint/views/multiple_image.xml.erb b/lib/powerpoint/views/multiple_image.xml.erb new file mode 100644 index 00000000..6c8a9b35 --- /dev/null +++ b/lib/powerpoint/views/multiple_image.xml.erb @@ -0,0 +1,317 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= title %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= subtitle %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%= page_number %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% y_coords = 2664490 %> + <% x_coords = 2392098 %> + <% images.each_with_index do |image, index| %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% if image[2].present? %> + + + + + + + + + <%= image[2] %> + + + + <% end %> + <% if image[1].present? %> + + + + + + + + + <%= image[1] %> + + + <% end %> + <% if image[4].present? %> + <% image[4].each do |comment| %> + + + + + + + + + <%= comment[0] %> + + + + + + + + + + + <%= comment[1] %> + + + <% end %> + <% end %> + + + <% end %> + + + + + + + + + + + \ No newline at end of file diff --git a/lib/powerpoint/views/multiple_image_rel.xml.erb b/lib/powerpoint/views/multiple_image_rel.xml.erb new file mode 100644 index 00000000..d64f0607 --- /dev/null +++ b/lib/powerpoint/views/multiple_image_rel.xml.erb @@ -0,0 +1,9 @@ + + + + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + <% images.each_with_index do |image, index| %> + " Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/> + <% end %> + \ No newline at end of file diff --git a/lib/powerpoint/views/presentation.xml.erb b/lib/powerpoint/views/presentation.xml.erb index b3f3be07..a6404265 100644 --- a/lib/powerpoint/views/presentation.xml.erb +++ b/lib/powerpoint/views/presentation.xml.erb @@ -8,14 +8,14 @@ <% end %> - + - - + + @@ -24,8 +24,8 @@ - - + + @@ -34,8 +34,8 @@ - - + + @@ -44,8 +44,8 @@ - - + + @@ -54,8 +54,8 @@ - - + + @@ -64,8 +64,8 @@ - - + + @@ -74,8 +74,8 @@ - - + + @@ -84,8 +84,8 @@ - - + + @@ -94,8 +94,8 @@ - - + + diff --git a/lib/powerpoint/views/presentation.xml.rel.erb b/lib/powerpoint/views/presentation.xml.rel.erb index e970d24e..00075bb5 100644 --- a/lib/powerpoint/views/presentation.xml.rel.erb +++ b/lib/powerpoint/views/presentation.xml.rel.erb @@ -3,10 +3,9 @@ - + <% slides.each_with_index do |slide, index| %> - <% id = 5 + (index+1) %> - + <% end %> \ No newline at end of file diff --git a/samples/pptx/sample.pptx b/samples/pptx/sample.pptx index 1221afc4..721625b0 100644 Binary files a/samples/pptx/sample.pptx and b/samples/pptx/sample.pptx differ diff --git a/spec/extended_test_spec.rb b/spec/extended_test_spec.rb new file mode 100644 index 00000000..bc8b67f3 --- /dev/null +++ b/spec/extended_test_spec.rb @@ -0,0 +1,13 @@ +require 'powerpoint' + +describe 'Powerpoint parsing a sample PPTX file' do + before(:all) do + @deck = Powerpoint::Presentation.new + @deck.add_extended_intro 'Bicycle Of the Mind','samples/images/sample_png.png', 'created by Steve Jobs', 'created by bob' + @deck.save 'samples/pptx/sample.pptx' # Examine the PPTX file + end + + it 'Create a PPTX file successfully.' do + #@deck.should_not be_nil + end +end \ No newline at end of file diff --git a/spec/ranking_spec.rb b/spec/ranking_spec.rb new file mode 100644 index 00000000..9fbf7852 --- /dev/null +++ b/spec/ranking_spec.rb @@ -0,0 +1,13 @@ +require 'powerpoint' + +describe 'Powerpoint parsing a sample PPTX file' do + before(:all) do + @deck = Powerpoint::Presentation.new + @deck.add_ranking_slide 'Bicycle Of the Mind','samples/images/sample_png.png', nil + @deck.save 'samples/pptx/sample.pptx' # Examine the PPTX file + end + + it 'Create a PPTX file successfully.' do + #@deck.should_not be_nil + end +end \ No newline at end of file diff --git a/template/ppt/slideLayouts/slideLayout1.xml b/template/ppt/slideLayouts/slideLayout1.xml index 0a295ae2..45fc766e 100755 --- a/template/ppt/slideLayouts/slideLayout1.xml +++ b/template/ppt/slideLayouts/slideLayout1.xml @@ -27,14 +27,19 @@ - - + + - + + + + + + Click to edit Master title style @@ -55,12 +60,12 @@ - - + + - + diff --git a/template/ppt/slideMasters/_rels/slideMaster1.xml.rels b/template/ppt/slideMasters/_rels/slideMaster1.xml.rels index b7afc216..9f1511b6 100755 --- a/template/ppt/slideMasters/_rels/slideMaster1.xml.rels +++ b/template/ppt/slideMasters/_rels/slideMaster1.xml.rels @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/template/ppt/theme/theme2.xml b/template/ppt/theme/theme2.xml new file mode 100644 index 00000000..8bc29fb0 --- /dev/null +++ b/template/ppt/theme/theme2.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file