[DRE-commits] [tdiary-contrib] 01/01: New upstream version 5.0.6

Youhei SASAKI uwabami-guest at moszumanska.debian.org
Tue Nov 14 09:51:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

uwabami-guest pushed a commit to annotated tag upstream/5.0.6
in repository tdiary-contrib.

commit 33d68aa72b16764147f0961ccc8fcba9e1575819
Author: Youhei SASAKI <uwabami at gfd-dennou.org>
Date:   Tue Nov 14 18:48:10 2017 +0900

    New upstream version 5.0.6
---
 .gitignore                    |  2 ++
 Gemfile.lock                  | 32 ++++++++++----------
 js/google_photos.js           | 12 +++++---
 lib/tdiary/contrib/version.rb |  2 +-
 plugin/google_photos.rb       | 19 ++++++++++--
 plugin/plantuml.rb            | 70 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 112 insertions(+), 25 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2dd0253
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+coverage
+pkg
diff --git a/Gemfile.lock b/Gemfile.lock
index 53416fe..d7fafaa 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,16 +1,16 @@
 PATH
   remote: .
   specs:
-    tdiary-contrib (5.0.4)
+    tdiary-contrib (5.0.6)
       ruby-pushbullet
       tdiary
 
 GEM
   remote: https://rubygems.org/
   specs:
-    addressable (2.5.1)
-      public_suffix (~> 2.0, >= 2.0.2)
-    coderay (1.1.1)
+    addressable (2.5.2)
+      public_suffix (>= 2.0.2, < 4.0)
+    coderay (1.1.2)
     concurrent-ruby (1.0.5)
     crack (0.4.3)
       safe_yaml (~> 1.0.0)
@@ -21,23 +21,22 @@ GEM
     emot (0.0.4)
       thor
     fastimage (2.1.0)
-    hashdiff (0.3.4)
+    hashdiff (0.3.6)
     hikidoc (0.1.0)
     http-cookie (1.0.3)
       domain_name (~> 0.5)
     json (2.1.0)
     mail (2.6.6)
       mime-types (>= 1.16, < 4)
-    method_source (0.8.2)
+    method_source (0.9.0)
     mime-types (2.99.3)
     netrc (0.11.0)
-    pry (0.10.4)
+    pry (0.11.1)
       coderay (~> 1.1.0)
-      method_source (~> 0.8.1)
-      slop (~> 3.4)
-    public_suffix (2.0.5)
+      method_source (~> 0.9.0)
+    public_suffix (3.0.0)
     rack (2.0.3)
-    rake (12.0.0)
+    rake (12.1.0)
     rest-client (1.8.0)
       http-cookie (>= 1.0.2, < 2.0)
       mime-types (>= 1.16, < 3.0)
@@ -59,16 +58,15 @@ GEM
       json
       rest-client (~> 1.8.0)
     safe_yaml (1.0.4)
-    simplecov (0.14.1)
+    simplecov (0.15.1)
       docile (~> 1.1.0)
       json (>= 1.8, < 3)
       simplecov-html (~> 0.10.0)
-    simplecov-html (0.10.1)
-    slop (3.6.0)
+    simplecov-html (0.10.2)
     sprockets (3.7.1)
       concurrent-ruby (~> 1.0)
       rack (> 1, < 3)
-    tdiary (5.0.4)
+    tdiary (5.0.6)
       bundler (~> 1.3)
       emot
       fastimage
@@ -78,7 +76,7 @@ GEM
       rake
       sprockets
       thor
-    thor (0.19.4)
+    thor (0.20.0)
     unf (0.1.4)
       unf_ext
     unf_ext (0.0.7.4)
@@ -100,4 +98,4 @@ DEPENDENCIES
   webmock
 
 BUNDLED WITH
-   1.14.6
+   1.16.0.pre.2
diff --git a/js/google_photos.js b/js/google_photos.js
index d3c0bc3..9a298c7 100644
--- a/js/google_photos.js
+++ b/js/google_photos.js
@@ -48,16 +48,20 @@ $(function() {
       .setDeveloperKey(developerKey)
       .setLocale('ja')
       .setCallback(pickerCallback)
+      .enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
       .build();
     picker.setVisible(true);
   }
 
   function pickerCallback(data) {
     if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) {
-      var doc = data[google.picker.Response.DOCUMENTS][0];
-      var image = doc.thumbnails[doc.thumbnails.length - 1];
-      var tag = $.makePluginTag("google_photos '" + image.url + "', '" + image.width + "', '" + image.height + "'");
-      $('#body').insertAtCaret(tag);
+      var tag = [];
+      for (var i = 0; i < data[google.picker.Response.DOCUMENTS].length; i++) {
+        var doc = data[google.picker.Response.DOCUMENTS][i];
+        var image = doc.thumbnails[doc.thumbnails.length - 1];
+        tag.push($.makePluginTag("google_photos '" + image.url + "', '" + image.width + "', '" + image.height + "'"));
+      }
+      $('#body').insertAtCaret(tag.join("\n") + "\n");
     }
   }
 });
diff --git a/lib/tdiary/contrib/version.rb b/lib/tdiary/contrib/version.rb
index a4ad1aa..de930a3 100644
--- a/lib/tdiary/contrib/version.rb
+++ b/lib/tdiary/contrib/version.rb
@@ -1,5 +1,5 @@
 module TDiary
   class Contrib
