Top Level Namespace
Defined Under Namespace
Modules: AWS, TDiary Classes: CGI, Comment, Diary, PStore, PStoreRuby18Exception, Paragraph, RackCGI, RefererDiary, String
Constant Summary collapse
- TDIARY_VERSION =
TDiary::VERSION
- SP_PREFIX =
50sp.rb - select-plugins plugin
'sp'
- SF_PREFIX =
60sf.rb - select-filters plugin This file is based on 50sp.rb Revision: 1.5 Modified by KURODA Hiraku.
'sf'
Instance Method Summary collapse
- #add_purge_cache_proc(&proc) ⇒ Object
-
#anchor(s) ⇒ Object
make anchor string.
- #author_mail_tag ⇒ Object
- #author_name_tag ⇒ Object
- #auto_migration_spam_champuru ⇒ Object
- #brl ⇒ Object
-
#brr ⇒ Object
layout.
- #calc_links ⇒ Object
-
#calendar ⇒ Object
make calendar.
-
#category_anchor(c) ⇒ Object
category.
- #charset ⇒ Object
- #comment_body_label ⇒ Object
- #comment_body_label_short ⇒ Object
- #comment_date(time) ⇒ Object
-
#comment_description ⇒ Object
make comment form.
- #comment_description_default ⇒ Object
- #comment_description_short ⇒ Object
- #comment_form ⇒ Object
- #comment_form_text ⇒ Object
-
#comment_length ⇒ Object
‘comment_length’ returns length of shorten comment on recent or monthly view.
- #comment_limit_label ⇒ Object
- #comment_mail(text) ⇒ Object
- #comment_mail_basic_html ⇒ Object
- #comment_mail_basic_setting ⇒ Object
-
#comment_mail_conf_label ⇒ Object
TSUKKOMI mail.
- #comment_mail_label ⇒ Object
- #comment_mail_label_short ⇒ Object
-
#comment_mail_mime(str) ⇒ Object
service methods for comment_mail.
- #comment_mail_send ⇒ Object
- #comment_name_label ⇒ Object
- #comment_name_label_short ⇒ Object
- #comment_new ⇒ Object
- #comment_submit_label ⇒ Object
- #comment_submit_label_short ⇒ Object
- #comment_today ⇒ Object
- #comment_total(total) ⇒ Object
- #conf_logger_list ⇒ Object
-
#conf_theme_list ⇒ Object
themes.
- #content_script_type ⇒ Object
- #convert_element(data) ⇒ Object
- #convert_pstore(file) ⇒ Object
- #css_tag ⇒ Object
- #description_tag ⇒ Object
- #dnsblfilter_conf_html ⇒ Object
-
#doctype ⇒ Object
define DOCTYPE.
-
#encoding ⇒ Object
‘encoding’ method returns String of HTTP or HTML charactor encoding.
- #encoding_old ⇒ Object
- #hide_comment_day_limit ⇒ Object
-
#html_lang ⇒ Object
tDiary language setup: Japanese(ja).
- #icon_tag ⇒ Object
- #index_page_tag ⇒ Object
-
#insert(file) ⇒ Object
insert file.
- #jquery_tag ⇒ Object
- #js_url ⇒ Object
- #label_no_referer ⇒ Object
- #label_only_volatile ⇒ Object
- #label_referer_table ⇒ Object
- #last_modified_header ⇒ Object
- #latest_day?(diary) ⇒ Boolean
- #make_category_link(subtitle) ⇒ Object
-
#migrate_to_utf8(str) ⇒ Object
‘migrate_to_utf8’ method converts string to UTF-8, but dummy in en.
- #mobile_label_hidden_diary ⇒ Object
- #mobile_navi ⇒ Object
- #mobile_navi_edit ⇒ Object
-
#mobile_navi_latest ⇒ Object
labels (for mobile).
- #mobile_navi_next_diary ⇒ Object
- #mobile_navi_preference ⇒ Object
- #mobile_navi_prev_diary ⇒ Object
- #mobile_navi_update ⇒ Object
-
#my(a, str, title = nil) ⇒ Object
make anchor tag in my diary.
-
#navi ⇒ Object
make navigation buttons.
- #navi_admin ⇒ Object
- #navi_edit ⇒ Object
- #navi_index ⇒ Object
- #navi_item(link, label, rel = nil) ⇒ Object
- #navi_latest ⇒ Object
- #navi_next_diary(date) ⇒ Object
- #navi_next_month ⇒ Object
- #navi_next_ndays ⇒ Object
- #navi_next_nyear(date) ⇒ Object
- #navi_oldest ⇒ Object
- #navi_preference ⇒ Object
- #navi_prev_diary(date) ⇒ Object
- #navi_prev_month ⇒ Object
- #navi_prev_ndays ⇒ Object
- #navi_prev_nyear(date) ⇒ Object
- #navi_update ⇒ Object
- #navi_user ⇒ Object
- #navi_user_day ⇒ Object
- #navi_user_default ⇒ Object
- #navi_user_edit ⇒ Object
- #navi_user_else ⇒ Object
- #navi_user_format(day) ⇒ Object
- #navi_user_latest ⇒ Object
- #navi_user_month ⇒ Object
- #navi_user_nyear ⇒ Object
-
#no_diary ⇒ Object
labels (normal).
- #nyear_diary_label ⇒ Object
- #nyear_diary_title ⇒ Object
- #nyear_link(date, title) ⇒ Object
- #ogp_tag ⇒ Object
-
#old_ruby_alert ⇒ Object
old ruby alert.
-
#old_ruby_alert_message ⇒ Object
old ruby alert.
- #preview_command ⇒ Object
- #preview_label ⇒ Object
- #referer_add_to_diary(diary, body) ⇒ Object
- #referer_file_name(diary) ⇒ Object
- #referer_load(file, diary) ⇒ Object
- #referer_load_current(diary) ⇒ Object
- #referer_load_volatile(diary) ⇒ Object
- #referer_of_today_long(diary, limit) ⇒ Object
-
#referer_of_today_short(diary, limit) ⇒ Object
referer of today.
- #referer_save(file, diary) ⇒ Object
- #referer_save_current(diary, referer) ⇒ Object
- #referer_save_trigger ⇒ Object
- #referer_save_volatile(diary, referer) ⇒ Object
-
#referer_today ⇒ Object
05referer.rb: Japanese resource of referer plugin.
- #referer_update(diary) ⇒ Object
- #referer_volatile_file_name ⇒ Object
- #referer_write_from_diary(fh, diary) ⇒ Object
- #robot_control ⇒ Object
-
#saveconf_comment ⇒ Object
comments.
- #saveconf_csrf_protection ⇒ Object
-
#saveconf_default ⇒ Object
basic (default).
-
#saveconf_display ⇒ Object
diaplay.
-
#saveconf_header ⇒ Object
header/footer (header).
- #saveconf_logger ⇒ Object
- #saveconf_recommendfilter ⇒ Object
-
#saveconf_referer ⇒ Object
referer preference.
- #saveconf_theme ⇒ Object
-
#saveconf_timezone ⇒ Object
timezone.
- #script_tag ⇒ Object
- #script_tag_query_string ⇒ Object
-
#sf_doc_url(file) ⇒ Object
url of the document.
- #sf_filters ⇒ Object
-
#sf_hash_from_dirs(dirs) ⇒ Object
hash of paths from array of dirs.
-
#sf_li_plugins(paths, is_checked) ⇒ Object
<li> list of plugins.
-
#sf_list_plugins(sf_opt) ⇒ Object
lists of plugins.
-
#sf_option(key) ⇒ Object
get plugin option.
-
#shorten(str, len = 120) ⇒ Object
‘shorten’ method cuts string length.
-
#sp_doc_url(file) ⇒ Object
url of the document.
-
#sp_hash_from_dirs(dirs) ⇒ Object
hash of paths from array of dirs.
-
#sp_li_plugins(paths, is_checked) ⇒ Object
<li> list of plugins.
-
#sp_list_plugins(sp_opt) ⇒ Object
lists of plugins.
-
#sp_option(key) ⇒ Object
get plugin option.
- #spamfilter_conf_html ⇒ Object
-
#style_howto ⇒ Object
link to HOWTO write diary.
-
#submit_command ⇒ Object
other resources.
- #submit_label ⇒ Object
- #subtitle_link(date, index, subtitle) ⇒ Object
- #theme_list_local(list) ⇒ Object
- #theme_paths_local ⇒ Object
- #theme_url ⇒ Object
- #theme_url_local(theme) ⇒ Object
- #title_of_day(date, title) ⇒ Object
-
#title_tag ⇒ Object
header.
-
#to_utf8(str, charset = nil) ⇒ Object
convert to UTF-8.
- #trackback_today ⇒ Object
- #trackback_total(total) ⇒ Object
- #volatile_referer ⇒ Object
Instance Method Details
#add_purge_cache_proc(&proc) ⇒ Object
16 17 18 |
# File 'lib/tdiary/plugin/03purge_cache.rb', line 16 def add_purge_cache_proc(&proc) @purge_cache_procs << proc end |
#anchor(s) ⇒ Object
make anchor string
469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/tdiary/plugin/00default.rb', line 469 def anchor( s ) if /^([\-\d]+)#?([pct]\d*)?$/ =~ s then if $2 then "?date=#$1##$2" else "?date=#$1" end else "" end end |
#author_mail_tag ⇒ Object
280 281 282 283 284 285 286 |
# File 'lib/tdiary/plugin/00default.rb', line 280 def if @conf. and not(@conf..empty?) then %Q[<link rev="made" href="mailto:#{h @conf.}">] else '' end end |
#author_name_tag ⇒ Object
272 273 274 275 276 277 278 |
# File 'lib/tdiary/plugin/00default.rb', line 272 def if @conf. and not(@conf..empty?) then %Q[<meta name="author" content="#{h @conf.}">] else '' end end |
#auto_migration_spam_champuru ⇒ Object
155 156 157 158 159 160 |
# File 'lib/tdiary/plugin/10spamfilter.rb', line 155 def auto_migration_spam_champuru # auto migration of spam-champuru shutdown. if @conf['spamlookup.ip.list'] && @conf['spamlookup.ip.list'].scan(/dnsbl\.spam-champuru\.livedoor\.com/).size > 0 @conf['spamlookup.ip.list'].gsub!(/dnsbl\.spam-champuru\.livedoor\.com/, "bsb.spamlookup.net") end end |
#brl ⇒ Object
733 |
# File 'lib/tdiary/plugin/00default.rb', line 733 def brl; '<br clear="left">'; end |
#brr ⇒ Object
layout
732 |
# File 'lib/tdiary/plugin/00default.rb', line 732 def brr; '<br clear="right">'; end |
#calc_links ⇒ Object
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/tdiary/plugin/00default.rb', line 223 def calc_links if /day|edit/ =~ @mode then today = @date.strftime('%Y%m%d') days = [] yms = [] this_month = today[0,6] @years.keys.each do |y| yms += @years[y].collect {|m| y + m} end yms |= [this_month] yms.sort! yms.unshift(nil).push(nil) yms[yms.index(this_month) - 1, 3].each do |ym| next unless ym now = @cgi.params['date'] # backup cgi = @cgi.clone cgi.params['date'] = [ym] m = TDiaryMonthWithoutFilter.new(cgi, '', @conf) @cgi.params['date'] = now # restore m.diaries.delete_if {|date,diary| !diary.visible?} days += m.diaries.keys.sort end days |= [today] days.sort! days.unshift(nil).push(nil) @navi_user_days = days[days.index(today) - 1, 3] @prev_day = @navi_user_days[0] @next_day = @navi_user_days[2] elsif @mode == 'nyear' y = 2000 # specify leam year m, d = @cgi.params['date'][0].scan(/^(\d\d)(\d\d)$/)[0] @prev_day = (Time.local(y, m, d) - 24*60*60).strftime( '%Y%m%d' ) @next_day = (Time.local(y, m, d) + 24*60*60).strftime( '%Y%m%d' ) end end |
#calendar ⇒ Object
make calendar
169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/tdiary/plugin/00default.rb', line 169 def calendar result = %Q[<div class="calendar">\n] @years.keys.sort.each do |year| result << %Q[<div class="year">#{year}|] @years[year.to_s].sort.each do |month| m = "#{year}#{month}" result << %Q[<a href="#{h @conf.index}#{anchor m}">#{month}</a>|] end result << "</div>\n" end result << "</div>" end |
#category_anchor(c) ⇒ Object
category
109 |
# File 'lib/tdiary/plugin/en/00default.rb', line 109 def category_anchor(c); "[#{c}]"; end |
#charset ⇒ Object
260 261 262 |
# File 'lib/tdiary/plugin/00default.rb', line 260 def charset @conf.encoding end |
#comment_body_label ⇒ Object
59 |
# File 'lib/tdiary/plugin/en/00default.rb', line 59 def comment_body_label; 'Comment'; end |
#comment_body_label_short ⇒ Object
60 |
# File 'lib/tdiary/plugin/en/00default.rb', line 60 def comment_body_label_short; 'Comment'; end |
#comment_date(time) ⇒ Object
63 |
# File 'lib/tdiary/plugin/en/00default.rb', line 63 def comment_date( time ); time.strftime( "(#{@conf.date_format} %H:%M)" ); end |
#comment_description ⇒ Object
make comment form
558 559 560 561 562 563 564 565 566 |
# File 'lib/tdiary/plugin/00default.rb', line 558 def comment_description begin if @conf.['comment_description'].length > 0 then return @conf.['comment_description'] end rescue end comment_description_default end |
#comment_description_default ⇒ Object
52 |
# File 'lib/tdiary/plugin/en/00default.rb', line 52 def comment_description_default; 'Add a TSUKKOMI or Comment please. E-mail address will be shown to only me.'; end |
#comment_description_short ⇒ Object
54 |
# File 'lib/tdiary/plugin/en/00default.rb', line 54 def comment_description_short; 'TSUKKOMI!!'; end |
#comment_form ⇒ Object
625 626 627 628 629 630 631 |
# File 'lib/tdiary/plugin/00default.rb', line 625 def comment_form return '' unless @mode == 'day' return '' if bot? return '' if hide_comment_day_limit comment_form_text end |
#comment_form_text ⇒ Object
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
# File 'lib/tdiary/plugin/00default.rb', line 568 def comment_form_text unless @diary then @diary = @diaries[@date.strftime( '%Y%m%d' )] return '' unless @diary end r = '' unless @conf.hide_comment_form then r = <<-FORM <div class="form"> FORM if @diary.count_comments( true ) >= @conf.comment_limit_per_day then r << <<-FORM <div class="caption"><a name="c">#{comment_limit_label}</a></div> FORM else r << <<-FORM <div class="caption"><a name="c">#{comment_description}</a></div> <form class="comment" name="comment-form" method="post" action="#{h @conf.index}"><div> <input type="hidden" name="date" value="#{ @date.strftime( '%Y%m%d' )}"> <div class="field name"> #{comment_name_label}:<input class="field" name="name" value="#{h( @conf.to_native(@cgi.['tdiary'][0] || '' ))}"> </div> <div class="field mail"> #{comment_mail_label}:<input class="field" name="mail" value="#{h( @cgi.['tdiary'][1] || '' )}"> </div> <div class="textarea"> #{comment_body_label}:<textarea name="body" cols="60" rows="5"></textarea> </div> <div class="button"> <input type="submit" name="comment" value="#{h comment_submit_label}"> </div> </div></form> FORM end r << <<-FORM </div> FORM end r end |
#comment_length ⇒ Object
‘comment_length’ returns length of shorten comment on recent or monthly view.
48 49 50 |
# File 'lib/tdiary/lang/en.rb', line 48 def comment_length 120 end |
#comment_limit_label ⇒ Object
53 |
# File 'lib/tdiary/plugin/en/00default.rb', line 53 def comment_limit_label; 'You cannot make more TSUKKOMI because it has over limit.'; end |
#comment_mail(text) ⇒ Object
708 709 710 711 |
# File 'lib/tdiary/plugin/00default.rb', line 708 def comment_mail( text ) # no action in default. # override by each plugins. end |
#comment_mail_basic_html ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/tdiary/plugin/en/00default.rb', line 264 def comment_mail_basic_html @conf['comment_mail.header'] = '' unless @conf['comment_mail.header'] @conf['comment_mail.receivers'] = '' unless @conf['comment_mail.receivers'] @conf['comment_mail.sendhidden'] = false unless @conf['comment_mail.sendhidden'] <<-HTML <h3 class="subtitle">Notify TSUKKOMI by E-mail</h3> <p>Select notify or not when your diary gets a new TSUKKOMI. So TSUKKOMI mail need SMTP server settings in tdiary.conf.</p> <p><select name="comment_mail.enable"> <option value="true"#{" selected" if @conf['comment_mail.enable']}>Send Mail</option> <option value="false"#{" selected" unless @conf['comment_mail.enable']}>Don't Send</option> </select></p> <h3 class="subtitle">Receivers</h3> <p>Sepecify receivers of TSUKKOMI mail, 1 address per 1 line. If you dose not specify, TSUKKOMI mails will be sent to your address.</p> <p><textarea name="comment_mail.receivers" cols="40" rows="3">#{h( @conf['comment_mail.receivers'].gsub( /[, ]+/, "\n") )}</textarea></p> <h3 class="subtitle">Mail header</h3> <p>Specify a string insert to beginning of mail subject. The subject have a style of "your_specified_string:DATE-SERIAL NAME". "date" is formatted as same as diary's date you specified. But when you specify another date style in this string, subject style is changed to "your_specified_string-SERIAL NAME" (ex: "hoge:%Y-%m-%d")</p> <p><input name="comment_mail.header" value="#{h @conf['comment_mail.header']}"></p> <h3 class="subtitle">About hidden TSUKKOMI</h3> <p>Some TSUKKOMI are hidden by filters. You can decide which sending E-mail by hidden TSUKKOMI.</p> <p><label for="comment_mail.sendhidden"><input type="checkbox" id="comment_mail.sendhidden" name="comment_mail.sendhidden" value="#{" checked" if @conf['comment_mail.sendhidden']}">Send mail by hidden TSUKKOMI</label></p> HTML end |
#comment_mail_basic_setting ⇒ Object
713 714 715 716 717 718 719 720 |
# File 'lib/tdiary/plugin/00default.rb', line 713 def comment_mail_basic_setting if @mode == 'saveconf' then @conf['comment_mail.enable'] = @cgi.params['comment_mail.enable'][0] == 'true' ? true : false @conf['comment_mail.receivers'] = @cgi.params['comment_mail.receivers'][0].strip.gsub( /[\n\r]+/, ',' ) @conf['comment_mail.header'] = @cgi.params['comment_mail.header'][0] @conf['comment_mail.sendhidden'] = @cgi.params['comment_mail.sendhidden'][0] == 'true' ? true : false end end |
#comment_mail_conf_label ⇒ Object
TSUKKOMI mail
39 |
# File 'lib/tdiary/plugin/ja/00default.rb', line 39 def comment_mail_conf_label; 'TSUKKOMI Mail'; end |
#comment_mail_label ⇒ Object
57 |
# File 'lib/tdiary/plugin/en/00default.rb', line 57 def comment_mail_label; 'E-mail'; end |
#comment_mail_label_short ⇒ Object
58 |
# File 'lib/tdiary/plugin/en/00default.rb', line 58 def comment_mail_label_short; 'Mail'; end |
#comment_mail_mime(str) ⇒ Object
service methods for comment_mail
651 652 653 654 655 656 |
# File 'lib/tdiary/plugin/00default.rb', line 651 def comment_mail_mime( str ) require 'nkf' NKF::nkf("-w -m0 -f30", str).lines.map do |s| %Q|=?UTF-8?B?#{[s.chomp].pack('m').gsub(/\n/, '')}?=| end end |
#comment_mail_send ⇒ Object
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
# File 'lib/tdiary/plugin/00default.rb', line 658 def comment_mail_send return unless @comment return unless @conf['comment_mail.enable'] return unless @conf['comment_mail.sendhidden'] or @comment.visible? case @conf['comment_mail.receivers'] when Array # for compatibility receivers = @conf['comment_mail.receivers'] when String receivers = @conf['comment_mail.receivers'].split( /[, ]+/ ) else receivers = [] end receivers = [@conf.] if receivers.compact.empty? return if receivers.empty? name = comment_mail_mime(@comment.name)[0] body = @comment.body.sub( /[\r\n]+\Z/, '' ) mail = @comment.mail mail = @conf. unless mail =~ %r<[0-9a-zA-Z_.-]+@[\(\)%!0-9a-zA-Z_$@.&+-,'"*-]+> mail = receivers[0] if mail.empty? now = Time::now g = now.dup.gmtime l = Time::local( g.year, g.month, g.day, g.hour, g.min, g.sec ) tz = (g.to_i - l.to_i) / 36 date = now.strftime( "%a, %d %b %Y %X " ) + sprintf( "%+05d", tz ) require 'socket' serial = @diaries[@date.strftime( '%Y%m%d' )].count_comments( true ) = %Q!<tdiary.#{[@conf['comment_mail.header'] || ''].pack('m').gsub(/\n/,'')}.#{now.strftime('%Y%m%d%H%M%S')}.#{serial}@#{Socket::gethostname}>! subject_header = (@conf['comment_mail.header'] || '').dup subject_header << ":#{@conf.date_format}" unless /%[a-zA-Z%]/ =~ subject_header subject_header = @date.strftime(subject_header) subject_header = comment_mail_mime(subject_header).join("\n ") rmail = File::open("#{TDiary::PATH}/../views/mail.rtxt").read header = ERB::new(rmail).result(binding) text = NKF.nkf('-w -MB', [ body, "-- ", "#{@conf.index =~ %r|^https?://|i ? '': @conf.base_url}#{@conf.index.sub(%r|^\./|, '')}#{anchor(@date.strftime('%Y%m%d') + ('#c%02d' % serial))}", "IP: #{@cgi.remote_addr}", "Status: #{@comment.visible? ? 'shown' : 'hidden'}" ].join("\r\n")) comment_mail([header, text].join("\r\n"), receivers) end |
#comment_name_label ⇒ Object
55 |
# File 'lib/tdiary/plugin/en/00default.rb', line 55 def comment_name_label; 'Name'; end |
#comment_name_label_short ⇒ Object
56 |
# File 'lib/tdiary/plugin/en/00default.rb', line 56 def comment_name_label_short; 'Name'; end |
#comment_new ⇒ Object
51 |
# File 'lib/tdiary/plugin/en/00default.rb', line 51 def comment_new; 'Add a TSUKKOMI'; end |
#comment_submit_label ⇒ Object
61 |
# File 'lib/tdiary/plugin/en/00default.rb', line 61 def comment_submit_label; 'Submit'; end |
#comment_submit_label_short ⇒ Object
62 |
# File 'lib/tdiary/plugin/en/00default.rb', line 62 def comment_submit_label_short; 'Submit'; end |
#comment_today ⇒ Object
49 |
# File 'lib/tdiary/plugin/en/00default.rb', line 49 def comment_today; "Today's TSUKKOMI"; end |
#comment_total(total) ⇒ Object
50 |
# File 'lib/tdiary/plugin/en/00default.rb', line 50 def comment_total( total ); "(Total: #{total})"; end |
#conf_logger_list ⇒ Object
909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
# File 'lib/tdiary/plugin/00default.rb', line 909 def conf_logger_list log_level_list = ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"] r = '' @conf['log_level'] ||= "INFO" log_level_list.each do |level| if level == @conf['log_level'] then select = " selected" end r << %Q|<option value="#{h level}"#{select}>#{level}</option>| end r << %Q|</select></p>| end |
#conf_theme_list ⇒ Object
themes
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 |
# File 'lib/tdiary/plugin/00default.rb', line 786 def conf_theme_list r = '' t = -1 @conf_theme_list.each_with_index do |theme, index| if theme[0] == @conf.theme then select = " selected" t = index end r << %Q|<option value="#{h theme[0]}"#{select}>#{theme[1]}</option>| end img = t == -1 ? 'nowprinting' : @conf.theme.sub(/^.*\//, '') r << <<-HTML </select> <input name="css" size="30" value="#{h @conf.css}"> </p> <p><img id="theme_thumbnail" src="http://www.tdiary.org/theme.image/#{img}.jpg" alt="#{@theme_thumbnail_label}"></p> #{@theme_location_comment} HTML end |
#content_script_type ⇒ Object
268 269 270 |
# File 'lib/tdiary/plugin/00default.rb', line 268 def content_script_type '' end |
#convert_element(data) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/tdiary/plugin/90migrate.rb', line 30 def convert_element( data ) case data when Hash, Array data.each_with_index do |e, i| if String === e data[i] = @conf.migrate_to_utf8( e ) else convert_element( e ) end end else data.instance_variables.each do |e| var = data.instance_variable_get( e ) if String === var data.instance_variable_set( e, @conf.migrate_to_utf8( var ) ) else convert_element( var ) end end end end |
#convert_pstore(file) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tdiary/plugin/90migrate.rb', line 6 def convert_pstore( file ) require "pstore" db = PStore.new( file ) begin roots = db.transaction{ db.roots } rescue ArgumentError if /\Aundefined class\/module (.+?)(::)?\z/ =~ $!. klass = $1 if /EmptdiaryString\z/ =~ klass eval( "class #{klass} < String; end" ) else eval( "class #{klass}; end" ) end retry end end db.transaction do roots.each do |root| convert_element( db[root] ) end end end |
#css_tag ⇒ Object
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/tdiary/plugin/00default.rb', line 405 def css_tag location, name = (@conf.theme || '').split(%r[/], 2) if @mode =~ /conf$/ then css = "#{h theme_url}/conf.css" elsif name && name.length > 0 css = __send__("theme_url_#{location}", name) css = theme_url_local('default') unless css # the location is not defined else css = @conf.css end title = File::basename( css, '.css' ) <<-CSS <link rel="stylesheet" href="#{h theme_url}/base.css" media="all"> <link rel="stylesheet" href="#{h css}" title="#{h title}" media="all"> CSS end |
#description_tag ⇒ Object
355 356 357 358 359 360 361 |
# File 'lib/tdiary/plugin/00default.rb', line 355 def description_tag if @conf.description and not(@conf.description.empty?) then %Q[<meta name="description" content="#{h @conf.description}">] else '' end end |
#dnsblfilter_conf_html ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/tdiary/plugin/en/10spamfilter.rb', line 59 def dnsblfilter_conf_html r = <<-HTML <h3>Domain Blacklist Services</h3> <p>List of IP based Domain Blacklist Services</p> <p><textarea name="spamlookup.ip.list" cols="70" rows="5">#{h @conf['spamlookup.ip.list']}</textarea></p> <p>List of Domain Blacklist Services</p> <p><textarea name="spamlookup.domain.list" cols="70" rows="5">#{h @conf['spamlookup.domain.list']}</textarea></p> <p>List of Safe Domain. Example for search engine.</p> <p><textarea name="spamlookup.safe_domain.list" cols="70" rows="10">#{h @conf['spamlookup.safe_domain.list']}</textarea></p> HTML r end |
#doctype ⇒ Object
define DOCTYPE
196 197 198 |
# File 'lib/tdiary/plugin/00default.rb', line 196 def doctype %Q|<!DOCTYPE html>| end |
#encoding ⇒ Object
‘encoding’ method returns String of HTTP or HTML charactor encoding.
18 19 20 |
# File 'lib/tdiary/lang/en.rb', line 18 def encoding 'UTF-8' end |
#encoding_old ⇒ Object
22 23 24 |
# File 'lib/tdiary/lang/en.rb', line 22 def encoding_old 'UTF-8' end |
#hide_comment_day_limit ⇒ Object
633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'lib/tdiary/plugin/00default.rb', line 633 def hide_comment_day_limit if @conf..include?('spamfilter.date_limit') && @conf.['spamfilter.date_limit'] && /\A\d+\z/ =~ @conf.['spamfilter.date_limit'].to_s date_limit = @conf.['spamfilter.date_limit'].to_s.to_i now = Time.now today = Time.local(now.year, now.month, now.day) limit = today - 24 * 60 * 60 * date_limit if @date < limit return true end end return false end |
#html_lang ⇒ Object
tDiary language setup: Japanese(ja)
Copyright © 2001-2011, TADA Tadashi <[email protected]> You can redistribute it and/or modify it under GPL2. or any later version
11 12 13 |
# File 'lib/tdiary/lang/en.rb', line 11 def html_lang 'en-US' end |
#icon_tag ⇒ Object
313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/tdiary/plugin/00default.rb', line 313 def icon_tag if @conf.icon and not(@conf.icon.empty?) then if /\.ico$/ =~ @conf.icon then %Q[<link rel="shortcut icon" href="#{h @conf.icon}">] elsif /\.svg$/ =~ @conf.icon then %Q[<link rel="icon" href="#{h @conf.icon}" type="image/svg+xml">] else %Q[<link rel="icon" href="#{h @conf.icon}">] end else '' end end |
#index_page_tag ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/tdiary/plugin/00default.rb', line 288 def index_page_tag result = '' if @conf.index_page and @conf.index_page.size > 0 then result << %Q[<link rel="index" title="#{h navi_index}" href="#{h @conf.index_page}">\n\t] end if @prev_day then case @mode when 'day' result << %Q[<link rel="prev" title="#{navi_prev_diary( Time::local(*@prev_day.scan(/^(\d{4})(\d\d)(\d\d)$/)[0]) )}" href="#{h @conf.index}#{anchor @prev_day}">\n\t] when 'nyear' result << %Q[<link rel="prev" title="#{navi_prev_nyear( Time::local(*@prev_day.scan(/^(\d{4})(\d\d)(\d\d)$/)[0]) )}" href="#{h @conf.index}#{anchor @prev_day[4,4]}">\n\t] end end if @next_day then case @mode when 'day' result << %Q[<link rel="next" title="#{navi_next_diary( Time::local(*@next_day.scan(/^(\d{4})(\d\d)(\d\d)$/)[0]) )}" href="#{h @conf.index}#{anchor @next_day}">\n\t] when 'nyear' result << %Q[<link rel="next" title="#{h navi_next_nyear( Time::local(*@next_day.scan(/^(\d{4})(\d\d)(\d\d)$/)[0]) )}" href="#{h @conf.index}#{anchor @next_day[4,4]}">\n\t] end end result << %Q[<link rel="start" title="#{navi_latest}" href="#{h @conf.index}">\n\t] result.chop.chop end |
#insert(file) ⇒ Object
insert file
185 186 187 188 189 190 191 |
# File 'lib/tdiary/plugin/00default.rb', line 185 def insert( file ) begin File::readlines( file ).join rescue %Q[<p class="message">#$! (#{h $!.class})<br>cannot read #{h file}.</p>] end end |
#jquery_tag ⇒ Object
363 364 365 |
# File 'lib/tdiary/plugin/00default.rb', line 363 def jquery_tag %Q[<script src="//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>] end |
#js_url ⇒ Object
378 379 380 |
# File 'lib/tdiary/plugin/00default.rb', line 378 def js_url @cgi.is_a?(RackCGI) ? 'assets' : 'js' end |
#label_no_referer ⇒ Object
11 |
# File 'lib/tdiary/plugin/en/05referer.rb', line 11 def label_no_referer; "Today's Links Excluding List"; end |
#label_only_volatile ⇒ Object
12 |
# File 'lib/tdiary/plugin/en/05referer.rb', line 12 def label_only_volatile; "Volatile Links List"; end |
#label_referer_table ⇒ Object
13 |
# File 'lib/tdiary/plugin/en/05referer.rb', line 13 def label_referer_table; "Today's Links Conversion Rule"; end |
#last_modified_header ⇒ Object
264 265 266 |
# File 'lib/tdiary/plugin/00default.rb', line 264 def last_modified_header '' end |
#latest_day?(diary) ⇒ Boolean
98 99 100 101 102 103 |
# File 'lib/tdiary/plugin/05referer.rb', line 98 def latest_day?( diary ) return false unless diary y = @years.keys.sort[-1] m = @years[y].sort[-1] diary.date.year == y.to_i and diary.date.month == m.to_i and diary.date.day == @diaries.keys.sort[-1][6,2].to_i end |
#make_category_link(subtitle) ⇒ Object
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'lib/tdiary/plugin/00default.rb', line 488 def make_category_link( subtitle ) r = '' if subtitle if respond_to?( :category_anchor ) then r << subtitle.sub( /^(\[([^\[]+?)\])+/ ) do $&.gsub( /\[(.*?)\]/ ) do $1.split( /,/ ).collect do |c| category_anchor( "#{CGI::unescapeHTML c}" ) end.join end end else r << subtitle end end r end |
#migrate_to_utf8(str) ⇒ Object
‘migrate_to_utf8’ method converts string to UTF-8, but dummy in en.
29 30 31 |
# File 'lib/tdiary/lang/en.rb', line 29 def migrate_to_utf8( str ) str.dup end |
#mobile_label_hidden_diary ⇒ Object
104 |
# File 'lib/tdiary/plugin/en/00default.rb', line 104 def mobile_label_hidden_diary; 'This day is HIDDEN.'; end |
#mobile_navi ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/tdiary/plugin/00default.rb', line 146 def mobile_navi result = [] if @navi_user_days and @navi_user_days[0] result << %Q[<A HREF="#{h @conf.index}#{anchor @navi_user_days[0]}" ACCESSKEY="*">[*]#{mobile_navi_prev_diary}</A>] end if @mode != 'latest' result << %Q[<A HREF="#{h @conf.index}" ACCESSKEY="0">[0]#{mobile_navi_latest}</A>] end if @navi_user_days and @navi_user_days[2] result << %Q[<A HREF="#{h @conf.index}#{anchor @navi_user_days[2]}" ACCESSKEY="#">[#]#{mobile_navi_next_diary}</A>] end if @mode == 'day' then result << %Q[<A HREF="#{h @conf.update}?edit=true;year=#{@date.year};month=#{@date.month};day=#{@date.day}" ACCESSKEY="5">[5]#{mobile_navi_edit}</A>] else result << %Q[<A HREF="#{h @conf.update}" ACCESSKEY="5">[5]#{mobile_navi_update}</A>] end result << %Q[<A HREF="#{h @conf.update}?conf=default" ACCESSKEY="8">[8]#{mobile_navi_preference}</A>] unless /^(latest|month|day|conf|nyear)$/ === @mode result.join('|') end |
#mobile_navi_edit ⇒ Object
100 |
# File 'lib/tdiary/plugin/en/00default.rb', line 100 def mobile_navi_edit; "Edit"; end |
#mobile_navi_latest ⇒ Object
labels (for mobile)
98 |
# File 'lib/tdiary/plugin/en/00default.rb', line 98 def mobile_navi_latest; 'Latest'; end |
#mobile_navi_next_diary ⇒ Object
103 |
# File 'lib/tdiary/plugin/en/00default.rb', line 103 def mobile_navi_next_diary; 'Next'; end |
#mobile_navi_preference ⇒ Object
101 |
# File 'lib/tdiary/plugin/en/00default.rb', line 101 def mobile_navi_preference; 'Prefs'; end |
#mobile_navi_prev_diary ⇒ Object
102 |
# File 'lib/tdiary/plugin/en/00default.rb', line 102 def mobile_navi_prev_diary; 'Prev'; end |
#mobile_navi_update ⇒ Object
99 |
# File 'lib/tdiary/plugin/en/00default.rb', line 99 def mobile_navi_update; 'Update'; end |
#my(a, str, title = nil) ⇒ Object
make anchor tag in my diary
524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/tdiary/plugin/00default.rb', line 524 def my( a, str, title = nil ) date, _, frag = a.scan( /^(\d{4}|\d{6}|\d{8}|\d{8}-\d+)([^\d]*)?#?([pct]\d+)?$/ )[0] anc = frag ? "#{date}#{frag}" : date index = /^https?:/ =~ @conf.index ? '' : base_url index += @conf.index.sub(%r|^\./|, '') if title then %Q[<a href="#{h index}#{anchor anc}" title="#{h title}">#{str}</a>] else %Q[<a href="#{h index}#{anchor anc}">#{str}</a>] end end |
#navi ⇒ Object
make navigation buttons
31 32 33 34 35 36 |
# File 'lib/tdiary/plugin/00default.rb', line 31 def navi result = %Q[<div class="adminmenu">\n] result << navi_user result << navi_admin result << %Q[</div>] end |
#navi_admin ⇒ Object
136 137 138 139 140 141 142 143 144 |
# File 'lib/tdiary/plugin/00default.rb', line 136 def navi_admin if @mode == 'day' then result = navi_item( "#{h @conf.update}?edit=true;year=#{@date.year};month=#{@date.month};day=#{@date.day}", h(navi_edit), "nofollow" ) else result = navi_item( h(@conf.update), h(navi_update), "nofollow") end result << navi_item( "#{h @conf.update}?conf=default", h(navi_preference) ) if /^(latest|month|day|comment|conf|nyear|category.*)$/ !~ @mode result end |
#navi_edit ⇒ Object
71 |
# File 'lib/tdiary/plugin/en/00default.rb', line 71 def navi_edit; "Edit"; end |
#navi_index ⇒ Object
67 |
# File 'lib/tdiary/plugin/en/00default.rb', line 67 def navi_index; 'Top'; end |
#navi_item(link, label, rel = nil) ⇒ Object
38 39 40 41 42 |
# File 'lib/tdiary/plugin/00default.rb', line 38 def navi_item( link, label, rel = nil ) result = %Q[<span class="adminmenu"><a href="#{link}"] result << %Q[ rel="#{rel}"] if rel result << %Q[>#{label}</a></span>\n] end |
#navi_latest ⇒ Object
68 |
# File 'lib/tdiary/plugin/en/00default.rb', line 68 def navi_latest; 'Latest'; end |
#navi_next_diary(date) ⇒ Object
74 |
# File 'lib/tdiary/plugin/en/00default.rb', line 74 def navi_next_diary(date); "Next(#{date.strftime(@conf.date_format)})"; end |
#navi_next_month ⇒ Object
76 |
# File 'lib/tdiary/plugin/en/00default.rb', line 76 def navi_next_month; "Next month"; end |
#navi_next_ndays ⇒ Object
80 |
# File 'lib/tdiary/plugin/en/00default.rb', line 80 def navi_next_ndays; "#{@conf.latest_limit} days after"; end |
#navi_next_nyear(date) ⇒ Object
78 |
# File 'lib/tdiary/plugin/en/00default.rb', line 78 def navi_next_nyear(date); "Next(#{date.strftime('%m-%d')})"; end |
#navi_oldest ⇒ Object
69 |
# File 'lib/tdiary/plugin/en/00default.rb', line 69 def navi_oldest; 'Oldest'; end |
#navi_preference ⇒ Object
72 |
# File 'lib/tdiary/plugin/en/00default.rb', line 72 def navi_preference; "Preference"; end |
#navi_prev_diary(date) ⇒ Object
73 |
# File 'lib/tdiary/plugin/en/00default.rb', line 73 def navi_prev_diary(date); "Prev(#{date.strftime(@conf.date_format)})"; end |
#navi_prev_month ⇒ Object
75 |
# File 'lib/tdiary/plugin/en/00default.rb', line 75 def navi_prev_month; "Prev month"; end |
#navi_prev_ndays ⇒ Object
79 |
# File 'lib/tdiary/plugin/en/00default.rb', line 79 def navi_prev_ndays; "#{@conf.latest_limit} days before"; end |
#navi_prev_nyear(date) ⇒ Object
77 |
# File 'lib/tdiary/plugin/en/00default.rb', line 77 def navi_prev_nyear(date); "Prev(#{date.strftime('%m-%d')})"; end |
#navi_update ⇒ Object
70 |
# File 'lib/tdiary/plugin/en/00default.rb', line 70 def navi_update; "Append"; end |
#navi_user ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/tdiary/plugin/00default.rb', line 44 def navi_user result = navi_user_default case @mode when 'latest' result << navi_user_latest when 'day' result << navi_user_day when 'month' result << navi_user_month when 'nyear' result << navi_user_nyear when 'edit' result << navi_user_edit else result << navi_user_else end result end |
#navi_user_day ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/tdiary/plugin/00default.rb', line 78 def navi_user_day result = '' if @navi_user_days then result << navi_item( "#{h @conf.index}#{anchor @navi_user_days[0]}", "«#{h navi_prev_diary(navi_user_format(@navi_user_days[0]))}" ) if @navi_user_days[0] result << navi_item( h(@conf.index), h(navi_latest) ) result << navi_item( "#{h @conf.index}#{anchor @navi_user_days[2]}", "#{h navi_next_diary(navi_user_format(@navi_user_days[2]))}»" ) if @navi_user_days[2] end result end |
#navi_user_default ⇒ Object
64 65 66 67 68 |
# File 'lib/tdiary/plugin/00default.rb', line 64 def navi_user_default result = '' result << navi_item( h(@conf.index_page), h(navi_index) ) unless @conf.index_page.empty? result end |
#navi_user_edit ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/tdiary/plugin/00default.rb', line 114 def navi_user_edit result = '' if @prev_day then a = @prev_day.scan( /^(\d{4})(\d\d)(\d\d)$/ ).flatten result << navi_item( "#{h @conf.update}?edit=true;year=#{a[0]};month=#{a[1]};day=#{a[2]}", "«#{h navi_prev_diary(Time::local(*@prev_day.scan(/^(\d{4})(\d\d)(\d\d)$/)[0]))}" ) end result << navi_item( h(@conf.index), h(navi_latest) ) if @next_day then a = @next_day.scan( /^(\d{4})(\d\d)(\d\d)$/ ).flatten result << navi_item( "#{h @conf.update}?edit=true;year=#{a[0]};month=#{a[1]};day=#{a[2]}", "#{h navi_next_diary(Time::local(*@next_day.scan(/^(\d{4})(\d\d)(\d\d)$/)[0]))}»" ) end result end |
#navi_user_else ⇒ Object
128 129 130 |
# File 'lib/tdiary/plugin/00default.rb', line 128 def navi_user_else navi_item( h(@conf.index), h(navi_latest) ) end |
#navi_user_format(day) ⇒ Object
132 133 134 |
# File 'lib/tdiary/plugin/00default.rb', line 132 def navi_user_format( day ) Time::local( *day.scan( /^(\d{4})(\d\d)(\d\d)$/ )[0] ) end |
#navi_user_latest ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/tdiary/plugin/00default.rb', line 70 def navi_user_latest result = '' result << navi_item( "#{h @conf.index}#{anchor( @conf['ndays.prev'] + '-' + @conf.latest_limit.to_s )}", "«#{navi_prev_ndays}", "next" ) if @conf['ndays.prev'] and not bot? result << navi_item( h(@conf.index), h(navi_latest) ) if @cgi.params['date'][0] result << navi_item( "#{h @conf.index}#{anchor( @conf['ndays.next'] + '-' + @conf.latest_limit.to_s )}", "#{navi_next_ndays}»", "prev") if @conf['ndays.next'] and not bot? result end |
#navi_user_month ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/tdiary/plugin/00default.rb', line 88 def navi_user_month ym = [] @years.keys.each do |y| ym += @years[y].collect {|m| y + m} end ym.sort! now = @date.strftime( '%Y%m' ) return '' unless ym.index( now ) prev_month = ym.index( now ) == 0 ? nil : ym[ym.index( now )-1] next_month = ym[ym.index( now )+1] result = '' result << navi_item( "#{h @conf.index}#{anchor( prev_month )}", "«#{h navi_prev_month}" ) if prev_month and not bot? result << navi_item( h(@conf.index), h(navi_latest) ) result << navi_item( "#{h @conf.index}#{anchor( next_month )}", "#{h navi_next_month}»" ) if next_month and not bot? result end |
#navi_user_nyear ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/tdiary/plugin/00default.rb', line 106 def navi_user_nyear result = '' result << navi_item( "#{h @conf.index}#{anchor @prev_day[4,4]}", "«#{h navi_prev_nyear(Time::local(*@prev_day.scan(/^(\d{4})(\d\d)(\d\d)$/)[0]))}" ) if @prev_day result << navi_item( h(@conf.index), h(navi_latest) ) unless @mode == 'latest' result << navi_item( "#{h @conf.index}#{anchor @next_day[4,4]}", "#{h navi_next_nyear(Time::local(*@next_day.scan(/^(\d{4})(\d\d)(\d\d)$/)[0]))}»" ) if @next_day result end |
#no_diary ⇒ Object
labels (normal)
48 |
# File 'lib/tdiary/plugin/en/00default.rb', line 48 def no_diary; "No diary on #{@date.strftime( @conf.date_format )}"; end |
#nyear_diary_label ⇒ Object
91 |
# File 'lib/tdiary/plugin/en/00default.rb', line 91 def nyear_diary_label; "my old days"; end |
#nyear_diary_title ⇒ Object
92 |
# File 'lib/tdiary/plugin/en/00default.rb', line 92 def nyear_diary_title; "same days in past"; end |
#nyear_link(date, title) ⇒ Object
451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
# File 'lib/tdiary/plugin/00default.rb', line 451 def nyear_link( date, title ) if @conf.show_nyear and @mode != 'nyear' then m = date.strftime( '%m' ) d = date.strftime( '%d' ) years = @years.find_all {|year, months| months.include? m} if years.length >= 2 then %Q|#{title} <span class="nyear">[<a href="#{h @conf.index}#{anchor m + d}" title="#{h(nyear_diary_title)}">#{nyear_diary_label}</a>]</span>| else title end else title end end |
#ogp_tag ⇒ Object
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/tdiary/plugin/00default.rb', line 327 def ogp_tag ogp = { 'og:title' => title_tag.gsub(/<[^>]*>/, ""), } if @conf. && !@conf..empty? ogp['og:image'] = @conf. end uri = @conf.index.dup uri[0, 0] = base_url if %r|^https?://|i !~ @conf.index uri.gsub!( %r|/\./|, '/' ) if @mode == 'day' then ogp['og:type'] = 'article' ogp['article:author'] = @conf. ogp['og:site_name'] = @conf.html_title ogp['og:url'] = uri + anchor( @date.strftime( '%Y%m%d' ) ) else ogp['og:type'] = 'website' ogp['og:description'] = @conf.description ogp['og:url'] = uri end ogp.map { |k, v| %Q|<meta property="#{k}" content="#{h(v)}">| }.join("\n") end |
#old_ruby_alert ⇒ Object
old ruby alert
963 964 965 966 967 968 969 970 971 972 |
# File 'lib/tdiary/plugin/00default.rb', line 963 def old_ruby_alert if RUBY_VERSION < '2.0.0' and !@conf['old_ruby_alert.hide'] %Q|<div class="alert-warn"> <a href="#" class="action-button" id="alert-old-ruby">×</a> #{} </div>| else '' end end |
#old_ruby_alert_message ⇒ Object
old ruby alert
373 374 375 |
# File 'lib/tdiary/plugin/en/00default.rb', line 373 def "お使いのRuby #{RUBY_VERSION}は次のリリースからサポート対象外になります。" end |
#preview_command ⇒ Object
547 548 549 550 551 552 553 |
# File 'lib/tdiary/plugin/00default.rb', line 547 def preview_command if @mode == 'form' or @cgi.valid?( 'appendpreview' ) then 'appendpreview' else 'replacepreview' end end |
#preview_label ⇒ Object
89 |
# File 'lib/tdiary/plugin/en/00default.rb', line 89 def preview_label; 'Preview'; end |
#referer_add_to_diary(diary, body) ⇒ Object
163 164 165 166 167 168 169 170 |
# File 'lib/tdiary/plugin/05referer.rb', line 163 def referer_add_to_diary( diary, body ) return unless body body.lines.each do |r| count, ref = r.chomp.split( / /, 2 ) next unless ref diary.add_referer( ref.chomp, count.to_i ) end end |
#referer_file_name(diary) ⇒ Object
141 142 143 |
# File 'lib/tdiary/plugin/05referer.rb', line 141 def referer_file_name( diary ) diary.date.strftime( "#{@conf.data_path}%Y/%Y%m%d.tdr" ) end |
#referer_load(file, diary) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/tdiary/plugin/05referer.rb', line 149 def referer_load( file, diary ) begin File::open( file, 'rb' ) do |fh| fh.flock( File::LOCK_SH ) fh.gets # read magic fh.read.split( /\r?\n\.\r?\n/ ).each do |l| headers, body = @conf.io_class.parse_tdiary( l ) yield( headers, @conf.to_native( body ) ) end end rescue Errno::ENOENT end end |
#referer_load_current(diary) ⇒ Object
172 173 174 175 176 177 |
# File 'lib/tdiary/plugin/05referer.rb', line 172 def referer_load_current( diary ) return unless diary referer_load( referer_file_name( diary ), diary ) do |headers, body| referer_add_to_diary( diary, body ) end end |
#referer_load_volatile(diary) ⇒ Object
179 180 181 182 183 184 185 |
# File 'lib/tdiary/plugin/05referer.rb', line 179 def referer_load_volatile( diary ) referer_load( referer_volatile_file_name, diary ) do |headers, body| diary.current_date = headers['Date'] referer_add_to_diary( diary, body ) end diary.current_date = nil end |
#referer_of_today_long(diary, limit) ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/tdiary/plugin/05referer.rb', line 238 def referer_of_today_long( diary, limit ) return '' if bot? result = '' if diary and diary.count_referers != 0 then result << %Q[<div class="caption">#{referer_today}</div>\n] result << %Q[<ul>\n] diary.each_referer( limit ) do |count,ref| result << %Q[<li>#{count} <a rel="nofollow" href="#{h ref}">#{h disp_referer( @conf.referer_table, ref )}</a></li>\n] end result << '</ul>' end if @referer_volatile and latest_day?( diary ) and @referer_volatile.count_referers != 0 then result << %Q[<div class="caption">#{volatile_referer}</div>\n] result << %Q[<ul>\n] @referer_volatile.each_referer( limit ) do |count,ref| result << %Q[<li>#{count} <a rel="nofollow" href="#{h ref}">#{h disp_referer( @conf.referer_table, ref )}</a></li>\n] end result << '</ul>' end result end |
#referer_of_today_short(diary, limit) ⇒ Object
referer of today
234 235 236 |
# File 'lib/tdiary/plugin/05referer.rb', line 234 def referer_of_today_short( diary, limit ) '' end |
#referer_save(file, diary) ⇒ Object
187 188 189 190 191 192 193 194 195 |
# File 'lib/tdiary/plugin/05referer.rb', line 187 def referer_save( file, diary ) File::open( file, File::WRONLY | File::CREAT ) do |fh| fh.flock( File::LOCK_EX ) fh.rewind fh.truncate( 0 ) fh.puts( ::TDiary::TDIARY_MAGIC ) yield( fh ) end end |
#referer_save_current(diary, referer) ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/tdiary/plugin/05referer.rb', line 205 def referer_save_current( diary, referer ) return unless referer # checking only volatile list ref = CGI::unescape( referer.sub( /#.*$/, '' ).sub( /\?\d{8}$/, '' ) ) @conf.only_volatile.each do |volatile| return if /#{volatile}/i =~ ref end diary.add_referer( referer ) referer_save( referer_file_name( diary ), diary ) do |fh| referer_write_from_diary( fh, diary ) end end |
#referer_save_trigger ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tdiary/plugin/05referer.rb', line 16 def referer_save_trigger return unless @conf.io_class.to_s == 'TDiary::IO::Default' return unless @mode =~ /^(latest|day|edit|append|replace)$/ if @date then diary = @diaries[@date.strftime( '%Y%m%d' )] diary.clear_referers if diary end referer_update( diary ) end |
#referer_save_volatile(diary, referer) ⇒ Object
220 221 222 223 224 225 226 227 228 229 |
# File 'lib/tdiary/plugin/05referer.rb', line 220 def referer_save_volatile( diary, referer ) # to prevend the increase in file size return if diary.count_referers > 10000 diary.add_referer( referer ) if referer referer_save( referer_volatile_file_name, diary ) do |fh| diary.each_date do |date| referer_write_from_diary( fh, diary ) end end end |
#referer_today ⇒ Object
05referer.rb: Japanese resource of referer plugin
Copyright © 2006, TADA Tadashi <[email protected]> You can redistribute it and/or modify it under GPL2 or any later version.
8 |
# File 'lib/tdiary/plugin/en/05referer.rb', line 8 def referer_today; "Today's Links"; end |
#referer_update(diary) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/tdiary/plugin/05referer.rb', line 105 def referer_update( diary ) # ignore an invalid URL including a non-ASCII character return if @cgi.referer && !@cgi.referer.match(/^[!-~]+$/) @referer_volatile = RefererDiary::new( @conf.latest_limit ) case @mode when 'latest' if @cgi.referer and !@conf.referer_day_only then referer_load_volatile( @referer_volatile ) referer_save_volatile( @referer_volatile, @cgi.referer ) end when 'day' if diary referer_load_current( diary ) referer_save_current( diary, @cgi.referer ) if latest_day?( diary ) then referer_load_volatile( @referer_volatile ) elsif @cgi.referer referer_load_volatile( @referer_volatile ) referer_save_volatile( @referer_volatile, @cgi.referer ) end end when "edit" referer_load_current( diary ) referer_load_volatile( @referer_volatile ) if latest_day?( diary ) when /^(append|replace)$/ referer_load_volatile( @referer_volatile ) @referer_volatile.clear_oldest_referer( @date.strftime( '%Y%m%d' ) ) referer_save_volatile( @referer_volatile, nil ) end end |
#referer_volatile_file_name ⇒ Object
145 146 147 |
# File 'lib/tdiary/plugin/05referer.rb', line 145 def referer_volatile_file_name "#{@conf.data_path}volatile.tdr" end |
#referer_write_from_diary(fh, diary) ⇒ Object
197 198 199 200 201 202 203 |
# File 'lib/tdiary/plugin/05referer.rb', line 197 def referer_write_from_diary( fh, diary ) fh.puts( "Date: #{diary.date.strftime( '%Y%m%d' )}\n\n" ) diary.each_referer( diary.count_referers ) do |count,ref| fh.puts( "#{count} #{ref}" ) end fh.puts( '.' ) end |
#robot_control ⇒ Object
422 423 424 425 426 427 428 |
# File 'lib/tdiary/plugin/00default.rb', line 422 def robot_control if /^form|edit|preview|showcomment$/ =~ @mode then '<meta name="robots" content="noindex,nofollow">' else '' end end |
#saveconf_comment ⇒ Object
comments
839 840 841 842 843 844 845 846 847 848 |
# File 'lib/tdiary/plugin/00default.rb', line 839 def saveconf_comment if @mode == 'saveconf' then @conf.show_comment = @cgi.params['show_comment'][0] == 'true' ? true : false @conf.comment_limit = @cgi.params['comment_limit'][0].to_i @conf.comment_limit = 3 if @conf.comment_limit < 1 @conf.comment_limit_per_day = @cgi.params['comment_limit_per_day'][0].to_i @conf.comment_limit_per_day = 0 if @conf.comment_limit_per_day < 0 end end |
#saveconf_csrf_protection ⇒ Object
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
# File 'lib/tdiary/plugin/00default.rb', line 850 def saveconf_csrf_protection if @mode == 'saveconf' then err = nil check_method = 0 case @cgi.params['check_enabled'] when ['true'] else err = :param end case @cgi.params['check_referer'] when ['true'] check_method |= 1 when ['false'] check_method |= 0 else err = :param end case @cgi.params['check_key'] when ['true'] check_method |= 2 when ['false'] check_method |= 0 else err = :param end err = :param if check_method == 0 check_key = '' key_seed = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 1.upto(30) do check_key << key_seed[rand( key_seed.length )] end if check_method & 2 != 0 && (!check_key || check_key == '') then err ||= :key end unless err old_key = @conf['csrf_protection_key'] old_method = @conf['csrf_protection_method'] @conf['csrf_protection_method'] = check_method @conf['csrf_protection_key'] = check_key if (check_method & 2 == 2 && (old_method & 2 == 0 || old_key != check_key)) @conf.save raise ForceRedirect, "#{h @conf.update}?conf=csrf_protection#{@cgi.referer ? '&referer_exists=true' : ''}" end end err else nil end end |
#saveconf_default ⇒ Object
basic (default)
743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
# File 'lib/tdiary/plugin/00default.rb', line 743 def saveconf_default if @mode == 'saveconf' then @conf.html_title = @conf.to_native( @cgi.params['html_title'][0] ) @conf. = @conf.to_native( @cgi.params['author_name'][0] ) @conf. = @cgi.params['author_mail'][0] @conf.index_page = @cgi.params['index_page'][0] @conf.description = @conf.to_native( @cgi.params['description'][0] ) @conf.icon = @cgi.params['icon'][0] @conf. = @cgi.params['banner'][0] @conf['base_url'] = @cgi.params['base_url'][0] @conf. = @cgi.params['x_frame_options'][0] @conf. = nil if @conf..empty? end end |
#saveconf_display ⇒ Object
diaplay
767 768 769 770 771 772 773 774 775 776 |
# File 'lib/tdiary/plugin/00default.rb', line 767 def saveconf_display if @mode == 'saveconf' then @conf.section_anchor = @conf.to_native( @cgi.params['section_anchor'][0] ) @conf.comment_anchor = @conf.to_native( @cgi.params['comment_anchor'][0] ) @conf.date_format = @conf.to_native( @cgi.params['date_format'][0] ) @conf.latest_limit = @cgi.params['latest_limit'][0].to_i @conf.latest_limit = 10 if @conf.latest_limit < 1 @conf.show_nyear = @cgi.params['show_nyear'][0] == 'true' ? true : false end end |
#saveconf_header ⇒ Object
header/footer (header)
759 760 761 762 763 764 |
# File 'lib/tdiary/plugin/00default.rb', line 759 def saveconf_header if @mode == 'saveconf' then @conf.header = @conf.to_native( @cgi.params['header'][0] ).lines.map(&:chomp).join( "\n" ).sub( /\n+\z/, '' ) @conf. = @conf.to_native( @cgi.params['footer'][0] ).lines.map(&:chomp).join( "\n" ).sub( /\n+\z/, '' ) end end |
#saveconf_logger ⇒ Object
903 904 905 906 907 |
# File 'lib/tdiary/plugin/00default.rb', line 903 def saveconf_logger if @mode == 'saveconf' then @conf['log_level'] = @cgi.params['log_level'][0] end end |
#saveconf_recommendfilter ⇒ Object
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 |
# File 'lib/tdiary/plugin/00default.rb', line 925 def saveconf_recommendfilter if @mode == 'saveconf' && @cgi.params['recommend.filter'][0] == 'true' then @conf['sf.selected'] = "" @conf['comment_description'] = "ツッコミ・コメントがあればどうぞ! URIは1つまで入力可能です。" if @sp_path.inject(false){|r, dir| r || FileTest.exist?("#{dir}/hide-mail-field.rb") } if @conf['sp.selected'] @conf['sp.selected'].concat("hide-mail-field.rb\n") else @conf['sp.selected'] = "hide-mail-field.rb\n" end @conf['spamfilter.bad_mail_patts'] = "@" @conf['comment_description'].concat("spam対策でE-mail欄は隠してあります。もしE-mail欄が見えていても、何も入力しないで下さい。") end @conf['spamfilter.bad_comment_patts'] = "href=\r\nurl=\r\nURL=\r\n" @conf['spamfilter.bad_ip_addrs'] = "" @conf['spamfilter.bad_uri_patts'] = "" @conf['spamfilter.bad_uri_patts_for_mails'] = false @conf['spamfilter.date_limit'] = "7" @conf['spamfilter.debug_file'] = "" @conf['spamfilter.debug_mode'] = false @conf['spamfilter.filter_mode'] = false @conf['spamfilter.hide_commentform'] = true @conf['spamfilter.linkcheck'] = 1 @conf['spamfilter.max_rate'] = "0" @conf['spamfilter.max_uris'] = "1" @conf['spamfilter.resolv_check'] = true @conf['spamfilter.resolv_check_mode'] = false @conf['spamlookup.domain.list'] = "bsb.spamlookup.net\r\nmulti.surbl.org\r\nrbl.bulkfeeds.jp" @conf['spamlookup.ip.list'] = "dnsbl.spam-champuru.livedoor.com" @conf['spamlookup.safe_domain.list'] = "www.google.com\r\nwww.google.co.jp\r\nezsch.ezweb.ne.jp\r\nwww.yahoo.co.jp\r\nsearch.mobile.yahoo.co.jp\r\nwww.bing.com" end end |
#saveconf_referer ⇒ Object
referer preference
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/tdiary/plugin/05referer.rb', line 265 def saveconf_referer if @mode == 'saveconf' then @conf.show_referer = @cgi.params['show_referer'][0] == 'true' ? true : false no_referer2 = [] @conf.to_native( @cgi.params['no_referer'][0] ).lines.each do |ref| ref.strip! no_referer2 << ref if ref.length > 0 end @conf.no_referer2 = no_referer2 only_volatile2 = [] @conf.to_native( @cgi.params['only_volatile'][0] ).lines.each do |ref| ref.strip! only_volatile2 << ref if ref.length > 0 end @conf.only_volatile2 = only_volatile2 referer_table2 = [] @conf.to_native( @cgi.params['referer_table'][0] ).lines.each do |pair| u, n = pair.sub( /[\r\n]+/, '' ).split( /[ \t]+/, 2 ) referer_table2 << [u,n] if u and n end @conf.referer_table2 = referer_table2 end end |
#saveconf_theme ⇒ Object
824 825 826 827 828 829 830 831 832 833 834 835 836 |
# File 'lib/tdiary/plugin/00default.rb', line 824 def saveconf_theme if @mode == 'saveconf' then @conf.theme = @cgi.params['theme'][0] @conf.css = @cgi.params['css'][0] end @conf_theme_list = methods.inject([]) {|conf_theme_list, method| if /^theme_list_/ =~ method.to_s __send__(method, conf_theme_list) else conf_theme_list end }.sort.compact.uniq end |
#saveconf_timezone ⇒ Object
timezone
779 780 781 782 783 |
# File 'lib/tdiary/plugin/00default.rb', line 779 def saveconf_timezone if @mode == 'saveconf' then @conf.hour_offset = @cgi.params['hour_offset'][0].to_f end end |
#script_tag ⇒ Object
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/tdiary/plugin/00default.rb', line 382 def script_tag require 'uri' query = script_tag_query_string html = @javascripts.keys.sort.map {|script| async = @javascripts[script][:async] ? "async" : "" if URI(script).scheme or script =~ %r|\A//| %Q|<script src="#{script}" #{async}></script>| else %Q|<script src="#{js_url}/#{script}#{query}" #{async}></script>| end }.join( "\n\t" ) html << "\n" << <<-HEAD <script><!-- #{@javascript_setting.map{|a| "#{a[0]} = #{a[1]};"}.join("\n\t\t")} //--> </script> HEAD end |
#script_tag_query_string ⇒ Object
374 375 376 |
# File 'lib/tdiary/plugin/00default.rb', line 374 def script_tag_query_string "?#{TDIARY_VERSION}#{Time::now.strftime('%Y%m%d')}" end |
#sf_doc_url(file) ⇒ Object
url of the document
31 32 33 |
# File 'lib/tdiary/plugin/60sf.rb', line 31 def sf_doc_url( file ) "https://github.com/tdiary/tdiary-docs-#{@conf.lang}/wiki/#{CGI::escape( file )}" end |
#sf_filters ⇒ Object
142 143 144 |
# File 'lib/tdiary/plugin/60sf.rb', line 142 def sf_filters @sf_filters||[] end |
#sf_hash_from_dirs(dirs) ⇒ Object
hash of paths from array of dirs
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tdiary/plugin/60sf.rb', line 17 def sf_hash_from_dirs( dirs ) r = Hash.new dirs.each do |dir| Dir::glob( "#{dir}/*.rb" ).each do |path| filename = File.basename( path ) unless r[ filename ] then r[ filename ] = path end end end r end |
#sf_li_plugins(paths, is_checked) ⇒ Object
<li> list of plugins
36 37 38 39 40 41 42 43 44 |
# File 'lib/tdiary/plugin/60sf.rb', line 36 def sf_li_plugins( paths, is_checked ) r = '' paths.collect { |path| File.basename( path ) }.sort.each do |file| r += <<-_HTML <li><input name="#{SF_PREFIX}.#{h file}" type="checkbox" value="t"#{'checked' if is_checked}><a href="#{h sf_doc_url( file )}">#{h file}</a> _HTML end r end |
#sf_list_plugins(sf_opt) ⇒ Object
lists of plugins
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/tdiary/plugin/60sf.rb', line 47 def sf_list_plugins( sf_opt ) r = '' if ( sf_opt && !sf_opt.empty? ) then # categorize the available plugins used = Array.new notused = Array.new unknown = Array.new # File.basenmame needed to read option from 01sp.rb <= 1.10 selected_array = sf_option( 'selected' ) ? sf_option( 'selected').split( /\n/ ).collect{ |p| File.basename( p ) } : [] notselected_array = sf_option( 'notselected' ) ? sf_option( 'notselected').split( /\n/ ).collect{ |p| File.basename( p ) } : [] sf_opt.keys.each do |path| if selected_array.include?( path ) then used << path elsif notselected_array.include?( path ) then notused << path else unknown << path end end # list up r += @sf_label_please_select unless unknown.empty? then r += @sf_label_new r += "<ul>\n" r += sf_li_plugins( unknown, sf_option( 'usenew' ) ) r += "</ul>\n" end # selected plugins unless used.empty? then r += @sf_label_used r += "<ul>\n" r += sf_li_plugins( used, true ) r += "</ul>\n" end # not selected plugins unless notused.empty? then r += @sf_label_notused r += "<ul>\n" r += sf_li_plugins( notused, false ) r += "</ul>\n" end else r += @sf_label_noplugin end r end |
#sf_option(key) ⇒ Object
get plugin option
12 13 14 |
# File 'lib/tdiary/plugin/60sf.rb', line 12 def sf_option( key ) @conf["#{SF_PREFIX}.#{key}"] end |
#shorten(str, len = 120) ⇒ Object
‘shorten’ method cuts string length.
36 37 38 39 40 41 42 43 |
# File 'lib/tdiary/lang/en.rb', line 36 def shorten( str, length = 120 ) matched = str.gsub( /\n/, ' ' ).scan( /^.{0,#{length - 2}}/u )[0] unless $'.empty? matched + '..' else matched end end |
#sp_doc_url(file) ⇒ Object
url of the document
34 35 36 |
# File 'lib/tdiary/plugin/50sp.rb', line 34 def sp_doc_url( file ) "https://github.com/tdiary/tdiary-docs-#{@conf.lang}/wiki/#{CGI::escape( file )}" end |
#sp_hash_from_dirs(dirs) ⇒ Object
hash of paths from array of dirs
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tdiary/plugin/50sp.rb', line 20 def sp_hash_from_dirs( dirs ) r = Hash.new dirs.each do |dir| Dir::glob( "#{dir}/*.rb" ).each do |path| filename = File.basename( path ) unless r[ filename ] then r[ filename ] = path end end end r end |
#sp_li_plugins(paths, is_checked) ⇒ Object
<li> list of plugins
39 40 41 42 43 44 45 46 47 |
# File 'lib/tdiary/plugin/50sp.rb', line 39 def sp_li_plugins( paths, is_checked ) r = '' paths.collect { |path| File.basename( path ) }.sort.each do |file| r += <<-_HTML <li><input name="#{SP_PREFIX}.#{h file}" type="checkbox" value="t"#{'checked' if is_checked}><a href="#{h sp_doc_url( file )}">#{h file}</a> _HTML end r end |
#sp_list_plugins(sp_opt) ⇒ Object
lists of plugins
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/tdiary/plugin/50sp.rb', line 50 def sp_list_plugins( sp_opt ) r = '' if ( sp_opt && !sp_opt.empty? ) then # categorize the available plugins used = Array.new notused = Array.new unknown = Array.new # File.basenmame needed to read option from 01sp.rb <= 1.10 selected_array = sp_option( 'selected' ) ? sp_option( 'selected').split( /\n/ ).collect{ |p| File.basename( p ) } : [] notselected_array = sp_option( 'notselected' ) ? sp_option( 'notselected').split( /\n/ ).collect{ |p| File.basename( p ) } : [] sp_opt.keys.each do |path| if selected_array.include?( path ) then used << path elsif notselected_array.include?( path ) then notused << path else unknown << path end end # list up r += @sp_label_please_select unless unknown.empty? then r += @sp_label_new r += "<ul>\n" r += sp_li_plugins( unknown, sp_option( 'usenew' ) ) r += "</ul>\n" end # selected plugins unless used.empty? then r += @sp_label_used r += "<ul>\n" r += sp_li_plugins( used, true ) r += "</ul>\n" end # not selected plugins unless notused.empty? then r += @sp_label_notused r += "<ul>\n" r += sp_li_plugins( notused, false ) r += "</ul>\n" end else r += @sp_label_noplugin end r end |
#sp_option(key) ⇒ Object
get plugin option
15 16 17 |
# File 'lib/tdiary/plugin/50sp.rb', line 15 def sp_option( key ) @conf["#{SP_PREFIX}.#{key}"] end |
#spamfilter_conf_html ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/tdiary/plugin/en/10spamfilter.rb', line 8 def spamfilter_conf_html r = <<-HTML <h3>Basic filters</h3> <p>Which dou you want to do spam TSUKKOMI finally?<br> <select name="spamfilter.filter_mode"> <option value="true"#{" selected" if @conf['spamfilter.filter_mode']}>hide</option> <option value="false"#{" selected" unless @conf['spamfilter.filter_mode']}>dispose</option> </select> </p> <p>It is spam when TSUKKOMI body has URIs over this value.<br> <input type="text" name="spamfilter.max_uris" value="#{h @conf['spamfilter.max_uris']}" size="5"></p> <p>It is spam when percentage of URI charctors in TSUKKOMI body is over this value.<br> <input type="text" name="spamfilter.max_rate" value="#{h @conf['spamfilter.max_rate']}" size="5"></p> <p>It is spam when TSUKKOMI body has URIs match with these patterns.<br> <textarea name="spamfilter.bad_uri_patts" cols="60" rows="8">#{h( @conf['spamfilter.bad_uri_patts'] || '' )}</textarea></p> <p>It is spam when TSUKKOMI body matches with these patterns.<br> <textarea name="spamfilter.bad_comment_patts" cols="60" rows="8">#{h( @conf['spamfilter.bad_comment_patts'] || '' )}</textarea></p> <p>It is spam when mail address matches with these patterns.<br> <textarea name="spamfilter.bad_mail_patts" cols="60" rows="8">#{h( @conf['spamfilter.bad_mail_patts'] || '' )}</textarea></p> <p>Use patterns of URI for checking mail address.<br> <select name="spamfilter.bad_uri_patts_for_mails"> <option value="true"#{" selected" if @conf['spamfilter.bad_uri_patts_for_mails']}>ON</option> <option value="false"#{" selected" unless @conf['spamfilter.bad_uri_patts_for_mails']}>OFF</option> </select></p> <h3>Date</h3> <p>Javascript is used to display TSUKKOMI from into<br> <input type="text" name="spamfilter.date_limit" value="#{h @conf['spamfilter.date_limit']}" size="5">days before (null: no limit, 0: only today) </p> <h3>IP address filters</h3> <p>It is spam when sender IP address matches these patterns. You have to specify complete IP address or part of IP address ends by '.'.<br> <textarea name="spamfilter.bad_ip_addrs" cols="60" rows="8">#{h( @conf['spamfilter.bad_ip_addrs'] || '' )}</textarea></p> </p> <h3>Description of TSUKKOMI</h3> <p>Show messeges and spam conditions for your subscribers.<br><textarea name="comment_description" cols="70" rows="5">#{h comment_description}</textarea></p> HTML r << <<-HTML <h3>for Debug</h3> <p>Debug mode.<br> <select name="filter.debug_mode"> <option value="0"#{" selected" if @conf['filter.debug_mode'] == 0}>OFF</option> <option value="1"#{" selected" if @conf['filter.debug_mode'] == 1}>Only spam</option> <option value="2"#{" selected" if @conf['filter.debug_mode'] == 2}>Full</option> </select></p> HTML r end |
#style_howto ⇒ Object
link to HOWTO write diary
41 42 43 |
# File 'lib/tdiary/plugin/en/00default.rb', line 41 def style_howto %Q|/<a href="https://github.com/tdiary/tdiary-docs-en/wiki#{h @conf.style}Style">How to write</a>| end |
#submit_command ⇒ Object
other resources
539 540 541 542 543 544 545 |
# File 'lib/tdiary/plugin/00default.rb', line 539 def submit_command if @mode == 'form' or @cgi.valid?( 'appendpreview' ) then 'append' else 'replace' end end |
#submit_label ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/tdiary/plugin/en/00default.rb', line 82 def submit_label if @mode == 'form' or @cgi.valid?( 'appendpreview' ) then 'Append' else 'Replace' end end |
#subtitle_link(date, index, subtitle) ⇒ Object
506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
# File 'lib/tdiary/plugin/00default.rb', line 506 def subtitle_link( date, index, subtitle ) r = '' if date then r << "<a " r << %Q[name="p#{'%02d' % index}" ] if @anchor_name param = "#{date.strftime( '%Y%m%d' )}#p#{'%02d' % index}" titleattr = (not subtitle or subtitle.empty?) ? '' : %Q[ title="#{remove_tag( apply_plugin( subtitle )).gsub( /"/, """ )}"] r << %Q[href="#{h @conf.index}#{anchor param}"#{titleattr}>#{@conf.section_anchor}</a> ] end r << %Q[(#{h @author}) ] if @multi_user and @author and subtitle r << make_category_link( subtitle ) end |
#theme_list_local(list) ⇒ Object
806 807 808 809 810 811 812 813 814 |
# File 'lib/tdiary/plugin/00default.rb', line 806 def theme_list_local(list) Dir::glob( theme_paths_local ).sort.map {|dir| theme = dir.sub( %r[.*/theme/], '') next unless FileTest::file?( "#{dir}/#{theme}.css" ) name = theme.split( /_/ ).collect{|s| s.capitalize}.join( ' ' ) list << ["local/#{theme}",name] } list end |
#theme_paths_local ⇒ Object
820 821 822 |
# File 'lib/tdiary/plugin/00default.rb', line 820 def theme_paths_local [::TDiary::PATH, TDiary.server_root].map {|d| "#{d}/theme/*" } end |
#theme_url ⇒ Object
401 402 403 |
# File 'lib/tdiary/plugin/00default.rb', line 401 def theme_url @cgi.is_a?(RackCGI) ? 'assets' : 'theme' end |
#theme_url_local(theme) ⇒ Object
816 817 818 |
# File 'lib/tdiary/plugin/00default.rb', line 816 def theme_url_local(theme) "#{h theme_url}/#{h theme}/#{h theme}.css" end |
#title_of_day(date, title) ⇒ Object
437 438 439 440 441 442 443 444 445 |
# File 'lib/tdiary/plugin/00default.rb', line 437 def title_of_day( date, title ) r = <<-HTML <span class="date"> <a href="#{h @conf.index}#{anchor( date.strftime( '%Y%m%d' ) )}">#{date.strftime @conf.date_format}</a> </span> <span class="title">#{title}</span> HTML return r.gsub( /^\t+/, '' ).chomp end |
#title_tag ⇒ Object
header
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tdiary/plugin/en/00default.rb', line 11 def title_tag r = "<title>#{h @conf.html_title}" case @mode when 'day', 'comment' r << "(#{@date.strftime( '%Y-%m-%d' )})" if @date when 'month' r << "(#{@date.strftime( '%Y-%m' )})" if @date when 'form' r << '(Append)' when 'edit' r << '(Edit)' when 'preview' r << '(Preview)' when 'showcomment' r << '(TSUKKOMI Status Change Completed)' when 'conf' r << '(Preferences)' when 'saveconf' r << '(Preferences Changed)' when 'nyear' years = @diaries.keys.map {|ymd| ymd.sub(/^\d{4}/, "")} r << "(#{years[0].sub( /^(\d\d)/, '\1-')}[#{nyear_diary_label}])" if @date end r << '</title>' end |
#to_utf8(str, charset = nil) ⇒ Object
convert to UTF-8
725 726 727 |
# File 'lib/tdiary/plugin/00default.rb', line 725 def to_utf8( str, charset = nil ) @conf.to_native( str, charset ) end |
#trackback_today ⇒ Object
64 |
# File 'lib/tdiary/plugin/en/00default.rb', line 64 def trackback_today; "Today's TrackBacks"; end |
#trackback_total(total) ⇒ Object
65 |
# File 'lib/tdiary/plugin/en/00default.rb', line 65 def trackback_total( total ); "(Total: #{total})"; end |
#volatile_referer ⇒ Object
9 |
# File 'lib/tdiary/plugin/en/05referer.rb', line 9 def volatile_referer; "Links to old diaries"; end |