Sha256: 9844b5165813bd9aa9f1cf08d3f9d316e483afcedc4164a5b260f72dd689d632

Contents?: true

Size: 919 Bytes

Versions: 5

Compression:

Stored size: 919 Bytes

Contents

# theme_online.rb: choice theme from online repository on tDiary.org
#
# options:
#    @options['theme_online.url']: top level URL of another theme site
#
# Copyright (C) 2014 by TADA Tadashi <t@tdtds.jp>
# You can distribute and/or modify it under GPL2 or any later version.
#
require 'json'
require 'open-uri'

def theme_list_online(list)
	url = @options['theme_online.url'] || 'http://theme.tdiary.org/'
	url = "http:#{url}" if url =~ %r|\A//|
	begin
		online_list = JSON.load(open(File.join(url, 'themes.json'), &:read))['themes']
		list + online_list.keys.map do |t|
			title = online_list[t]['title']
			label = t == title ? '' : " (#{title})"
			["online/#{t}", "#{t}#{label}"]
		end
	rescue
		@logger.error "could not get theme list from online: #$!"
		list
	end
end

def theme_url_online(theme)
	url = @options['theme_online.url'] || 'http://theme.tdiary.org/'
	File.join(url, "#{h theme}/#{h theme}.css")
end

Version data entries

5 entries across 4 versions & 1 rubygems

Version Path
tdiary-4.2.1 misc/plugin/theme_online.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/tdiary-4.2.0/misc/plugin/theme_online.rb
tdiary-4.2.0 misc/plugin/theme_online.rb
tdiary-4.1.3 misc/plugin/theme_online.rb
tdiary-4.1.2 misc/plugin/theme_online.rb