-    VERSION = "5.0.5"
+    VERSION = "5.0.6"
   end
 end
diff --git a/plugin/google_photos.rb b/plugin/google_photos.rb
index d1d6a2a..f42c464 100644
--- a/plugin/google_photos.rb
+++ b/plugin/google_photos.rb
@@ -5,15 +5,24 @@
 # Distributed under the GPL
 #
 
-def google_photos(src, width, height, alt="photo", place="photo")
+def google_photos(src, width, height, alt="photo", place="photo", scale=nil)
+	scale = scale || @conf['google_photos.scale'] || 100
+	width = width.to_i * (scale.to_f / 100)
+	height = height.to_i * (scale.to_f / 100)
 	%Q|<img title="#{alt}" width="#{width}" height="#{height}" alt="#{alt}" src="#{src}" class="#{place} google">|
 end
 
-def google_photos_left(src, width, height, alt="photo")
+def google_photos_left(src, width, height, alt="photo", scale=nil)
+	scale = scale || @conf['google_photos.scale'] || 100
+	width = width.to_i * (scale.to_f / 100)
+	height = height.to_i * (scale.to_f / 100)
 	google_photos(src, width, height, alt, 'left')
 end
 
-def google_photos_right(src, width, height, alt="photo")
+def google_photos_right(src, width, height, alt="photo", scale=nil)
+	scale = scale || @conf['google_photos.scale'] || 100
+	width = width.to_i * (scale.to_f / 100)
+	height = height.to_i * (scale.to_f / 100)
 	google_photos(src, width, height, alt, 'right')
 end
 
@@ -40,6 +49,8 @@ add_conf_proc('google_photos', 'Googleフォト') do
   if @mode == 'saveconf'
     @conf['google_photos.api_key'] = @cgi.params['google_photos.api_key'][0]
     @conf['google_photos.client_id'] = @cgi.params['google_photos.client_id'][0]
+    @conf['google_photos.scale'] = @cgi.params['google_photos.scale'][0]
+    @conf['google_photos.scale'] = 100 if @conf['google_photos.scale'].nil? || @conf['google_photos.scale'].empty?
   end
 
   r = <<-_HTML
@@ -63,5 +74,7 @@ add_conf_proc('google_photos', 'Googleフォト') do
 	<p><input type="text" name="google_photos.api_key" size="100" value="#{@conf['google_photos.api_key']}"></p>
 	<h3>認証用クライアントID</h3>
 	<p><input type="text" name="google_photos.client_id" size="100" value="#{@conf['google_photos.client_id']}"></p>
+	<h3>サムネイルからの縮小率 (単位%。数値1〜100)</h3>
+	<p><input type="text" name="google_photos.scale" size="100" value="#{@conf['google_photos.scale']}"></p>
 _HTML
 end
diff --git a/plugin/plantuml.rb b/plugin/plantuml.rb
new file mode 100644
index 0000000..b566e5d
--- /dev/null
+++ b/plugin/plantuml.rb
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+# create image by PlantUML http://plantuml.com/
+#
+# Copyright (c) tamoot <tamoot+tdiary at gmail.com>
+# Distributed under the GPL
+#
+
+require 'uri'
+require 'zlib'
+require 'digest/md5'
+
+module ::PlantUML
+   module Deflate
+
+      CHARS ||= ('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a + ['-', '_']
+
+      def self.compress(text)
+         compressed = Zlib::Deflate.deflate(text, Zlib::BEST_COMPRESSION)
+         compressed.chars.each_slice(3).map do |chars|
+            append3bytes(chars[0].ord, chars[1]&.ord.to_i, chars[2]&.ord.to_i)
+         end.join
+      end
+
+      private
+
+      def self.append3bytes(b1, b2, b3)
+         [
+            b1 >> 2,
+            ((b1 & 0x3) << 4) | (b2 >> 4),
+            ((b2 & 0xF) << 2) | (b3 >> 6),
+            b3 & 0x3F,
+         ].map { |c| CHARS[c & 0x3F] || '?' }.join
+      end
+   end
+
+end
+
+def plantuml(text)
+   html = %Q|<div class="plantuml">|
+
+   begin
+      uri = URI::parse( @conf['plantuml.server'] )
+      uri.path.gsub!(/\/+$/, "")
+      uri.path << '/png/' << PlantUML::Deflate::compress(text)
+      html << %Q|<img src=#{uri}></img>|
+   rescue
+      html << %Q|Error: #{$!.message}|
+   end
+
+   html << %Q|</div>|
+
+end
+
+add_conf_proc('plantuml_server', 'PlantUMLサーバ') do
+   if @mode == 'saveconf'
+      @conf['plantuml.server'] = @cgi.params['plantuml.server'][0]
+   end
+
+   r = <<-_HTML
+   <h3>Summary</h3>
+   <p>The image is generated by using specified PlantUML server.</p>
+   <h3>URL</h3>
+   <p>Please specify the PlantUML server URL (official site or your own PlantUML server)
+   <li> Official PlantUML server: http://www.plantuml.com/plantuml/</li>
+   <p><input type="text" name="plantuml.server" size="100" value="#{@conf['plantuml.server']}"></p>
+   _HTML
+
+   r
+end
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/tdiary-contrib.git



More information about the Pkg-ruby-extras-commits mailing list