[DRE-commits] [tdiary-contrib] 01/04: New upstream version 5.0.4
Youhei SASAKI
uwabami-guest at moszumanska.debian.org
Sun May 14 12:02:15 UTC 2017
This is an automated email from the git hooks/post-receive script.
uwabami-guest pushed a commit to branch master
in repository tdiary-contrib.
commit 11ca0abd24e1709b4b13bfdfe87f18e8f1127e18
Author: Youhei SASAKI <uwabami at gfd-dennou.org>
Date: Sun May 14 20:17:36 2017 +0900
New upstream version 5.0.4
---
.gitignore | 2 -
.travis.yml | 4 +-
Gemfile.lock | 50 +++++---
js/picasa.js | 268 ------------------------------------------
lib/tdiary/contrib/version.rb | 2 +-
plugin/flickr.rb | 2 +-
plugin/google_analytics.rb | 36 +++++-
plugin/ogp.rb | 41 +++++--
plugin/picasa.rb | 34 ------
plugin/playstore.rb | 2 +-
spec/flicker_spec.rb | 2 +-
11 files changed, 104 insertions(+), 339 deletions(-)
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 2dd0253..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-coverage
-pkg
diff --git a/.travis.yml b/.travis.yml
index 9092acc..e062b2b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,9 +2,9 @@ language: ruby
cache: bundler
rvm:
- - 2.1
- 2.2
- - 2.3.0
+ - 2.3.3
+ - 2.4.0
- ruby-head
before_install:
diff --git a/Gemfile.lock b/Gemfile.lock
index e7fcd05..501e124 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,25 +1,33 @@
PATH
remote: .
specs:
- tdiary-contrib (5.0.1)
+ tdiary-contrib (5.0.3)
ruby-pushbullet
tdiary
GEM
remote: https://rubygems.org/
specs:
- addressable (2.4.0)
+ addressable (2.5.0)
+ public_suffix (~> 2.0, >= 2.0.2)
coderay (1.1.1)
+ concurrent-ruby (1.0.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
- diff-lcs (1.2.5)
+ diff-lcs (1.3)
docile (1.1.5)
- domain_name (0.5.20160826)
+ domain_name (0.5.20170223)
unf (>= 0.0.5, < 1.0.0)
- hashdiff (0.3.0)
- http-cookie (1.0.2)
+ emot (0.0.4)
+ thor
+ fastimage (2.1.0)
+ hashdiff (0.3.2)
+ hikidoc (0.1.0)
+ http-cookie (1.0.3)
domain_name (~> 0.5)
- json (2.0.2)
+ json (2.0.3)
+ mail (2.6.4)
+ mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (2.99.3)
netrc (0.11.0)
@@ -27,7 +35,9 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
- rake (11.2.2)
+ public_suffix (2.0.5)
+ rack (2.0.1)
+ rake (12.0.0)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
@@ -36,7 +46,7 @@ GEM
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
- rspec-core (3.5.3)
+ rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
@@ -49,20 +59,30 @@ GEM
json
rest-client (~> 1.8.0)
safe_yaml (1.0.4)
- simplecov (0.12.0)
+ simplecov (0.14.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
- tdiary (5.0.1)
+ sprockets (3.7.1)
+ concurrent-ruby (~> 1.0)
+ rack (> 1, < 3)
+ tdiary (5.0.3)
bundler (~> 1.3)
- thor (~> 0.18)
- thor (0.19.1)
+ emot
+ fastimage
+ hikidoc
+ mail
+ rack
+ rake
+ sprockets
+ thor
+ thor (0.19.4)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
- webmock (2.1.0)
+ webmock (2.3.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
@@ -80,4 +100,4 @@ DEPENDENCIES
webmock
BUNDLED WITH
- 1.13.1
+ 1.14.3
diff --git a/js/picasa.js b/js/picasa.js
deleted file mode 100644
index a212584..0000000
--- a/js/picasa.js
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- picasa.js: javascript for picasa.rb plugin of tDiary
-
- Copyright (C) 2011 by hb <smallstyle at gmail.com>
- You can redistribute it and/or modify it under GPL2.
- */
-$(function () {
- var CanvasLoadingImage = function (rgb) {
- this.canvas = null;
- this.ctx = null;
- this.width = 200;
- this.height = 32;
- this.rgb = rgb || '0, 0, 0';
- this.initialize();
- }
-
- CanvasLoadingImage.prototype = {
- initialize: function () {
- this.canvas = $('<canvas>', {
- text: 'loading...'
- }).attr({
- 'width': this.width,
- 'height': this.height
- });
- if (this.canvas.get(0).getContext) {
- this.ctx = this.canvas.get(0).getContext('2d');
- }
- },
-
- draw: function (idx) {
- var ctx = this.ctx;
- ctx.clearRect(0, 0, this.width, this.height);
- for (i = 0; i < 10; i++) {
- ctx.fillStyle = i > idx ? 'rgba(' + this.rgb + ', 0.25)' : 'rgb(' + this.rgb + ')';
- ctx.fillRect(i * (this.width / 10), 0, (this.width / 10) - 4, this.height);
- }
- return idx < 10 ? idx + 1 : 0;
- },
-
- start: function () {
- var self = this;
- var idx = 0;
- this.timer = setInterval(function () {
- idx = self.draw(idx);
- }, 100)
- },
-
- stop: function () {
- clearInterval(this.timer);
- }
- }
-
- var PicasaService = function (userId, imgMax) {
- this.userId = userId;
- this.imgMax = imgMax || 400;
- this.has_more_photos = false;
- this.has_more_albums = false;
- this.recently_uploaded_photo_start_index = 1;
- this.album_start_index = 1;
- };
-
- PicasaService.prototype = {
- setRecentlyUploadedPhotoStartIndex: function(index) {
- this.recently_uploaded_photo_start_index = index;
- },
-
- setAlbumStartIndex: function(index) {
- this.album_start_index = 1;
- },
-
- hasMorePhotos: function () {
- return this.has_more_photos;
- },
-
- hasMoreAlbums: function() {
- return this.has_more_albums;
- },
-
- getAlbums: function (fn) {
- var timerId = this.setErrorHandler();
- var self = this;
- $.ajax({
- url: '//picasaweb.google.com/data/feed/api/user/' + this.userId,
- data: 'alt=json-in-script&max-results=25&thumbsize=128c&start-index=' + this.album_start_index,
- dataType: 'jsonp',
- success: function (data) {
- clearTimeout(timerId);
- self.album_start_index += 25;
- if (self.album_start_index < data.feed.openSearch$totalResults.$t) {
- self.has_more_albums = true;
- } else {
- self.has_more_albums = false;
- }
- fn(data.feed.entry);
- }
- });
- },
-
- getPhotos: function (albumId, fn) {
- var timerId = this.setErrorHandler();
- $.ajax({
- url: '//picasaweb.google.com/data/feed/api/user/' + this.userId + '/albumid/' + albumId,
- data: 'alt=json-in-script&imgmax=' + this.imgMax + '&thumbsize=200',
- dataType: 'jsonp',
- success: function (data) {
- clearTimeout(timerId);
- fn(data.feed.entry);
- }
- });
- },
-
- getPhotosRecentlyUploaded: function (fn) {
- var timerId = this.setErrorHandler();
- var self = this;
- $.ajax({
- url: '//picasaweb.google.com/data/feed/api/user/' + this.userId,
- data: 'alt=json-in-script&imgmax=' + this.imgMax + '&thumbsize=200&kind=photo&max-results=25&start-index=' + this.recently_uploaded_photo_start_index,
- dataType: 'jsonp',
- success: function (data) {
- clearTimeout(timerId);
- self.recently_uploaded_photo_start_index += 25;
- if (self.recently_uploaded_photo_start_index < data.feed.openSearch$totalResults.$t) {
- self.has_more_photos = true;
- } else {
- self.has_more_photos = false;
- }
- fn(data.feed.entry);
- }
- });
- },
-
- setErrorHandler: function () {
- var timerId = setTimeout(function () {
- clearTimeout(timerId);
- $('#plugin_picasa canvas').hide();
- $('#plugin_picasa').append(
- $('<span>', {
- text: 'Picasa Web Serviceの呼び出しに失敗しました'
- }).css('color', 'red'));
- }, 10000);
- return timerId;
- }
- };
-
- $('<input>')
- .attr({
- id: 'plugin_picasa_recent',
- type: 'button',
- value: 'Picasaから写真を取得する'
- })
- .css({
- 'margin-left': '5px'
- })
- .appendTo('#plugin_picasa');
-
- var showPhoto = function(photo) {
- $('<img>')
- .click(function () {
- $('#body').insertAtCaret($.makePluginTag('picasa', [photo.content.src, $.trim(photo.summary.$t)]));
- })
- .attr({
- src: photo.media$group.media$thumbnail[0].url,
- title: $.trim(photo.summary.$t),
- alt: $.trim(photo.summary.$t)
- })
- .css({
- 'cursor': 'pointer',
- 'margin': '5px',
- 'border': 'solid 1px #aaa'
- })
- .appendTo('#photos');
- };
-
- var showAlbum = function (album) {
- $('<li>').attr('title', album.title.$t + 'の写真一覧を表示する').css({
- 'cursor': 'pointer',
- 'list-style': 'none',
- 'float': 'left',
- 'width': '128px',
- 'height': '128px',
- 'background-image': 'url(' + album.media$group.media$thumbnail[0].url + ')',
- 'margin': '5px',
- 'border': 'solid 1px #aaaaaa',
- 'overflow': 'hidden'
- }).click(function () {
- $('h3.plugin_picasa span')
- .css('cursor', 'pointer')
- .attr('title', 'アルバム一覧を表示する')
- .unbind('click')
- .click(function () {
- $('h3.plugin_picasa span.title').remove();
- $('.photo').remove();
- $('.album').show();
- });
- $('<span>', {
- text: ' > ' + album.title.$t
- }).addClass('title').appendTo('h3.plugin_picasa');
- $('<div>').css({
- 'overflow': 'auto',
- 'height': '300px'
- }).attr('id', 'photos').addClass('photo').appendTo('#plugin_picasa');
- $('.album').hide();
- $(loading.canvas).show();
- loading.start();
- service.getPhotos(album.gphoto$id.$t, function (photos) {
- $(loading.canvas).hide();
- loading.stop();
- $.each(photos, function (j, photo) {
- showPhoto(photo);
- });
- });
- }).append(
- $('<span>', {
- text: album.title.$t
- }).css({
- 'display': 'block',
- 'text-align': 'center',
- 'color': '#fff',
- 'background-color': 'rgba(0, 0, 0, 0.5)'
- })).appendTo('#albums');
- };
-
- var service = new PicasaService($tDiary.plugin.picasa.userId, $tDiary.plugin.picasa.imgMax);
- var loading = new CanvasLoadingImage();
-
- var showAlbums = function(){
- service.setAlbumStartIndex(1);
- $('h3.plugin_picasa span.title').remove();
- $('#albums').remove();
- $('.photo').remove();
- $('<ul>').css({
- 'overflow': 'auto',
- 'height': '300px'
- }).attr('id', 'albums').addClass('album')
- .scroll(function(){
- if (($(this).height() + $(this).scrollTop()) > ($(this).get(0).scrollHeight - 250)) {
- if (!service.active && service.hasMoreAlbums()) {
- service.active = true;
- service.getAlbums(function(next_albums) {
- service.active = false;
- $.each(next_albums, function(m, next_album) {
- showAlbum(next_album);
- });
- });
- }
- }
- })
- .appendTo('#plugin_picasa');
-
- $(loading.canvas).show();
- loading.start();
- service.getAlbums(function (albums) {
- $(loading.canvas).hide();
- loading.stop();
- $.each(albums, function(l, album) {
- showAlbum(album)
- });
- });
- }
-
- $('#plugin_picasa_recent').click(function(){
- $('#plugin_picasa')
- .css('height', '300px')
- .empty();
- $(loading.canvas).appendTo($('#plugin_picasa'));
- showAlbums();
- });
-});
diff --git a/lib/tdiary/contrib/version.rb b/lib/tdiary/contrib/version.rb
index 1ebb831..471de05 100644
--- a/lib/tdiary/contrib/version.rb
+++ b/lib/tdiary/contrib/version.rb
@@ -1,5 +1,5 @@
module TDiary
class Contrib
- VERSION = "5.0.2"
+ VERSION = "5.0.4"
end
end
diff --git a/plugin/flickr.rb b/plugin/flickr.rb
index 8cc1576..03cbe16 100644
--- a/plugin/flickr.rb
+++ b/plugin/flickr.rb
@@ -43,7 +43,7 @@ def flickr(photo_id, size = nil, place = 'flickr')
return '[ERROR] flickr.rb: failed to get photo.'
end
- %Q|<a href="#{photo[:page]}" class="flickr"><img title="#{photo[:title]}" alt="#{photo[:title]}" src="#{photo[:src]}" class="#{place} photo"></a>|
+ %Q|<a href="#{photo[:page]}" class="flickr"><img title="#{photo[:title]}" alt="#{photo[:title]}" src="#{photo[:src]}" class="#{place} photo" height="#{photo[:height]}" width="#{photo[:width]}"></a>|
end
def flickr_left(photo_id, size = nil)
diff --git a/plugin/google_analytics.rb b/plugin/google_analytics.rb
index 02ef66c..c065b6f 100644
--- a/plugin/google_analytics.rb
+++ b/plugin/google_analytics.rb
@@ -29,10 +29,44 @@ end
add_conf_proc( 'google_analytics', 'Google Analytics' ) do
if @mode == 'saveconf' then
@conf['google_analytics.profile'] = @cgi.params['google_analytics.profile'][0]
+ @conf['google_analytics.amp.profile'] = @cgi.params['google_analytics.amp.profile'][0]
end
- <<-HTML
+ r = <<-HTML
<h3>Google Analytics Profile</h3>
<p>set your Profile ID (NNNNN-N)</p>
<p><input name="google_analytics.profile" value="#{h @conf['google_analytics.profile']}"></p>
HTML
+ if defined? AMP
+ r << <<-HTML
+ <h3>Google Analytics Profile for AMP page</h3>
+ <p>set your Profile ID (NNNNN-N) for AMP page</p>
+ <p><input name="google_analytics.amp.profile" value="#{h @conf['google_analytics.amp.profile']}"></p>
+ HTML
+ end
+ r
+end
+
+if defined? AMP
+ add_amp_header_proc do
+ %Q|<script async custom-element="amp-analytics"
+ src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>|
+ end
+
+ add_amp_body_enter_proc do
+ profile_id = %w(google_analytics.amp.profile google_analytics.profile).map {|key|
+ @conf[key]
+ }.find {|profile|
+ profile && !profile.empty?
+ }
+ <<-HTML
+ <amp-analytics type="googleanalytics" id="analytics1">
+ <script type="application/json">
+ {
+ "vars": { "account": "UA-#{h profile_id}" },
+ "triggers": { "trackPageview": { "on": "visible", "request": "pageview" } }
+ }
+ </script>
+ </amp-analytics>
+ HTML
+ end
end
diff --git a/plugin/ogp.rb b/plugin/ogp.rb
index 34a16f7..fd771e5 100644
--- a/plugin/ogp.rb
+++ b/plugin/ogp.rb
@@ -7,31 +7,46 @@
# @conf['ogp.facebook.app_id'] - your facebook application ID.
# @conf['ogp.facebook.admins'] - your facebook ID.
-def ogp_description
- section_index = @cgi.params['p'][0]
- # section_index = "1"
- if @mode == 'day' and section_index
- diary = @diaries[@date.strftime('%Y%m%d')]
- sections = diary.instance_variable_get(:@sections)
- section = sections[section_index.to_i - 1].body_to_html
- @conf.shorten(apply_plugin(section, true), 200)
+def ogp_description(html)
+ @conf.shorten(remove_tag(html), 200)
+end
+
+def ogp_image(html)
+ images = html.scan(/<img.*?src="(.*?)"/)
+ if !images.empty?
+ images.first[0]
else
- @conf.description
+ @conf.banner
end
end
add_header_proc do
headers = {
- # TODO: og:urlへ対応
'og:title' => title_tag.match(/>([^<]+)</).to_a[1],
'og:site_name' => @conf.html_title,
- 'og:description' => ogp_description,
- 'og:image' => @conf.banner,
- 'og:type' => (@mode == 'day') ? 'article' : 'blog',
'og:author' => @conf.author_name,
'fb:app_id' => @conf['ogp.facebook.app_id'],
'fb:admins' => @conf['ogp.facebook.admins']
}
+
+ if @mode == 'day'
+ diary = @diaries[@date.strftime('%Y%m%d')]
+ if diary
+ sections = diary.instance_variable_get(:@sections)
+ section_index = @cgi.params['p'][0] || sections.size
+ section = sections[section_index.to_i - 1].body_to_html
+ section_html = apply_plugin(section)
+
+ headers['og:description'] = ogp_description(section_html)
+ headers['og:image'] = ogp_image(section_html)
+ headers['og:type'] = 'article'
+ end
+ else
+ headers['og:description'] = @conf.description
+ headers['og:image'] = @conf.banner
+ headers['og:type'] = 'website'
+ end
+
headers.select {|key, val|
val && !val.empty?
}.map {|key, val|
diff --git a/plugin/picasa.rb b/plugin/picasa.rb
index 6dba1e5..7c3bf77 100644
--- a/plugin/picasa.rb
+++ b/plugin/picasa.rb
@@ -29,37 +29,3 @@ end
def picasa_right( src, alt = "photo" )
picasa( src, alt, 'right' )
end
-
-if /\A(form|edit|preview|showcomment)\z/ === @mode then
- enable_js( 'picasa.js' )
- add_js_setting( '$tDiary.plugin.picasa' )
- add_js_setting( '$tDiary.plugin.picasa.userId', %Q|'#{@conf['picasa.user']}'| )
- add_js_setting( '$tDiary.plugin.picasa.imgMax', %Q|'#{@conf[ 'picasa.default_size'] || 400}'| )
-end
-
-add_edit_proc do |date|
- unless @conf['picasa.user']
- '<p>[ERROR] picasa.rb: Picasa username is not specified.</p>'
- else
- <<-HTML
- <h3 class="plugin_picasa"><span>Picasa Web Album</span></h3>
- <div id="plugin_picasa"></div>
- HTML
- end
-end
-
-add_conf_proc( 'picasa', 'Picasa' ) do
- if @mode == 'saveconf'
- @conf['picasa.user'], = @cgi.params['picasa.user']
- @conf['picasa.default_size'] = @cgi.params['picasa.default_size'][0].to_i
- @conf['picasa.default_size'] = 400 if @conf['picasa.default_size'] == 0
- end
-
- <<-HTML
- <h3 class="subtitle">Picasa user name</h3>
- <p><input name="picasa.user" value="#{h @conf['picasa.user']}"></p>
-
- <h3 class="subtitle">default size</h3>
- <p><input name="picasa.default_size" value="#{h @conf['picasa.default_size']}"></p>
- HTML
-end
diff --git a/plugin/playstore.rb b/plugin/playstore.rb
index 98554cf..d768fd0 100644
--- a/plugin/playstore.rb
+++ b/plugin/playstore.rb
@@ -131,7 +131,7 @@ def playstore_text(app_id)
when :notfound
"<em>#{app_id} was not found</em>"
else
- %Q[<a href="#{app.market_url}">#{app.title}</a>]
+ %Q[<a href="#{app.store_url}">#{app.title}</a>]
end
end
diff --git a/spec/flicker_spec.rb b/spec/flicker_spec.rb
index a038a8f..e0fd1f9 100644
--- a/spec/flicker_spec.rb
+++ b/spec/flicker_spec.rb
@@ -15,7 +15,7 @@ describe "flickr plugin" do
subject { plugin.flickr('5950109223', size = nil) }
it do
- expect(subject).to eq %Q|<a href=\"https://www.flickr.com/photos/machu/5950109223/\" class=\"flickr\"><img title=\"RubyKaigi 2011\" alt=\"RubyKaigi 2011\" src=\"https://farm7.staticflickr.com/6006/5950109223_040097db92.jpg\" class=\"flickr photo\"></a>|
+ expect(subject).to eq %Q|<a href=\"https://www.flickr.com/photos/machu/5950109223/\" class=\"flickr\"><img title=\"RubyKaigi 2011\" alt=\"RubyKaigi 2011\" src=\"https://farm7.staticflickr.com/6006/5950109223_040097db92.jpg\" class=\"flickr photo\" height=\"375\" width=\"500\"></a>|
end
end
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