html2img 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ //= require_tree .
2
+
3
+ $(function() {
4
+
5
+ // $(".html2img").each(function( index ) {
6
+ // console.log( index + ": " + $( this ).text() );
7
+ //$("[id^=html2img]").click(function() {
8
+
9
+ $("[class^=html2img-#download-#]").click(function() {
10
+ console.log("start")
11
+ var img_id = returnHtml2imgID($(this));
12
+ // console.log(cls);
13
+ // var img_id = "#" + id.split("-#")[2];
14
+
15
+ console.log(img_id);
16
+
17
+ html2canvas($(img_id), {
18
+ onrendered: function(canvas) {
19
+ //theCanvas = canvas;
20
+ // document.body.appendChild(canvas);
21
+
22
+ // Convert and download as image and downloads
23
+ Canvas2Image.saveAsPNG(canvas);
24
+ //$(this).replaceWith(canvas);
25
+ // $("#img-out").append(canvas);
26
+ // Clean up
27
+ //document.body.removeChild(canvas);
28
+ }
29
+ });
30
+ });
31
+
32
+ function returnHtml2imgID(el) {
33
+ var classList = el.attr('class').split(/\s+/);
34
+
35
+ for (i in classList) {
36
+ item = classList[i];
37
+ console.log(item);
38
+ var id = item.split("html2img-#download-#")[1];
39
+
40
+ if (id !== undefined) {
41
+ console.log(id);
42
+ //do something
43
+ return "#" + id;
44
+ }
45
+ }
46
+
47
+ // return array;
48
+ }
49
+ });
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "html2img"
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
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/html2img.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'html2img/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "html2img"
8
+ spec.version = Html2img::VERSION
9
+ spec.authors = ["edmothershaw"]
10
+ spec.email = ["ucabeam@ucl.ac.uk"]
11
+
12
+ spec.summary = %q{Allows the easy downloading of HTML elements.}
13
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = 'http://rubygems.org/gems/html2img'
15
+ spec.license = "MIT"
16
+
17
+ # # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = ""
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ end
@@ -0,0 +1,4 @@
1
+ module Html2img
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Html2img
2
+ VERSION = "0.0.2"
3
+ end
data/lib/html2img.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "html2img/version"
2
+ require "html2img/engine"
3
+
4
+ module Html2img
5
+
6
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html2img
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - edmothershaw
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - ucabeam@ucl.ac.uk
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - app/assets/javascripts/base64.js
54
+ - app/assets/javascripts/canvas2image.js
55
+ - app/assets/javascripts/html2canvas.js
56
+ - app/assets/javascripts/html2img.js
57
+ - bin/console
58
+ - bin/setup
59
+ - html2img.gemspec
60
+ - lib/html2img.rb
61
+ - lib/html2img/engine.rb
62
+ - lib/html2img/version.rb
63
+ homepage: http://rubygems.org/gems/html2img
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.6
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Allows the easy downloading of HTML elements.
87
+ test_files: []