Sha256: 8ef3216dc3fa9a7ac54d5b95a632fff080cb5f1a70b423b512a7211f282f659f

Contents?: true

Size: 1.84 KB

Versions: 8

Compression:

Stored size: 1.84 KB

Contents

# show photo image on Picasa Web Album
#
# usage:
#   picasa( src[, title[, place]] )
#     - src: The url of the photo to show.
#     - title: title of photo. (optional)
#     - place: class name of img element. default is 'photo'.
#
#   picasa_left( src[, title] )
#
#   picasa_right( src[, title] )
#
# options configurable through settings:
#   @conf['picasa.user'] : picasa username
#   @conf['picasa.default_size'] : default image size
#
# Copyright (c) hb <http://www.smallstyle.com>
# Distributed under the GPL.
#

def picasa( src, alt = "photo", place = 'photo' )
	%Q|<img title="#{alt}" alt="#{alt}" src="#{src}" class="#{place} picasa">|
end

def picasa_left( src, alt = "photo" )
	picasa( src, alt, 'left' )
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

Version data entries

8 entries across 7 versions & 2 rubygems

Version Path
tdiary-contrib-5.0.3 plugin/picasa.rb
tdiary-contrib-5.0.2 plugin/picasa.rb
tdiary-contrib-5.0.1 plugin/picasa.rb
tdiary-contrib-5.0.0 plugin/picasa.rb
tdiary-contrib-4.2.1 plugin/picasa.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/bundler/gems/tdiary-contrib-2ab36447ae2a/plugin/picasa.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/bundler/gems/tdiary-contrib-d189eb6688f1/plugin/picasa.rb
tdiary-contrib-4.2.0 plugin/picasa.rb