ruby_slides 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/example.pptx +0 -0
- data/example/ruby.png +0 -0
- data/lib/ruby_slides/compression.rb +25 -0
- data/lib/ruby_slides/presentation.rb +105 -0
- data/lib/ruby_slides/slide/chart.rb +41 -0
- data/lib/ruby_slides/slide/introduction.rb +36 -0
- data/lib/ruby_slides/slide/pictorial.rb +54 -0
- data/lib/ruby_slides/slide/picture_description.rb +63 -0
- data/lib/ruby_slides/slide/table.rb +32 -0
- data/lib/ruby_slides/slide/text_picture_split.rb +59 -0
- data/lib/ruby_slides/slide/textual.rb +32 -0
- data/lib/ruby_slides/util.rb +39 -0
- data/lib/ruby_slides/version.rb +3 -0
- data/lib/ruby_slides/views/app.xml.erb +51 -0
- data/lib/ruby_slides/views/chart_ele.xml.erb +196 -0
- data/lib/ruby_slides/views/chart_rel.xml.erb +5 -0
- data/lib/ruby_slides/views/chart_slide.xml.erb +118 -0
- data/lib/ruby_slides/views/content_type.xml.erb +33 -0
- data/lib/ruby_slides/views/introduction_rel.xml.erb +4 -0
- data/lib/ruby_slides/views/introduction_slide.xml.erb +74 -0
- data/lib/ruby_slides/views/pictorial_rel.xml.erb +5 -0
- data/lib/ruby_slides/views/pictorial_slide.xml.erb +87 -0
- data/lib/ruby_slides/views/picture_description_rels.xml.erb +5 -0
- data/lib/ruby_slides/views/picture_description_slide.xml.erb +115 -0
- data/lib/ruby_slides/views/presentation.xml.erb +124 -0
- data/lib/ruby_slides/views/presentation.xml.rel.erb +12 -0
- data/lib/ruby_slides/views/table_rel.xml.erb +4 -0
- data/lib/ruby_slides/views/table_slide.xml.erb +137 -0
- data/lib/ruby_slides/views/text_picture_split_rel.xml.erb +5 -0
- data/lib/ruby_slides/views/text_picture_split_slide.xml.erb +114 -0
- data/lib/ruby_slides/views/textual_rel.xml.erb +4 -0
- data/lib/ruby_slides/views/textual_slide.xml.erb +78 -0
- data/lib/ruby_slides.rb +17 -0
- data/ruby_slides.gemspec +30 -0
- data/template/_rels/.rels +6 -0
- data/template/docProps/core.xml +7 -0
- data/template/ppt/_rels/.keep +0 -0
- data/template/ppt/charts/.keep +0 -0
- data/template/ppt/media/.keep +0 -0
- data/template/ppt/presProps.xml +14 -0
- data/template/ppt/slideLayouts/_rels/slideLayout1.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout10.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout11.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout2.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout3.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout4.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout5.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout6.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout7.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout8.xml.rels +2 -0
- data/template/ppt/slideLayouts/_rels/slideLayout9.xml.rels +2 -0
- data/template/ppt/slideLayouts/slideLayout1.xml +237 -0
- data/template/ppt/slideLayouts/slideLayout10.xml +2 -0
- data/template/ppt/slideLayouts/slideLayout11.xml +2 -0
- data/template/ppt/slideLayouts/slideLayout2.xml +165 -0
- data/template/ppt/slideLayouts/slideLayout3.xml +2 -0
- data/template/ppt/slideLayouts/slideLayout4.xml +2 -0
- data/template/ppt/slideLayouts/slideLayout5.xml +2 -0
- data/template/ppt/slideLayouts/slideLayout6.xml +2 -0
- data/template/ppt/slideLayouts/slideLayout7.xml +2 -0
- data/template/ppt/slideLayouts/slideLayout8.xml +2 -0
- data/template/ppt/slideLayouts/slideLayout9.xml +2 -0
- data/template/ppt/slideMasters/_rels/slideMaster1.xml.rels +2 -0
- data/template/ppt/slideMasters/slideMaster1.xml +505 -0
- data/template/ppt/slides/_rels/.keep +0 -0
- data/template/ppt/tableStyles.xml +2 -0
- data/template/ppt/theme/theme1.xml +2 -0
- data/template/ppt/viewProps.xml +32 -0
- metadata +193 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e578fb2796af5721b2dac0f714008dc2931251a6
|
4
|
+
data.tar.gz: 724e2a43e2290b97be58b812f56dd39d0d11f658
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f179ad0ea0e90b7b17e90012316a34f059ed9bbf2037382229ff3a1bc0775451dcc4deed0cdcbbc0d784e49017be45fe10dc6cba140c6337bce693185bc7498e
|
7
|
+
data.tar.gz: edaa7a60d5bdaecc708a884bb3d3d2f6bafa1ef20bfc1ac45ddd7f10408c31d1b1420e6901e2933c76cef62aadf6cadff70abe42366512294753e367c5ed4ea8
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at mail@danielsousa.io. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Daniel Sousa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# RubySlides
|
2
|
+
|
3
|
+
Create Powerpoint presentations in Ruby with elements like slides, text, images, tables and charts.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ruby_slides'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ruby_slides
|
20
|
+
|
21
|
+
Optionally use the latest code using:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'ruby_slides', git: "https://github.com/danielsousaio/ruby_slides.git"
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/danielsousaio/ruby_slides. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
43
|
+
|
44
|
+
## Code of Conduct
|
45
|
+
|
46
|
+
Everyone interacting in the RubySlides project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ruby_slides/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruby_slides"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
Binary file
|
data/example/ruby.png
ADDED
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RubySlides
|
2
|
+
def self.decompress_pptx(in_path, out_path)
|
3
|
+
Zip::File.open(in_path) do |zip_file|
|
4
|
+
zip_file.each do |f|
|
5
|
+
f_path = File.join(out_path, f.name)
|
6
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
7
|
+
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.compress_pptx(in_path, out_path)
|
13
|
+
Zip::File.open(out_path, Zip::File::CREATE) do |zip_file|
|
14
|
+
Dir.glob("#{in_path}/**/*", ::File::FNM_DOTMATCH).each do |path|
|
15
|
+
zip_path = path.gsub("#{in_path}/","")
|
16
|
+
next if zip_path == "." || zip_path == ".." || zip_path.match(/DS_Store/)
|
17
|
+
begin
|
18
|
+
zip_file.add(zip_path, path)
|
19
|
+
rescue Zip::ZipEntryExistsError
|
20
|
+
raise "#{out_path} already exists!"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'zip/filesystem'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
module RubySlides
|
6
|
+
class Presentation
|
7
|
+
include RubySlides::Util
|
8
|
+
|
9
|
+
attr_reader :slides
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@slides = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def introduction_slide(title, subtitle)
|
16
|
+
@slides << RubySlides::Slide::Introduction.new(title: title,
|
17
|
+
subtitle: subtitle)
|
18
|
+
end
|
19
|
+
|
20
|
+
def textual_slide(title, content = [])
|
21
|
+
@slides << RubySlides::Slide::Textual.new(presentation: self,
|
22
|
+
title: title,
|
23
|
+
content: content)
|
24
|
+
end
|
25
|
+
|
26
|
+
def pictorial_slide(title, image_path, coords = {})
|
27
|
+
@slides << RubySlides::Slide::Pictorial.new(presentation: self,
|
28
|
+
title: title,
|
29
|
+
image_path: image_path,
|
30
|
+
coords: coords)
|
31
|
+
end
|
32
|
+
|
33
|
+
def text_picture_slide(title, image_path, content = [])
|
34
|
+
@slides << RubySlides::Slide::TextPicSplit.new(presentation: self,
|
35
|
+
title: title,
|
36
|
+
image_path: image_path,
|
37
|
+
content: content)
|
38
|
+
end
|
39
|
+
|
40
|
+
def picture_description_slide(title, image_path, content = [])
|
41
|
+
@slides << RubySlides::Slide::DescriptionPic.new(presentation: self,
|
42
|
+
title: title,
|
43
|
+
image_path: image_path,
|
44
|
+
content: content)
|
45
|
+
end
|
46
|
+
|
47
|
+
def table_slide(title, content = [])
|
48
|
+
@slides << RubySlides::Slide::Table.new(presentation: self,
|
49
|
+
title: title,
|
50
|
+
content: content)
|
51
|
+
end
|
52
|
+
|
53
|
+
def chart_slide(title, series = [{}])
|
54
|
+
@slides << RubySlides::Slide::Chart.new(presentation: self,
|
55
|
+
title: title,
|
56
|
+
series: series)
|
57
|
+
end
|
58
|
+
|
59
|
+
def save(path)
|
60
|
+
Dir.mktmpdir do |dir|
|
61
|
+
extract_path = "#{dir}/extract_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}"
|
62
|
+
|
63
|
+
# Copy template to temp path
|
64
|
+
FileUtils.copy_entry(TEMPLATE_PATH, extract_path)
|
65
|
+
|
66
|
+
# Remove keep files
|
67
|
+
Dir.glob("#{extract_path}/**/.keep").each do |keep_file|
|
68
|
+
FileUtils.rm_rf(keep_file)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Render/save generic stuff
|
72
|
+
render_view('content_type.xml.erb',
|
73
|
+
"#{extract_path}/[Content_Types].xml")
|
74
|
+
render_view('presentation.xml.rel.erb',
|
75
|
+
"#{extract_path}/ppt/_rels/presentation.xml.rels")
|
76
|
+
render_view('presentation.xml.erb',
|
77
|
+
"#{extract_path}/ppt/presentation.xml")
|
78
|
+
render_view('app.xml.erb',
|
79
|
+
"#{extract_path}/docProps/app.xml")
|
80
|
+
|
81
|
+
# Save slides
|
82
|
+
slides.each_with_index do |slide, index|
|
83
|
+
slide.save(extract_path, index + 1)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Create .pptx file
|
87
|
+
File.delete(path) if File.exist?(path)
|
88
|
+
RubySlides.compress_pptx(extract_path, path)
|
89
|
+
end
|
90
|
+
path
|
91
|
+
end
|
92
|
+
|
93
|
+
def file_types
|
94
|
+
slides.map {|slide|
|
95
|
+
slide.file_type if slide.respond_to? :file_type
|
96
|
+
}.compact.uniq
|
97
|
+
end
|
98
|
+
|
99
|
+
def charts
|
100
|
+
slides.map {|slide|
|
101
|
+
slide.class == RubySlides::Slide::Chart
|
102
|
+
}.count
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module RubySlides
|
5
|
+
module Slide
|
6
|
+
class Chart
|
7
|
+
include RubySlides::Util
|
8
|
+
|
9
|
+
attr_reader :title, :series
|
10
|
+
|
11
|
+
def initialize(options={})
|
12
|
+
require_arguments [:title, :series], options
|
13
|
+
options.each {|k, v| instance_variable_set("@#{k}", v)}
|
14
|
+
end
|
15
|
+
|
16
|
+
def save(extract_path, index)
|
17
|
+
save_rel_xml(extract_path, index)
|
18
|
+
save_slide_xml(extract_path, index)
|
19
|
+
save_chart_xml(extract_path, index)
|
20
|
+
end
|
21
|
+
|
22
|
+
def save_rel_xml(extract_path, index)
|
23
|
+
render_view('chart_rel.xml.erb',
|
24
|
+
"#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels",
|
25
|
+
index: index)
|
26
|
+
end
|
27
|
+
private :save_rel_xml
|
28
|
+
|
29
|
+
def save_slide_xml(extract_path, index)
|
30
|
+
render_view('chart_slide.xml.erb',
|
31
|
+
"#{extract_path}/ppt/slides/slide#{index}.xml")
|
32
|
+
end
|
33
|
+
private :save_slide_xml
|
34
|
+
|
35
|
+
def save_chart_xml(extract_path, index)
|
36
|
+
render_view('chart_ele.xml.erb',
|
37
|
+
"#{extract_path}/ppt/charts/chart#{index}.xml")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module RubySlides
|
5
|
+
module Slide
|
6
|
+
class Introduction
|
7
|
+
include RubySlides::Util
|
8
|
+
|
9
|
+
attr_reader :title, :subtitle
|
10
|
+
|
11
|
+
def initialize(options={})
|
12
|
+
require_arguments [:title, :subtitle], options
|
13
|
+
options.each {|k, v| instance_variable_set("@#{k}", v)}
|
14
|
+
end
|
15
|
+
|
16
|
+
def save(extract_path, index)
|
17
|
+
save_rel_xml(extract_path, index)
|
18
|
+
save_slide_xml(extract_path, index)
|
19
|
+
end
|
20
|
+
|
21
|
+
def file_type
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def save_rel_xml(extract_path, index)
|
26
|
+
render_view('introduction_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: 1)
|
27
|
+
end
|
28
|
+
private :save_rel_xml
|
29
|
+
|
30
|
+
def save_slide_xml(extract_path, index)
|
31
|
+
render_view('introduction_slide.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
|
32
|
+
end
|
33
|
+
private :save_slide_xml
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'zip/filesystem'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'fastimage'
|
4
|
+
require 'erb'
|
5
|
+
|
6
|
+
module RubySlides
|
7
|
+
module Slide
|
8
|
+
class Pictorial
|
9
|
+
include RubySlides::Util
|
10
|
+
|
11
|
+
attr_reader :image_name, :title, :coords, :image_path
|
12
|
+
|
13
|
+
def initialize(options={})
|
14
|
+
require_arguments [:presentation, :title, :image_path], options
|
15
|
+
options.each {|k, v| instance_variable_set("@#{k}", v)}
|
16
|
+
@coords = default_coords unless @coords.any?
|
17
|
+
@image_name = File.basename(@image_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def save(extract_path, index)
|
21
|
+
copy_media(extract_path, @image_path)
|
22
|
+
save_rel_xml(extract_path, index)
|
23
|
+
save_slide_xml(extract_path, index)
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_type
|
27
|
+
File.extname(image_name).gsub('.', '')
|
28
|
+
end
|
29
|
+
|
30
|
+
def default_coords
|
31
|
+
slide_width = pixel_to_pt(720)
|
32
|
+
default_width = pixel_to_pt(550)
|
33
|
+
|
34
|
+
return {} unless dimensions = FastImage.size(image_path)
|
35
|
+
image_width, image_height = dimensions.map {|d| pixel_to_pt(d)}
|
36
|
+
new_width = default_width < image_width ? default_width : image_width
|
37
|
+
ratio = new_width / image_width.to_f
|
38
|
+
new_height = (image_height.to_f * ratio).round
|
39
|
+
{x: (slide_width / 2) - (new_width/2), y: pixel_to_pt(120), cx: new_width, cy: new_height}
|
40
|
+
end
|
41
|
+
private :default_coords
|
42
|
+
|
43
|
+
def save_rel_xml(extract_path, index)
|
44
|
+
render_view('pictorial_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: 2)
|
45
|
+
end
|
46
|
+
private :save_rel_xml
|
47
|
+
|
48
|
+
def save_slide_xml(extract_path, index)
|
49
|
+
render_view('pictorial_slide.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
|
50
|
+
end
|
51
|
+
private :save_slide_xml
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'zip/filesystem'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'fastimage'
|
4
|
+
require 'erb'
|
5
|
+
|
6
|
+
module RubySlides
|
7
|
+
module Slide
|
8
|
+
class DescriptionPic
|
9
|
+
include RubySlides::Util
|
10
|
+
|
11
|
+
attr_reader :title, :content, :image_name, :image_path, :coords
|
12
|
+
|
13
|
+
def initialize(options={})
|
14
|
+
require_arguments [:presentation, :title, :image_path, :content], options
|
15
|
+
options.each {|k, v| instance_variable_set("@#{k}", v)}
|
16
|
+
@coords = default_coords
|
17
|
+
@image_name = File.basename(@image_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def save(extract_path, index)
|
21
|
+
copy_media(extract_path, @image_path)
|
22
|
+
save_rel_xml(extract_path, index)
|
23
|
+
save_slide_xml(extract_path, index)
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_type
|
27
|
+
File.extname(image_name).gsub('.', '')
|
28
|
+
end
|
29
|
+
|
30
|
+
def default_coords
|
31
|
+
slide_width = pixel_to_pt(720)
|
32
|
+
default_width = pixel_to_pt(550)
|
33
|
+
default_height = pixel_to_pt(300)
|
34
|
+
|
35
|
+
return {} unless dimensions = FastImage.size(image_path)
|
36
|
+
image_width, image_height = dimensions.map {|d| pixel_to_pt(d)}
|
37
|
+
|
38
|
+
capped_width = [default_width, image_width].min
|
39
|
+
w_ratio = capped_width / image_width.to_f
|
40
|
+
|
41
|
+
capped_height = [default_height, image_height].min
|
42
|
+
h_ratio = capped_height / image_height.to_f
|
43
|
+
|
44
|
+
ratio = [w_ratio, h_ratio].min
|
45
|
+
|
46
|
+
new_width = (image_width.to_f * ratio).round
|
47
|
+
new_height = (image_height.to_f * ratio).round
|
48
|
+
{x: (slide_width / 2) - (new_width/2), y: pixel_to_pt(60), cx: new_width, cy: new_height}
|
49
|
+
end
|
50
|
+
private :default_coords
|
51
|
+
|
52
|
+
def save_rel_xml(extract_path, index)
|
53
|
+
render_view('picture_description_rels.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: 2)
|
54
|
+
end
|
55
|
+
private :save_rel_xml
|
56
|
+
|
57
|
+
def save_slide_xml(extract_path, index)
|
58
|
+
render_view('picture_description_slide.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
|
59
|
+
end
|
60
|
+
private :save_slide_xml
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module RubySlides
|
5
|
+
module Slide
|
6
|
+
class Table
|
7
|
+
include RubySlides::Util
|
8
|
+
|
9
|
+
attr_reader :title, :content
|
10
|
+
|
11
|
+
def initialize(options={})
|
12
|
+
require_arguments [:title, :content], options
|
13
|
+
options.each {|k, v| instance_variable_set("@#{k}", v)}
|
14
|
+
end
|
15
|
+
|
16
|
+
def save(extract_path, index)
|
17
|
+
save_rel_xml(extract_path, index)
|
18
|
+
save_slide_xml(extract_path, index)
|
19
|
+
end
|
20
|
+
|
21
|
+
def save_rel_xml(extract_path, index)
|
22
|
+
render_view('table_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: 2)
|
23
|
+
end
|
24
|
+
private :save_rel_xml
|
25
|
+
|
26
|
+
def save_slide_xml(extract_path, index)
|
27
|
+
render_view('table_slide.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
|
28
|
+
end
|
29
|
+
private :save_slide_xml
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'zip/filesystem'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'fastimage'
|
4
|
+
require 'erb'
|
5
|
+
|
6
|
+
module RubySlides
|
7
|
+
module Slide
|
8
|
+
class TextPicSplit
|
9
|
+
include RubySlides::Util
|
10
|
+
|
11
|
+
attr_reader :title, :content, :image_name, :image_path, :coords
|
12
|
+
|
13
|
+
def initialize(options={})
|
14
|
+
require_arguments [:presentation, :title, :image_path, :content], options
|
15
|
+
options.each {|k, v| instance_variable_set("@#{k}", v)}
|
16
|
+
@coords = default_coords
|
17
|
+
@image_name = File.basename(@image_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def save(extract_path, index)
|
21
|
+
copy_media(extract_path, @image_path)
|
22
|
+
save_rel_xml(extract_path, index)
|
23
|
+
save_slide_xml(extract_path, index)
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_type
|
27
|
+
File.extname(image_name).gsub('.', '')
|
28
|
+
end
|
29
|
+
|
30
|
+
def default_coords
|
31
|
+
start_x = pixel_to_pt(360)
|
32
|
+
default_width = pixel_to_pt(300)
|
33
|
+
|
34
|
+
return {} unless dimensions = FastImage.size(image_path)
|
35
|
+
image_width, image_height = dimensions.map {|d| pixel_to_pt(d)}
|
36
|
+
new_width = default_width < image_width ? default_width : image_width
|
37
|
+
ratio = new_width / image_width.to_f
|
38
|
+
new_height = (image_height.to_f * ratio).round
|
39
|
+
{x: start_x, y: pixel_to_pt(120), cx: new_width, cy: new_height}
|
40
|
+
end
|
41
|
+
private :default_coords
|
42
|
+
|
43
|
+
def save_rel_xml(extract_path, index)
|
44
|
+
render_view('text_picture_split_rel.xml.erb',
|
45
|
+
"#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels",
|
46
|
+
index: 2)
|
47
|
+
end
|
48
|
+
private :save_rel_xml
|
49
|
+
|
50
|
+
def save_slide_xml(extract_path, index)
|
51
|
+
render_view('text_picture_split_slide.xml.erb',
|
52
|
+
"#{extract_path}/ppt/slides/slide#{index}.xml")
|
53
|
+
end
|
54
|
+
private :save_slide_xml
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module RubySlides
|
5
|
+
module Slide
|
6
|
+
class Textual
|
7
|
+
include RubySlides::Util
|
8
|
+
|
9
|
+
attr_reader :title, :content
|
10
|
+
|
11
|
+
def initialize(options={})
|
12
|
+
require_arguments [:title, :content], options
|
13
|
+
options.each {|k, v| instance_variable_set("@#{k}", v)}
|
14
|
+
end
|
15
|
+
|
16
|
+
def save(extract_path, index)
|
17
|
+
save_rel_xml(extract_path, index)
|
18
|
+
save_slide_xml(extract_path, index)
|
19
|
+
end
|
20
|
+
|
21
|
+
def save_rel_xml(extract_path, index)
|
22
|
+
render_view('textual_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: 2)
|
23
|
+
end
|
24
|
+
private :save_rel_xml
|
25
|
+
|
26
|
+
def save_slide_xml(extract_path, index)
|
27
|
+
render_view('textual_slide.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
|
28
|
+
end
|
29
|
+
private :save_slide_xml
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|