class Qwik::Action
Constants
- BOOK_SEARCH
- CALC_FLOAT_RE
- CALC_INT_RE
- CHRONOLOGY_HEIGHT
- CHRONOLOGY_WIDTH
- CLOUD_BASE_FONT_SIZE
- CLOUD_MAX_FONT_SIZE
- CSV_DIVIDE
- DEFAULT_DESCRIPTION
- D_ExtArchive
- D_ExtArchive_ja
- D_ExtBackup
- D_ExtBackup_ja
- D_ExtChronology
- D_ExtChronology_ja
- D_ExtFiles
- D_ExtFiles_ja
- D_ExtHistory
- D_ExtHistory_ja
- D_ExtPresen
- D_ExtPresen_ja
- D_ExtRedirect
- D_ExtRedirect_ja
- D_ExtWysiwyg
- D_ExtWysiwyg_ja
- D_PluginBasic
- D_PluginBasic_ja
- D_PluginBook
- D_PluginBook_ja
- D_PluginCalc
- D_PluginCalc_ja
- D_PluginChristel
- D_PluginChristel_ja
- D_PluginCode
- D_PluginCode_ja
- D_PluginComment
- D_PluginComment_ja
- D_PluginCounter
- D_PluginCounter_ja
- D_PluginDiary
- D_PluginDiary_ja
- D_PluginEmbedHtml
- D_PluginEmbedHtml_ja
- D_PluginInclude
- D_PluginInclude_ja
- D_PluginInterWiki
- D_PluginInterWiki_ja
- D_PluginKeywords
- D_PluginKeywords_ja
- D_PluginMap
- D_PluginMenu
- D_PluginMenu_ja
- D_PluginPassword
- D_PluginPassword_ja
- D_PluginPlan
- D_PluginPlan_ja
- D_PluginPovray
- D_PluginPovray_ja
- D_PluginRuby
- D_PluginSample
- D_PluginSample_ja
- D_PluginSchedule
- D_PluginSearch
- D_PluginSearch_ja
- D_PluginSmil
- D_PluginStyle
- D_PluginStyle_ja
- D_PluginTable
- D_PluginTable_ja
- D_PluginTextarea
- D_PluginTextarea_ja
- D_PluginWebService
- D_PluginWebService_ja
- D_PluginWema
- D_PluginWema_ja
- D_QwikWeb
- D_QwikWebLogin
- D_QwikWebLogin_ja
- D_QwikWeb_ja
- D_SiteBackup
- D_SiteBackup_ja
- D_SiteLog
- D_SiteLog_ja
- D_SiteManagement
- D_SiteManagement_ja
- D_SiteTheme
- D_SiteTheme_ja
- D_TextFormat
- D_TextFormatSimple
- D_TextFormatSimple_ja
- D_TextFormat_ja
- D_christel
- D_code
- FILES_FORCE_DOWNLOAD
- GOOGLE_MAPS_API_KEY_FILE
- HIRAGANA
- ICON_GENRE_TABLE
- ICON_MIMETYPE_TABLE
- ICON_SUF_TABLE
icon¶ ↑
- IGNORE_PLUGINS
- INVALID_CSS_INDICATOR
- ISBN_LINK
- JAVASCRIPT_FILES
JAVASCRIPT_FILES
= %w(prototype scriptaculous base niftypp debugwindow)- KANJI
- LICENSE
- MAX_COLS
- MAX_PAGE_SIZE
- MAX_ROWS
- MIN_COLS
- MIN_ROWS
- MODULOBE_MODEL_STYLE
model¶ ↑
- MONTA_SCRIPT
- MONTA_STYLE
monta¶ ↑
- MV_CMD
POVRAY_CMD
= ‘/usr/local/bin/povray’- NotNecessary_D_ExtDescribe
- NotNecessary_D_ExtDescribe_ja
- NotUse_D_ExtRing
- NotYet_D_ExtMember
- NotYet_D_PluginListEdit
- NotYet_D_site_config
- PATTERN_EUC
- PATTERN_SJIS
- PLG_LIST_SCRIPT
- POVRAY_CMD
- PRESEN_DEFAULT_THEME
ext_presen
¶ ↑- PRESEN_THEME_IGNORE_DIR
- REPLACE_TOC
- RE_EUC
- RE_SJIS
- RING_CATALOG
- RING_CATALOG_CONTENT
- RING_INVITE_MAIL_TEMPLATE
- RING_INVITE_MEMBER
- RING_MEMBER
common¶ ↑
- RING_PAGE_TEMPLATE
- SITE_CONFIG
- SITE_THEME
site theme¶ ↑
- TEXTAREA_MAX_COLS
- TEXTAREA_MAX_ROWS
- TEXTAREA_MIN_COLS
- TEXTAREA_MIN_ROWS
- THEME_FILE
- THEME_IGNORE_DIR
- TYPEKEY_SITETOKEN_FILE
Public Class Methods
# File vendor/qwik/lib/qwik/act-edit.rb, line 164 def self.editor_generate(template, title, h1, message, main, sidebar) w = template.get_tag('head') # insert title w.insert(1, [:title, title]) # insert JavaScript js = generate_js w.insert(w.length, *js) # insert meta w << [:meta, {:name=>'ROBOTS', :content=>'NOINDEX,NOFOLLOW'}] # insert h1 w = template.get_tag('h1') #w << title w << h1 # insert message w = template.get_by_class('message') w << message # insert main w = template.get_by_class('main') w.insert(2, *main) # insert sidebar w = template.get_by_class('sidebar') w.insert(2, *sidebar) return template end
# File vendor/qwik/lib/qwik/common-plugin.rb, line 49 def self.from_local?(h) if h == 'localhost' || h == '127.0.0.1' || /\A\w+\z/ =~ h || /\A192\.168\..+\z/ =~ h || /\A150\.29\.151/ =~ h || /\A61\.193\.236/ =~ h return true end return false end
# File vendor/qwik/lib/qwik/common-javascript.rb, line 12 def self.generate_js return JAVASCRIPT_FILES.map {|f| generate_script("js/#{f}") } end
# File vendor/qwik/lib/qwik/act-code.rb, line 99 def self.generate_png(str) return nil if ! $have_gd font, fw, fh = GD::Font::TinyFont, 5, 8 str = str.to_s width = fw * str.length height = fh img = GD::Image.new(width, height) white = img.colorAllocate(255, 255, 255) color = img.colorAllocate(127, 127, 127) img.transparent(white) img.string(font, 0, 0, str, color) return img.pngStr end
# File vendor/qwik/lib/qwik/common-javascript.rb, line 18 def self.generate_script(f) return [:script, {:type=>'text/javascript', :src=>".theme/#{f}.js"}, ''] end
# File vendor/qwik/lib/qwik/act-attach.rb, line 64 def self.get_basename(filename) basename = filename.sub(/\A.*[\/\\]([^\/\\]+)\z/) { $1 } return basename end
# File vendor/qwik/lib/qwik/act-html.rb, line 81 def self.html_page_cache_path(dirpath, pagename) return (dirpath+"#{pagename}.html").cleanpath end
# File vendor/qwik/lib/qwik/act-html.rb, line 77 def self.html_page_cache_store(dirpath, pagename, str) Action.html_page_cache_path(dirpath, pagename).write(str) # Write to file. end
# File vendor/qwik/lib/qwik/act-list.rb, line 211 def self.list_arrange(content, item_list) tokens = TextTokenizer.tokenize(content) new_tokens = [] item_list.each {|item_num| new_tokens << tokens[item_num - 1] } return tokens_to_s(new_tokens) end
# File vendor/qwik/lib/qwik/act-list.rb, line 153 def self.list_edit(content, item_num, value) tokens = TextTokenizer.tokenize(content) index = 1 # list index starts with 1 tokens.each_element(:ul) {|token| if index == item_num token[2] = value # Destructive. end index += 1 } return tokens_to_s(tokens) end
# File vendor/qwik/lib/qwik/action.rb, line 52 def initialize @config = @memory = @req = @res = nil end
# File vendor/qwik/lib/qwik/act-keywords.rb, line 80 def self.nodes_get(content) content.set_sjis euc_content = content.to_euc tagger = MeCab::Tagger.new([$0]) n = tagger.parseToNode(euc_content) nodes = [] while n.hasNode != 0 surface = n.getSurface.set_euc.to_sjis feature = n.getFeature.set_euc.to_sjis if ! surface.empty? && RE_SJIS =~ surface && /\A([ぁ-んー~]+)\z/ !~ surface && /\A[.→、。]/ !~ surface && /\A[,←]/ !~ surface # /\A[ 0-9→「」()、。]/s !~ surface nodes << [surface, feature] end n = n.next end return nodes end
# File vendor/qwik/lib/qwik/common-notice.rb, line 38 def self.notice_generate(template, title, msg, url=nil, redirectflag=false, sec=0) w = template.get_tag('head') # insert title w.insert(1, [:title, title]) # insert JavaScript js = generate_js w.insert(w.length, *js) # insert meta w << [:meta, {:name=>'ROBOTS', :content=>'NOINDEX,NOFOLLOW'}] if url && ! redirectflag # redirect w << [:meta, {'http-equiv'=>'Refresh', :content=>"#{sec}; url=#{url}"}] end # insert h1 w = template.get_tag('h1') w << title # insert section w = template.get_by_class('section') w << msg template end
# File vendor/qwik/lib/qwik/act-list.rb, line 204 def self.parse_list(list) return list.map {|item| /\A(\d+)_(\d+)\z/ =~ item $2.to_i } end
# File vendor/qwik/lib/qwik/act-calc.rb, line 197 def self.parse_num(str) return [nil, 0, nil] if str.empty? return [nil, nil, nil] if /\A[^0-9]+\z/ =~ str # no number prefix = suffix = nil if /\A([^-0-9]+)[0-9]/ =~ str prefix = $1 str = str.sub($1, '') end if /[0-9]([^0-9]+)\z/ =~ str suffix = $1 str = str.sub($1, '') end if /[^-.,0-9]/ =~ str return [nil, nil, nil] end i = str.to_i f = str.to_f n = (f-i) == 0 ? i : f return [prefix, n, suffix] end
# File vendor/qwik/lib/qwik/common-plain.rb, line 30 def self.plain_generate(template, title, msg) w = template.get_tag('head') # insert title w.insert(1, [:title, title]) # insert JavaScript js = generate_js w.insert(w.length, *js) # insert meta w << [:meta, {:name=>'ROBOTS', :content=>'NOINDEX,NOFOLLOW'}] # insert h1 w = template.get_tag('h1') w << title # insert main w = template.get_by_class('main') w << msg template end
# File vendor/qwik/lib/qwik/common-plugin.rb, line 36 def self.plugin_parse_args(param) args = CSVTokenizer.csv_split(param) args.collect! {|a| case a when /\A'(.+)'$/, /^"(.+)"\z/ $1 else a end } args end
# File vendor/qwik/lib/qwik/act-html.rb, line 57 def self.private_page?(pagename) return pagename[0] == ?_ end
# File vendor/qwik/lib/qwik/act-ring.rb, line 186 def self.ring_invite_parse_guest_mails(guest_mails) guest_mail_ar = [] guest_mails.each {|line| line.chomp! line.sub!(/\A\s+/, "") line.sub!(/\s+\z/, "") line.sub!(/,\z/, "") guest_mail = line next unless MailAddress.valid?(guest_mail) guest_mail_ar << guest_mail } return guest_mail_ar end
# File vendor/qwik/lib/qwik/act-schedule.rb, line 59 def self.schedule_default_content(now) content = '' date = 'Date' content << "|#{date}|A|B|C|D|E\n" 5.times {|n| theday = Time.at(now.to_i + (n+1) * (60*60*24)) ymd = theday.ymd content << "|#{ymd}|||||\n" } return content end
# File vendor/qwik/lib/qwik/act-calc.rb, line 84 def self.tab_to_table(str) table = [:table] str.each {|line| ff = line.chomp.split(/\t/) next if ff.empty? tr = [:tr] ff.each {|f| tr << [:td, f] } table << tr } return nil if table.length == 1 return table end
# File vendor/qwik/lib/qwik/act-calc.rb, line 99 def self.table_calc(table) sum = Array.new(0) #pp table WabisabiTable.each_td(table) {|td, col, row| t = td[1] prefix, n, suffix = Action.parse_num(t) if n #qp col, n sum[col] ||= 0 sum[col] += n end } max_col = WabisabiTable.max_col(table) tr = [:tr, {:class=>'sum'}] max_col.times {|n| s = sum[n] ss = '' ss = s.to_s if s tr << [:td, ss] } table << tr return table end
# File vendor/qwik/lib/qwik/act-table.rb, line 76 def self.table_default_content content = '' content << "||A|B|C|D|E\n" (1..5).each {|n| content << "|#{n}||||||\n" } return content end
# File vendor/qwik/lib/qwik/act-tag.rb, line 21 def self.tag_get_pages(site) pages = Hash.new {|h, k| h[k] = []} site.each {|page| tags = page.get_tags next if tags.nil? tags.each {|tag| pages[tag] << page.key } } return pages end
# File vendor/qwik/lib/qwik/act-list.rb, line 165 def self.tokens_to_s(tokens) token_str = '' tokens.each_element(:ul) {|token| level_s = '-' * token[1] token_str << "#{level_s} #{token[2]}\n" } return token_str end
# File vendor/qwik/lib/qwik/act-wysiwyg.rb, line 173 def self.wysiwyg_editor(w) # The attribute 'contenteditable' makes it editable. Only works in IE. return [:div, {:id=>'weditor', :contenteditable=>'true'}, w] end
# File vendor/qwik/lib/qwik/act-wysiwyg.rb, line 178 def self.wysiwyg_form(pagename, md5hex, debug=false) #debug = true div = [:div] div << {:style=>'display:none;'} if ! debug div << [:form, {:action=>pagename+'.wysiwyg', :method=>'POST', :name=>'wform', :id=>'wform'}, [:input, {:type=>'submit', :value=>'Submit'}], [:input, {:type=>'text', :name=>'mode', :value=>'save'}], [:input, {:type=>'text', :name=>'md5hex', :value=>md5hex}], [:textarea, {:name=>'wtext', :id=>'wtext'}, '']] return div end
# File vendor/qwik/lib/qwik/act-wysiwyg.rb, line 119 def self.wysiwyg_generate(pagename, w, md5hex, debug) s = [:div, {:class=>'section'}] s << [:style, "@import '.theme/css/wema.css';"] s << wysiwyg_toolbar(pagename) s << wysiwyg_editor(w) # important s << wysiwyg_form(pagename, md5hex, debug) s << [:script, {:type=>'text/javascript', :src=>'.theme/js/wysiwyg.js'}, ''] div = [:div, {:class=>'wysiwyg'}, [:div, {:class=>'day'}, s]] return div end
# File vendor/qwik/lib/qwik/act-wysiwyg.rb, line 131 def self.wysiwyg_toolbar(pagename) div = [:div, {:class=>'toolbar'}, [:a, {:href=>'javascript:wysiwyg_save()'}, [:img, {:alt=>'Save', :src=>'.theme/i/action_save.gif'}]], [:input, {:type=>'checkbox', :name=>'autosave', :title=>'Auto-save'}], [:a, {:href=>"javascript:wysiwyg_command('bold')"}, [:img, {:alt=>'Bold', :src=>'.theme/i/text_bold.png'}]], [:a, {:href=>"javascript:wysiwyg_command('italic')"}, [:img, {:alt=>'Italic', :src=>'.theme/i/text_italic.png'}]], [:a, {:href=>"javascript:wysiwyg_command('InsertUnorderedList')"}, [:img, {:alt=>'UL', :src=>'.theme/i/text_list_bullets.png'}]], [:a, {:href=>"javascript:wysiwyg_command('InsertOrderedList')"}, [:img, {:alt=>'OL', :src=>'.theme/i/text_list_numbers.png'}]], [:a, {:href=>"javascript:wysiwyg_markup('h2')"}, [:img, {:alt=>'H2', :src=>'.theme/i/text_heading_2.png'}]], [:a, {:href=>"javascript:wysiwyg_markup('h3')"}, [:img, {:alt=>'H3', :src=>'.theme/i/text_heading_3.png'}]], [:a, {:href=>"javascript:wysiwyg_markup('h4')"}, [:img, {:alt=>'H4', :src=>'.theme/i/text_heading_4.png'}]], [:a, {:href=>"javascript:wysiwyg_command('CreateLink')"}, [:img, {:alt=>'Link', :src=>'.theme/i/icon_link.gif'}]], [:a, {:href=>'javascript:wysiwyg_image()'}, [:img, {:alt=>'Image', :src=>'.theme/i/image.gif'}]], [:a, {:href=>'javascript:wysiwyg_deleteTags()'}, [:img, {:alt=>'Normal', :src=>'.theme/i/text_align_justify.png'}]], [:span, {:class=>'wupdate_here'}, [:a, {:href=>"#{pagename}.wysiwyg"}, [:img, {:alt=>'Update', :src=>'.theme/i/action_refresh_blue.gif'}]]], [:input, {:type=>'checkbox', :name=>'autoupdate', :title=>'Auto update'}], ] return div end
Public Instance Methods
catalog¶ ↑
# File vendor/qwik/lib/qwik/act-ring.rb, line 45 def _r(text) catalog = ring_catalog t = catalog[text] return t if t # Try to reload. @memory[:ring_catalog] = ring_generate_catalog catalog = ring_catalog t = catalog[text] return t if t #raise if @config.test # Only for test. return text.to_s # abandon end
# File vendor/qwik/lib/qwik/act-aa.rb, line 34 def aa_database aa = {} msg = {} aa['smile'] = '(^_^) $1' msg['smile'] = 'Hi!' aa['モナー'] = ' ∧_∧ / ̄ ̄ ̄ ̄ ̄ ( ´∀`)< $1 ( ) \_____ | | | (__)_) ' msg['モナー'] = 'オマエモナー' aa['クマァ'] = ' 〇_〇 ( ・(ェ)・) <$1 /J ▽J し―-J ' msg['クマァ'] = 'クマァ!' return [aa, msg] end
# File vendor/qwik/lib/qwik/act-aa.rb, line 19 def aa_get(type=nil, message=nil) if type.nil? raise unless block_given? return yield end aa, msg = aa_database a = aa[type] raise 'no such aa' if a.nil? m = msg[type] m = message if message a = a.gsub(/\$1/) { m } return a end
# File vendor/qwik/lib/qwik/act-attach.rb, line 10 def act_attach if @req.query['c'] == 'del' c_require_member filename = @req.query['f'] return attach_delete(filename) if @req.is_post? # delete it return attach_delete_confirm(filename) # confirm before delete end args = @req.path_args if 0 < args.length # has target file filename = args.join('/') filename.set_url_charset filename = Filename.decode(filename) if ! @site.attach.exist?(filename) return c_notfound(_('No such file')) end return attach_send_file(filename) # send it end content = @req.query['content'] return attach_put_file(filename, content) if content # show attach form and the list of files return attach_form_and_list end
# File vendor/qwik/lib/qwik/act-chronology.rb, line 26 def act_chronology c_require_pagename #c_require_member timeline = @site.timeline timeline.calc_history divs = chronology_make_divs(timeline) return chronology_show(divs) end
find the newest day.
# File vendor/qwik/lib/qwik/act-day.rb, line 14 def act_day timeline = @site.timeline timeline.calc_history #pp timeline max = timeline.site_max day = max.ymd_s @req.base = day return ext_day # return c_notice('max') { # day # } end
search word delete action
# File vendor/qwik/lib/qwik/act-searchwords.rb, line 27 def act_delete query = search_get_query if query @site.delete_search_word(query) end return c_notice("Deleted",@req.header["referer"]) { "deleted" } end
# File vendor/qwik/lib/qwik/act-describe.rb, line 77 def act_describe @req.base = DEFAULT_DESCRIPTION return ext_describe end
# File vendor/qwik/lib/qwik/act-media.rb, line 87 def act_encode rp = RealProducer.new(@config, @site) if 0 < @req.path_args.length # has target file filename = @req.path_args.shift if filename == 'all' t = Thread.new { each_movie_entry {|f| file = f.basename f = @site.attach.path(file) next unless f.exist? output = rp.output_file(file) output.dirname.check_directory next if output.exist? msg = StringIO.new rp.encode_file(f, output, msg) puts 'done', msg.string } } return c_notice('start encoding all') end file = filename.path f = @site.attach.path(filename) return c_notfound('File not found.') unless f.exist? output = rp.output_file(file) msg = StringIO.new t = Thread.new { rp.encode_file(f, output, msg) } return c_notice("start encoding: #{file.to_s}") end ul = [] each_movie_entry {|f| file = f.basename ar = [] ar << [:a, {:href=>c_relative_to_root(".encode/#{file}")}, file.to_s] output = rp.output_file(file) if output.exist? outbase = output.basename.to_s uri = URI(@config.public_url) url = "rtsp://#{uri.host}:554/#{rpath}#{@site.sitename}/#{outbase}" ar += [' [', [:a, {:href=>url}, outbase], ']'] end ul << [:li, ar] } if 0 < ul.length ul << [:li, [:a, {:href=>c_relative_to_root('.encode/all')}, 'encode all']] end return c_notice('movie file list') { [:ul, ul] } end
# File vendor/qwik/lib/qwik/act-sample.rb, line 102 def act_hello c_notice('hello, world!') { 'hi, there.' } end
# File vendor/qwik/lib/qwik/act-isearch.rb, line 28 def act_isearch query = @req.query['q'] if query.nil? || query.empty? search_form_page isearch_patch(@res.body) return end ar = @site.isearch(query) if ar.nil? || ar.empty? search_notfound_page(query) isearch_patch(@res.body) return end return isearch_result(@site, ar) end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 46 def act_list c_surface(_('Page List'), true) { [:div, {:class=>'day'}, [:div, {:class=>'section'}, plg_title_list]] } end
# File vendor/qwik/lib/qwik/act-media.rb, line 13 def act_media_server ms = MediaServer.new(@config) if 0 < @req.path_args.length # has target file filename = @req.path_args.shift file = filename.path if @req.query['delete'] == 'yes' output = ms.output_file(@site, file) return c_nerror("already deleted: #{file.to_s}") unless output.exist? output.unlink return c_notice("delete content: #{file.to_s}"){} end if filename == 'all' each_media_entry {|f| file = f.basename f = @site.attach.path(file) next unless f.exist? ms.publish_file(@site, f) } return c_notice('publish all') end f = @site.attach.path(filename) return c_notfound('File not found.') unless f.exist? ms.publish_file(@site, f) return c_notice("pulish the content: #{file.to_s}") end ul = [] each_media_entry {|f| file = f.basename ar = [] ar << [:a, {:href=>c_relative_to_root(".media_server/#{file}")}, file.to_s] output = ms.output_file(@site, file) if output.exist? outbase = output.basename.to_s uri = URI(@config.public_url) url = "rtsp://#{uri.host}:554/#{uri.path}#{@site.sitename}/#{outbase}" ar << ' [' << [:a, {:href=>url}, outbase] << '] ' url = [:a, {:href=>c_relative_to_root(".media_server/#{file}?delete=yes")}, 'delete'] ar << url end ul << [:li, ar] } if 0 < ul.length ul << [:li, [:a, {:href=>c_relative_to_root('.media_server/all')}, 'publish all']] end return c_notice('media server') {[:ul, ul]} end
# File vendor/qwik/lib/qwik/act-member.rb, line 26 def act_member_add if @req.query && tomail = @req.query['tomail'] return member_add_exec(tomail) end return member_add_form end
# File vendor/qwik/lib/qwik/act-member.rb, line 72 def act_member_list list = @site.member.list return c_notice(_('Member list')) { [[:ul] + list.sort.map {|user| [:li, user] }, [:p, _('Member'), ': ', list.length.to_s]] } end
# File vendor/qwik/lib/qwik/act-member.rb, line 81 def act_member_list_csv list = @site.member.list str = '' list.sort.each_with_index {|user, i| str += user+((i % CSV_DIVIDE == 0) ? "\n" : ', ') } return c_plain(_('Member list')) { [:div, {:class=>'day'}, [:h2, _('Member list')], [:form, {:action=>".member_list_csv"}, [:textarea, {:class=>'memberlist'}, str] ] ] } end
# File vendor/qwik/lib/qwik/act-new.rb, line 13 def act_new c_require_login # Check if the title is specified. title = @req.query['t'] return new_input_title if title.nil? || title.empty? # Parse page title. page_title, tags = Page.parse_title(title) # Check if the page title is here. return new_input_title if page_title.nil? || page_title.empty? # Check if the title is already exist. page = @site.get_by_title(page_title) return new_already_exist(page_title, page.key) if page # Check if the request is GET. return new_confirm(title) if ! @req.is_post? if Page.valid_as_pagekey?(page_title) key = page_title else key = @site.get_new_id end begin page = @site.create(key) # CREATE rescue PageExistError # FIXME: should retry? return new_already_exist(page_title, key) end c_make_log('create', key) # CREATE c_monitor("create#{key}") # CREATE page.store("* #{title}\n") # with tag url = "#{key}.edit" # create_rrefs(key) site_updated return c_notice(_('New page'), url, 201) { # 201, Created [[:h2, _('Created.')], [:p, [:a, {:href=>url}, _('Edit new page')]]] } end
# File vendor/qwik/lib/qwik/act-code.rb, line 82 def act_num return c_nerror if ! $have_gd args = @req.path_args return c_nerror if args.nil? || args.empty? filename = args.first return c_nerror unless /\A([0-9]+)\.png\z/ =~ filename str = $1 return c_nerror if 10 < str.length files = @site.files('FrontPage') if ! files.exist?(filename) png = Action.generate_png(str) files.put(filename, png) end path = files.path(filename) return c_simple_send(path, 'image/png') end
Make a new plan.
# File vendor/qwik/lib/qwik/act-plan.rb, line 94 def act_plan date = @req.query['date'] title = @req.query['title'] if date.nil? || date.empty? || title.nil? || title.empty? date_attr = {:name=>'date', :class => 'focus'} date_attr[:value] = @req.start_time.ymd_s date_attr[:value] = date if date && ! date.empty? title_attr = {:name=>'title'} title_attr[:value] = 'Plan' title_attr[:value] = title if title && ! title.empty? form = [:form, {:action=>'.plan', :method=>'POST'}, [:dl, [:dt, _('Date')], [:dd, [:input, date_attr]], [:dt, _('Title')], [:dd, [:input, title_attr]]], [:input, {:type=>'submit', :value=>_('Create a new plan')}]] return c_notice(_('New plan')) { [[:h2, _('New plan')], [:div, {:class=>'plan form'}, form]] } end # Create a new plan #page = @site.create_new # CREATE dateobj = Time.parse(date) pagename = "plan_#{dateobj.ymd_s}" page = @site[pagename] msg = _('Already Exists.') if page.nil? msg = _('Created.') page = @site.create(pagename) # CREATE page.store("* #{title}\n") # Specify title. end url = "#{page.key}.edit" return c_notice(_('New plan'), url, 201) { # 201, Created [[:h2, msg], [:p, [:a, {:href=>url}, _('Edit new page')]]] } end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 61 def act_recent(max = -1) str = recent_str(max) c_surface(_('Recent Changes'), true) { [:div, {:class=>'day'}, [:div, {:class=>'section'}, c_res(str)]] } end
# File vendor/qwik/lib/qwik/act-search.rb, line 52 def act_search query = search_get_query if query.nil? return search_form_page end ar = @site.search(query) if ar.empty? return search_notfound_page(query) end return search_result(@site, ar, query) end
# File vendor/qwik/lib/qwik/act-sendpass.rb, line 11 def act_sendpass c_require_member return sendpass_show_form if ! @req.is_post? status = {} members = @site.member.list @req.query.each {|mail, v| if ! MailAddress.valid?(mail) || v != 'on' status[mail] = _('Wrong format.') next end if ! members.include?(mail) status[mail] = _('Not a member.') next end passmail = generate_password_mail(mail) sendmail = Sendmail.new(@config.smtp_host, @config.smtp_port, @config.test) begin sendmail.send(passmail) status[mail] = _('Succeeded.') rescue status[mail] = _('Failed.') end } ar = [] status.each {|mail, result| ar << [:li, mail, ' : ', result.to_s] } return c_notice(_('Send Password done')) { [:ul, ar] } end
# File vendor/qwik/lib/qwik/act-site.rb, line 35 def act_site c_require_login return c_nerror("You are not administrator.") if ! is_administrator? farm = @memory.farm ul = [:ul] farm.list.each {|sitename| # next unless /\A[0-9]/ =~ sitename # site = farm.get_site(sitename) sitepath = "#{@config.sites_dir}/#{sitename}".path li = [:li] li << [:a, {:href=>"/#{sitename}/"}, "/#{sitename}/"] ul << li } div = [:div, {:class => 'day'}, [:div, {:class => 'section'}, [:h2, _("Site list.")], ul]] return c_plain(_("Site list. __qwik_page_generate_time__ sec. past.")) { div } end
sitelog viewer
# File vendor/qwik/lib/qwik/act-sitelog.rb, line 41 def act_sitelog return c_plain('SiteLog') { [:div, {:class=>'day'}, [:div, {:class=>'section'}, plg_sitelog]] } end
# File vendor/qwik/lib/qwik/act-status.rb, line 148 def act_status c_require_login return c_nerror("You are not administrator.") if ! is_administrator? str = "" now = @req.start_time str << status_get_date(now) ps = `ps auxww | grep -i ruby` str << status_get_memory(ps) str << "\n" str << status_show_httprequests(now) str << "\n" str << status_show_requests(now) str << "\n" str << status_get_objects # str << status_get_objects2 str << "\n" # return c_notice(_('Status')) { return c_plain(_('Status')) { [[:h2, _('Status')], # [:pre, str]] [:pre, c_pre_text { str }]] } end
only for check design
# File vendor/qwik/lib/qwik/act-edit.rb, line 23 def act_test_editor w = c_page_res('TextFormatSimple') generate_editor_page('act_test_editor', 'h1', w, w, w) end
Method for testing page design.
# File vendor/qwik/lib/qwik/common-notice.rb, line 11 def act_test_notice w = login_show_login_page('http://example.com/HelloQwik/') c_notice('act_test_notice') { w } end
For page design check.
# File vendor/qwik/lib/qwik/common-plain.rb, line 10 def act_test_plain w = c_page_res('TextFormat') c_plain('act_test_plain') { w } end
c_surface
¶ ↑
co/qwik/.test_surface Only for page design check.
# File vendor/qwik/lib/qwik/common-surface.rb, line 14 def act_test_surface w = c_page_res('TextFormat') c_surface('act_test_surface') { w } end
# File vendor/qwik/lib/qwik/action.rb, line 190 def action_go_login url = c_relative_to_root('.login') c_notice(_('Login'), url, 200, 1) { [:div, [:p, _('Please log in.')], [:p, login_create_login_link]] } end
# File vendor/qwik/lib/qwik/action.rb, line 209 def action_member_only_form(user, ml) c_nerror(_('Members Only')) { [:div, [:p, _('You are now logged in with this user id.'), [:br], [:strong, user]], [:p, _('This user with this ID is not a member of this group.'), [:br], [:strong, ml]], [:p, _('If you would like to log in on another account,'), [:br], _('please log out first.')], logout_form] } end
# File vendor/qwik/lib/qwik/action.rb, line 180 def action_no_such_site(sitename) c_notfound(_('No such site.')) { [:div, [:p, [:b, sitename], ' : ', _('No corresponding site.')], [:p , _('Please send mail to make a site')], [:p, [:a, {:href=>'http://qwik.jp/'}, 'qwik.jp'], _('Access here and see how to.')]] } end
# File vendor/qwik/lib/qwik/act-new.rb, line 103 def action_page_not_found # Assert that the title is encoded in UTF8. # @req.base.charset is already set to 'UTF-8' in request-path.rb title = @req.base.to_page_charset c_notfound(_('Page not found.')) { [[:h2, _('Page not found.')], [:p, [:a, {:href=>'FrontPage.html'}, _('Go back')]], [:hr], new_form(title) { [:p, _('Push create if you would like to create the page.')] } ] } end
action_page_not_found
is moved to act-new.rb
# File vendor/qwik/lib/qwik/action.rb, line 237 def action_require_base_is_sitename c_notfound(_('Not found.')) { [:h2, _('Not found.')] } end
# File vendor/qwik/lib/qwik/action.rb, line 199 def action_require_login c_nerror(_('Please log in.')) { [:div, [:p, _('You need to log in to use this function.')], [:p, login_create_login_link, ' : ' + _('Access here.')], [:hr], [:p, [:a, {:href=>'FrontPage.html'}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/action.rb, line 229 def action_require_no_path_args c_notfound(_('Incorrect path arguments.')) { [:h2, _('Path arguments are not acceptable.')] } end
# File vendor/qwik/lib/qwik/action.rb, line 222 def action_require_post c_nerror(_('Please input POST')) { [[:p, _('This function requires POST input.')], [:p, [:a, {:href=>'FrontPage.html'}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-archive.rb, line 61 def archive_clear_cache path = archive_path path.unlink if path.exist? path = archive_running_path path.unlink if path.exist? end
# File vendor/qwik/lib/qwik/act-archive.rb, line 53 def archive_path return @site.cache_path + "#{@site.sitename}.zip" end
# File vendor/qwik/lib/qwik/act-archive.rb, line 57 def archive_running_path return @site.cache_path + "#{@site.sitename}.zip.running" end
# File vendor/qwik/lib/qwik/act-attach.rb, line 129 def attach_delete(filename) c_require_post url = '.attach' begin filename.set_url_charset filename = Filename.decode(filename) @site.attach.delete(filename) rescue FileNotExist return c_nerror(_('Already deleted.'), url) rescue FailedToDelete return c_nerror(_('Failed to delete.'), url) end return c_notice(_('The file has been deleted.')) { [:p, [:a, {:href=>url}, _('Go back')]] } end
# File vendor/qwik/lib/qwik/act-attach.rb, line 119 def attach_delete_confirm(filename) return c_notice(_('Confirm file deletion')) { [:form, {:method=>'POST', :action=>'.attach'}, [:p, _("Push 'Delete' to delete a file")], [:input, {:type=>'hidden', :name=>'c', :value=>'del'}], [:input, {:type=>'hidden', :name=>'f', :value=>filename}], [:p, [:input, {:type=>'submit', :value=>_('Delete')}]]] } end
# File vendor/qwik/lib/qwik/act-attach.rb, line 106 def attach_file_list base = c_relative_to_root('.attach') list = [] @site.attach.each {|file| encoded = Filename.encode(file) list << [:li, [:a, {:href=>"#{base}/#{encoded}"}, file.to_page_charset], [:span, {:class=>'delete'}, ' (', [:a, {:href=>"#{base}?c=del&f=#{encoded}"}, _('Delete')], ')']] } return nil if list.length == 0 return list end
# File vendor/qwik/lib/qwik/act-attach.rb, line 98 def attach_form(a=nil) return [:form, {:action=>a, :method=>'post', :enctype=>'multipart/form-data'}, [:input, {:type=>'file', :name=>'content'}], [:br], [:input, {:type=>'submit', :value=>'attach'}]] end
# File vendor/qwik/lib/qwik/act-attach.rb, line 78 def attach_form_and_list c_require_member div = [] div << [:div, {:class=>'msg'}, [:p, _('Attach a file')], attach_form] list = attach_file_list if list div << [:br] div << [:div, {:class=>'msg'}, [:p, _('File list')], [:ul, list]] end return c_notice(_('Attach file')) { div } end
# File vendor/qwik/lib/qwik/act-attach.rb, line 43 def attach_put_file(filename, content) c_require_member c_require_post filename = content.filename basename = Action.get_basename(filename) basename.set_url_charset basename = Filename.decode(basename) res = basename res = @site.attach.fput(basename, content) attach_rewrite_page(res) backpage = '.attach' return c_notice(_('File attachment completed')) { [[:p, [:strong, res], ' : ', _('The file is saved.')], [:p, [:a, {:href=>backpage}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-attach.rb, line 69 def attach_rewrite_page(basename) page = @site[@req.base] v = page.load if /\{\{ref\}\}/ =~ v v.sub!(/\{\{ref\}\}/){ "{{ref(#{basename})}}" } # only once page.store(v) end end
# File vendor/qwik/lib/qwik/act-attach.rb, line 37 def attach_send_file(filename) @res.set_content_type(Filename.extname(filename)) file = @site.attach.path(filename) return c_simple_send(file.to_s) end
# File vendor/qwik/lib/qwik/act-backup.rb, line 113 def backup_diff(list, last, now) s1, t1 = list[last] s2, t2 = list[now] return DiffGenerator.generate(s1, s2) end
# File vendor/qwik/lib/qwik/act-backup.rb, line 105 def backup_list(site, key) list = [] site.backupdb.each_by_key(key) {|v, time| list << [v, time.to_i] } return list end
# File vendor/qwik/lib/qwik/act-backup.rb, line 119 def backup_list_page(site, key) list = backup_list(site, key) ul = list.map {|v, time| [:li, [:a, {:href=>"#{key}.#{time}.backup"}, Time.at(time).format_date]] } if 0 < ul.length ul.last << ' '+_('<-')+' '+ _('Newest') end return c_plain(_('Backup list')) { [:div, {:class=>'day'}, [:div, {:class=>'section'}, [:ul, ul]]] } end
# File vendor/qwik/lib/qwik/act-backup.rb, line 50 def backup_show(site, key, args) page = site[key] return c_nerror('only one time stamp') if 1 < args.length time = args.shift return c_nerror('should be number') unless /\A[0-9]+\z/ =~ time # Is the backup exist? time = Time.at(time.to_i) unless site.backupdb.exist?(key, time) return c_notfound('not found') end str = site.backupdb.get(key, time) # Get the old content. =begin # Do not show diffs for now. (2009/9/1) list = backup_list(site, key) # Get the list. # Get the index of the content. index = nil list.each_with_index {|a, i| if a[1] == time.to_i index = i end } return c_notfound('no data?') if index.nil? msg = '' if index == 0 msg = [:p, _('This is the first page.')] else # FIXME: fix diff function. (2009/9/1) diff = backup_diff(list, index-1, index) msg = [:div, {:class=>'differ'}, *diff] end return c_plain("#{key} @ #{time.ymdax}") { [[:div, {:class=>'day'}, [:h2, _('Difference from the previous page')], [:div, {:class=>'section'}, msg]], [:div, {:class=>'day'}, [:h2, _('Original data')], [:div, {:class=>'section'}, [:pre, str]]]] } =end return c_plain("#{key} @ #{time.ymdax}") { [[:div, {:class=>'day'}, [:h2, _('Original data')], [:div, {:class=>'section'}, [:pre, str]]]] } end
# File vendor/qwik/lib/qwik/act-httpauth.rb, line 60 def basicauth_logout return c_notice(_('Basic Authentication') + ' ' + _('Log out')) { [[:h2, _('Can not log out.')], [:p, _('You can not log out in Basic Authentication mode.'), [:br], _('Please close browser and access again.')], [:hr], [:p, [:a, {:href=>'FrontPage.html'}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/common-plugin.rb, line 10 def c_call_plugin(method, param, &b) args = nil args = Action.plugin_parse_args(param) if param && !param.empty? args ||= [] args.each {|s| s.set_page_charset } m = "plg_#{method}" begin return self.send(m, *args, &b) if self.respond_to?(m) return [:span, {:class=>'plg_error'}, 'nosuch plugin | ', [:strong, method]] rescue #raise if @config.test || @config.debug raise if @config.test h = @req.fromhost if Action.from_local?(h) return PrettyBacktrace.to_html($!) # common-backtrace else return [:span, {:class=>'plg_error'}, 'plugin error | ', [:strong, method]] end end end
# File vendor/qwik/lib/qwik/common-send.rb, line 13 def c_download(path) return SimpleSender.download(@req, @res, path.to_s, @config.test) end
# File vendor/qwik/lib/qwik/act-edit.rb, line 28 def c_editor(site, pagename, contents=nil, message=['']) page = site[pagename] page_title = page.get_title title = _('Edit')+' | '+page_title h1 = [_('Edit'), ' | ', [:a, {:href=>page.url}, page_title]] str = contents str = page.load if contents.nil? md5hex = str.md5hex edit_form = editor_edit_form(pagename, str, md5hex) attach_form, attach_list = editor_attach_form(pagename) main = editor_main(edit_form, attach_form, attach_list, pagename) ar = [] ar << editor_help_qwikweb ar << editor_help_edit ar << editor_page_functions(pagename) ar << editor_site_admin sidebar = editor_sidebar(*ar) generate_editor_page(title, h1, message, main, sidebar) end
# File vendor/qwik/lib/qwik/act-theme.rb, line 205 def c_fetch_by_url(url) uri = URI(url) return nil if uri.scheme != 'http' res = nil begin Net::HTTP.start(uri.host, uri.port) {|http| res = http.get(uri.path) } rescue return nil end return res.body end
# File vendor/qwik/lib/qwik/act-sitelog.rb, line 53 def c_make_log(cmd, pagename=@req.base) timestr = c_time_str @site.log(timestr, @req.user, cmd, pagename) end
# File vendor/qwik/lib/qwik/common-condition.rb, line 18 def c_member? c_login? && @site.member.exist?(@req.user) end
# File vendor/qwik/lib/qwik/common-error.rb, line 10 def c_nerror(title=_('Error'), url=nil, status=500, &b) #status = 200 if @config.test msg = title msg = yield if block_given? generate_notice_page(status, title, url, msg) end
# File vendor/qwik/lib/qwik/common-error.rb, line 17 def c_notfound(title=_('Not found.'), &b) return c_nerror(title, nil, 404, &b) end
# File vendor/qwik/lib/qwik/common-notice.rb, line 16 def c_notice(title, url=nil, status=200, sec=0, &b) msg = yield generate_notice_page(status, title, url, msg, sec) end
# File vendor/qwik/lib/qwik/common-notice.rb, line 21 def c_nredirect(title, url, &b) msg = '' msg = yield if block_given? c_set_location(c_relative_to_absolute(url)) generate_notice_page(302, title, url, msg) end
# File vendor/qwik/lib/qwik/resolve-tdiary.rb, line 14 def c_page_url page = @site[@req.base] return nil if page.nil? return page.url end
# File vendor/qwik/lib/qwik/common-res.rb, line 21 def c_parse(str) tokens = TextTokenizer.tokenize(str) return TextParser.make_tree(tokens) end
# File vendor/qwik/lib/qwik/common-plain.rb, line 15 def c_plain(title, status=200, &b) msg = yield generate_plain_page(status, title, msg) end
# File vendor/qwik/lib/qwik/act-text.rb, line 19 def c_pre_text str = yield tokens = TextTokenizer.tokenize(str, true) tree = TextParser.make_tree(tokens) w = Resolver.resolve(@site, self, tree) return w end
1.html -> example.com/test/1.html
# File vendor/qwik/lib/qwik/common-url.rb, line 19 def c_relative_to_absolute(url) if /\Ahttp:\/\// =~ url || /\Ahttps:\/\// =~ url return url # It's already absolute URL. end # make absolute url fromrootpath = c_relative_to_root(url) return "#{@site.host_url.chomp('/')}#{fromrootpath}" end
1.html -> /test/1.html
# File vendor/qwik/lib/qwik/common-url.rb, line 12 def c_relative_to_root(url) return url if /\A\// =~ url # It's already from root path. uri = URI(@config.public_url) return "#{uri.path}#{@site.url_path}#{url}" end
# File vendor/qwik/lib/qwik/common-condition.rb, line 47 def c_require_base_is_sitename raise BaseIsNotSitename if @req.base != @req.sitename end
# File vendor/qwik/lib/qwik/common-condition.rb, line 51 def c_require_lib(lib) begin require lib rescue raise "there is no #{lib} library" end end
# File vendor/qwik/lib/qwik/common-condition.rb, line 14 def c_require_login # You must logged in. raise RequireLogin unless c_login? end
# File vendor/qwik/lib/qwik/common-condition.rb, line 22 def c_require_member # You must be a member of this group. raise RequireMember unless c_member? end
# File vendor/qwik/lib/qwik/common-condition.rb, line 38 def c_require_no_ext_args raise 'no ext args' if 0 < @req.ext_args.length end
# File vendor/qwik/lib/qwik/common-condition.rb, line 34 def c_require_no_path_args raise RequireNoPathArgs if 0 < @req.path_args.length end
# File vendor/qwik/lib/qwik/common-condition.rb, line 30 def c_require_page_exist raise PageNotFound if @site[@req.base].nil? end
# File vendor/qwik/lib/qwik/common-condition.rb, line 42 def c_require_pagename raise 'pagename is nil' if @req.base.nil? # FIXME: But, pagename is always not nil for now. end
# File vendor/qwik/lib/qwik/common-condition.rb, line 26 def c_require_post raise RequirePost unless @req.is_post? end
# File vendor/qwik/lib/qwik/common-res.rb, line 26 def c_res(str) tokens = TextTokenizer.tokenize(str) tree = TextParser.make_tree(tokens) return Resolver.resolve(@site, self, tree) end
# File vendor/qwik/lib/qwik/common-basic.rb, line 41 def c_set_body(body) @res.body = body end
# File vendor/qwik/lib/qwik/common-basic.rb, line 27 def c_set_contenttype(contenttype="text/html; charset=Shift_JIS") @res['Content-Type'] = contenttype end
# File vendor/qwik/lib/qwik/common-basic.rb, line 37 def c_set_location(location) @res['Location'] = location end
# File vendor/qwik/lib/qwik/common-basic.rb, line 32 def c_set_no_cache(pragma='no-cache', control='no-cache') @res['Pragma'] = pragma @res['Cache-Control'] = control end
# File vendor/qwik/lib/qwik/common-send.rb, line 9 def c_simple_send(path, type=nil) return SimpleSender.send(@config, @req, @res, path.to_s, type) end
# File vendor/qwik/lib/qwik/common-surface.rb, line 19 def c_surface(title, patch=true, &b) msg = yield c_set_status c_set_contenttype c_set_no_cache body = surface_generate(title, msg, patch) c_set_body(body) end
# File vendor/qwik/lib/qwik/resolve-tdiary.rb, line 9 def c_tdiary_resolve(w) w = TDiaryResolver.resolve(@config, @site, self, w) return w end
# File vendor/qwik/lib/qwik/act-sitelog.rb, line 48 def c_time_str(time=nil) time ||= @req.start_time return sprintf('%.6f', time.to_i + time.usec/1000000.0) end
ref: webrick/httpauth.rb
# File vendor/qwik/lib/qwik/act-httpauth.rb, line 13 def check_basicauth auth = @req['Authorization'] return if auth.nil? return unless /^Basic\s+(.*)/o =~ auth user, pass = Base64.decode64($1).split(':', 2) return if user.nil? raise InvalidUserError if user.nil? || user.empty? raise InvalidUserError unless MailAddress.valid?(user) gen = @memory.passgen raise InvalidUserError if !gen.match?(user, pass) @req.user = user @req.auth = 'basicauth' return end
verify¶ ↑
called from act-login.rb:41
# File vendor/qwik/lib/qwik/common-session.rb, line 11 def check_session sid = @req.cookies['sid'] # get session id from cookie. return if sid.nil? || sid.empty? # return if you don't have session id. sdb = @memory.sessiondb user = sdb.get(sid) # Get user from SessionDB. return if user.nil? # return if there is no session id. @req.user = user # OK! I have your sesssion id. I know who you are. @req.auth = 'session' end
# File vendor/qwik/lib/qwik/act-chronology.rb, line 40 def chronology_make_divs(timeline) # height = times = timeline.times pages_history = timeline.pages_history page_min = timeline.page_min site_min = timeline.site_min site_duration = timeline.site_duration return [:p, "No files here."] if times.nil? page_num = times.length # Total page number return [:p, "No files here."] if page_num == 0 h_span = CHRONOLOGY_HEIGHT / page_num x_offset = 60 y_offset = 50 divs = [] num = 0 pages_history.each {|key| ar = times[key] pm_time = page_min[key] x = 10 y = y_offset + CHRONOLOGY_HEIGHT * num / page_num page = @site[key] next if page.nil? title = page.get_title url = page.url divs << [:div, {:title=>"#{title} | #{pm_time.ymd}", :class=>'time_title', :style=>"position:absolute;left:#{x}px;top:#{y}px;height:#{h_span}px;"}, [:a, {:href=>url}, title]] num += 1 ar.each {|time| past_time = time - site_min x = x_offset + (CHRONOLOGY_WIDTH-x_offset) * past_time / site_duration divs << [:div, {:title=>"#{title} | #{time.ymd}", :class=>'time_update', :style=>"left:#{x}px;top:#{y}px;width:10px;height:#{h_span}px;"}, [:a, {:href=>url}, '_']] } } return divs end
# File vendor/qwik/lib/qwik/act-chronology.rb, line 91 def chronology_show(divs) ar = [] ar << [:style, "@import '.theme/css/wema.css';"] ar << [:style, " .time_update { margin: 0; padding: 0; position: absolute; background-color: #6dd; border: 1px outset #9ff; } .time_update a { margin: 0; padding: 0; } "] section = [] section << [:div, {:id=>"chronology"}, ''] section << divs section << [:div, {:id=>'lines'}, ''] ar << [:div, {:class=>'day'}, [:div, {:class=>'section'}, section]] ar << [:script, {:type=>'text/javascript', :src=>'.theme/js/wema.js'}, ''] ar << [:script, {:type=>'text/javascript',:src=>'.theme/js/history.js'}, ''] title = _('Chronology') + " | #{@site.sitename}" return c_plain(title) { ar } end
# File vendor/qwik/lib/qwik/act-config.rb, line 25 def config_site @req.base = SITE_CONFIG # Fake. w = [] w << [:h1, _('Site Configuration')] w = c_res(content) w = TDiaryResolver.resolve(@config, @site, self, w) title = _('Function')+' | '+hash[:dt] return c_surface(title, true) { w } end
# File vendor/qwik/lib/qwik/act-counter.rb, line 62 def counter_increment_count pagename = @req.base counter_pagename = "_counter_#{pagename}" counter_page = @site[counter_pagename] if counter_page.nil? counter_page = @site.create(counter_pagename) counter_page.store('0') end counter_str = counter_page.load md5 = counter_str.md5hex counter_num = counter_str.to_i counter_num += 1 new_counter_str = counter_num.to_s #counter_page.store(counter_num.to_s) begin counter_page.put_with_md5(new_counter_str, md5) rescue PageCollisionError # Do nothing. end return counter_num end
# File vendor/qwik/lib/qwik/act-theme.rb, line 196 def css_get_by_url(url) # Add one more slash. url = url.sub(/\Ahttp:\//, 'http://') if /\Ahttp:\/[^\/]/ =~ url content = c_fetch_by_url(url) return nil if content.nil? return '/* invalid css */' if ! CSS.valid?(content) return content end
# File vendor/qwik/lib/qwik/act-theme.rb, line 179 def css_get_from_site_theme(filename) files = @site.files(SITE_THEME) return nil if files.nil? || ! files.exist?(filename) str = files.get(filename) return nil if str.nil? ext = filename.path.ext type = @res.get_mimetypes ext if type == 'text/css' str = INVALID_CSS_INDICATOR if ! CSS.valid?(str) return str, type elsif /\Aimage\// =~ type return str, type else return nil end end
# File vendor/qwik/lib/qwik/act-describe.rb, line 98 def description_get(name, langs=nil) langs = [] if langs.nil? langs << '' if ! langs.include?('') langs.each {|lang| lang.gsub!(/-/, '_') constname = "D_#{name}" constname = "D_#{name}_#{lang}" if ! lang.empty? if self.class.const_defined?(constname) return self.class.const_get(constname) end } return nil end
# File vendor/qwik/lib/qwik/act-describe.rb, line 55 def description_list(langs=nil) langs = [] if langs.nil? langs << '' if ! langs.include?('') list = [] self.class.constants.each {|constname| langs.each {|lang| if /\AD_([A-Za-z]+)_#{lang}\z/ =~ constname if ! list.include?($1) list << $1 end elsif /\AD_([A-Za-z]+)\z/ =~ constname if ! list.include?($1) list << $1 end end } } return list.sort end
# File vendor/qwik/lib/qwik/act-basic.rb, line 237 def descriptions_hash desc = {} description_list.each {|name| desc[name] = self.class.const_get("D_#{name}")[:dc] } return desc end
# File vendor/qwik/lib/qwik/act-media.rb, line 69 def each_media_entry path = @site.attach.path('') path.each_entry {|file| base = file.to_s next unless /\A(.+)\.rm\z/i =~ base yield(path+file) } end
# File vendor/qwik/lib/qwik/act-media.rb, line 78 def each_movie_entry path = @site.attach.path path.each_entry {|file| base = file.to_s next unless /\A(.+)\.avi\z/i =~ base || /\A(.+)\.mp4\z/i =~ base yield(path+file) } end
# File vendor/qwik/lib/qwik/act-save.rb, line 77 def edit_conflict_message(url, editing_content) return [:div, {:class=>'day'}, [:h2, _('Page edit conflict')], [:div, {:class=>'section'}, [:p, _('Please save the following content to your text editor.'), [:a, {:href=>url}, _('Newest page')], _(': see this page and re-edit again.')]], editing_content] end
# File vendor/qwik/lib/qwik/act-edit.rb, line 69 def editor_attach_form(pagename) form = files_form(pagename) list = files_list return form, list end
# File vendor/qwik/lib/qwik/act-edit.rb, line 58 def editor_edit_form(pagename, str, md5hex) form = [:form, {:method=>'POST', :action=>"#{pagename}.save"}, [:textarea, {:name=>'contents', :id=>'contents', :cols=>'70', :rows=>'20', :class=>'focus'}, str], [:div, {:class=>'right'}, [:input, {:type=>'hidden', :name=>'md5hex', :value=>md5hex}], [:input, {:class=>'submit', :type=>'submit', :name=>'save', :value=>_('Save')}]]] return form end
# File vendor/qwik/lib/qwik/act-edit.rb, line 106 def editor_help_edit return [:div, {:class=>'section edithelp'}, [:h2, _('Text Format')], [:ul, [:li, [:tt, '*'], ' ', _('Header')], [:li, [:tt, '-'], ' ', _('List')], [:li, [:tt, '+'], ' ', _('Ordered list')], [:li, [:tt, '>'], ' ', _('Block quote')], [:li, [:tt, ':'], ' ', _('Word'), ': ', _('Definition')], [:li, [:tt, ','], ' ', _('Table')], [:li, [:tt, "''"], _('Emphasis'), [:tt, "''"]], [:li, [:tt, "'''"], _('Stronger'), [:tt, "'''"]], [:li, [:tt, '[['], 'FrontPage', [:tt, ']]'], ' ', _('Link')]], [:p, [:a, {:href=>'TextFormat.describe'}, _('more help')]]] end
# File vendor/qwik/lib/qwik/act-edit.rb, line 98 def editor_help_qwikweb return [:div, {:class=>'section edithistory'}, [:h2, _('Help')], [:ul, [:li, [:a, {:href=>'.describe'}, _('How to qwikWeb')]] ]] end
# File vendor/qwik/lib/qwik/act-edit.rb, line 75 def editor_main(edit_form, attach_form, attach_list, pagename) divs = [ [:div, {:class=>'day edit'}, [:h2, _('Edit')], [:div, {:class=>'section section_edit'}, edit_form]], [:div, {:class=>'day attach'}, [:h2, _('Attach Files')], [:div, {:class=>'section section_attach'}, attach_form, [:div, {:class=>'right attach_many'}, [:a, {:href=>"#{pagename}.files"}, _('Attach many files')]]]] ] if attach_list divs << [:div, {:class=>'day attach'}, [:h2, _('Files')], [:div, {:class=>'section'}, [:ul, *attach_list]]] end return divs end
# File vendor/qwik/lib/qwik/act-edit.rb, line 122 def editor_page_functions(pagename) return [:div, {:class=>'section edithistory'}, [:h2, _('Page functions')], [:ul, [:li, [:a, {:href=>"#{pagename}.backup"}, _('Backup')]], [:li, [:a, {:href=>"#{pagename}.history"}, _('Time machine')]], [:li, [:a, {:href=>"#{pagename}.presen"}, _('Presentation mode')]], [:li, [:a, {:href=>"#{pagename}.wysiwyg"}, _('Edit in this page')]], [:li, [:a, {:href=>"PluginWema.describe"}, _('How to use post-its')]], ]] end
# File vendor/qwik/lib/qwik/act-edit.rb, line 134 def editor_site_admin return [:div, {:class=>'section edithistory'}, [:h2, _('Site administration')], [:ul, [:li, [:a, {:href=>'SiteManagement.describe'}, _('Site Menu')]], [:li, [:a, {:href=>'_SiteConfig.html'}, _('Site Configuration')]], [:li, [:a, {:href=>'.plan'}, _('Create a new plan')]], [:li, [:a, {:href=>'.chronology'}, _('Chronology')]], [:li, [:a, {:href=>'_GroupMembers.html'}, _('Group members')]], [:li, [:a, {:href=>"#{@site.sitename}.zip"}, _('Site Archive')]], [:li, [:a, {:href=>"#{@site.sitename}.sitebackup"}, _('Site backup')]], [:li, [:a, {:href=>"_GroupConfig.html"}, _('Mailing List Configuration')]], [:li, [:a, {:href=>".sendpass"}, _('Send Password')]], ]] end
# File vendor/qwik/lib/qwik/act-emode.rb, line 46 def emode_each_month @site.to_a.sort.each {|page| title = page.key if /\A(\d\d)([0-1]\d)\z/ =~ title y = $1 m = $2 yield(y, m) end } end
# File vendor/qwik/lib/qwik/act-event.rb, line 58 def event_disconnect(reason) if @event.nil? @event = reason end end
# File vendor/qwik/lib/qwik/act-event.rb, line 86 def event_error(msg) return event_send(",#{msg}\n") end
# File vendor/qwik/lib/qwik/act-event.rb, line 54 def event_occurred(event) @event = event end
# File vendor/qwik/lib/qwik/act-event.rb, line 101 def event_send(body) @res.status = 200 @res['Cache-Control'] = 'no-cache, must-revalidate' @res['Pragma'] = 'no-cache' @res.body = body end
# File vendor/qwik/lib/qwik/act-event.rb, line 90 def event_tell(event) time, user, key, ext, cmd = event ar = [] title = "#{Time.at(time).ymd} : #{cmd}" user = MailAddress.obfuscate(user) msg = "#{user}: #{cmd} #{key}" ar << [:h2, title] ar << [:p, msg] return event_send(ar) end
# File vendor/qwik/lib/qwik/act-backup.rb, line 35 def ext_backup c_require_pagename c_require_member #c_require_page_exist # does not require the page is exist # because you can see the list of the page that is already deleted. c_require_no_path_args args = @req.ext_args if 0 < args.length # has target return backup_show(@site, @req.base, args) end return backup_list_page(@site, @req.base) end
# File vendor/qwik/lib/qwik/act-comment.rb, line 71 def ext_comment user = MailAddress.obfuscate(@req.user) ymdx = @req.start_time.ymdx msg = "\n" + @req.query['msg'] msg = msg.normalize_newline msg = msg.gsub("\n", '{{br}}') content = ":#{user} (#{ymdx}):#{msg}\n" page = @site[@req.base] page.add(content) c_make_log('comment') # COMMENT url = @req.base+'.html' return c_notice(_('Message has been added.'), url) { [[:h2, _('Message has been added.')], [:p, [:a, {:href=>url}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-counter.rb, line 38 def ext_counter couner_num = counter_increment_count new_counter_str = couner_num.to_s @res['Content-Type'] = 'text/html; charset=Shift_JIS' @res.body = [:html, [:head, [:title, 'counter'], [:style, ' * { padding: 0; margin: 0; } body { border: 0; font-family: Helvetica,Arial,Verdana,sans-serif; font-size: xx-small; text-align: right; } ']], [:body, [:div, {:class=>'counter'}, new_counter_str]]] return nil end
# File vendor/qwik/lib/qwik/act-day.rb, line 31 def ext_day day = @req.base return c_nerror('require arg') if day.nil? if /\A(\d\d\d\d)(\d\d)(\d\d)\z/ =~ day time = Time.local($1, $2, $3) else return c_nerror('wrong format') end timeline = @site.timeline timeline.calc_history #pp timeline ymd = time.ymd_s keys = timeline.get_keys_by_day(ymd) return c_nerror('no contents') if keys.nil? ar = [] keys.each {|pagename| page = @site[pagename] ar << [:h1, [:a, {:href=>"#{pagename}.html"}, page.get_title]] ar << surface_get_body(page) pageattribute = c_page_res('_PageAttribute') } return c_surface(_('One day') + ' | ' + ymd) { ar } end
# File vendor/qwik/lib/qwik/act-describe.rb, line 82 def ext_describe hash = description_get(@req.base, @req.accept_language) return c_nerror('No such description') if hash.nil? content = "#{hash[:dd]} #{hash[:dc]} * #{_('Functions list')} {{description_list}} " @req.base = 'FrontPage' # Fake. w = c_res(content) w = TDiaryResolver.resolve(@config, @site, self, w) #title = "#{_('Function')} | #{hash[:dt]}" title = hash[:dt] return c_surface(title, true) { w } end
download¶ ↑
# File vendor/qwik/lib/qwik/act-files.rb, line 71 def ext_download if 0 < @req.path_args.length # has target file if @req.path_args[0] == '.theme' @req.path_args.shift return pre_act_theme end filename = files_parse_filename(@req.path_args) files = @site.files(@req.base) if files.nil? || ! files.exist?(filename) return c_notfound(_('No such file')) end return c_download(files.path(filename).to_s) # Download it. end return c_nerror(_('Error')) end
# File vendor/qwik/lib/qwik/act-edit.rb, line 11 def ext_edit c_require_login c_require_page_exist generate_edit_page end
Wait for event.¶ ↑
# File vendor/qwik/lib/qwik/act-event.rb, line 65 def ext_event @event = nil siteevent = @site.event begin siteevent.add_listener(self) rescue ListenerMaxExceed @event = 'max_exceed' end while @event.nil? sleep 0.1 end if @event.is_a?(String) return event_error(@event) end return event_tell(@event) end
# File vendor/qwik/lib/qwik/act-files.rb, line 147 def ext_file_del c_require_member return c_nerror(_('Error')) if @req.path_args.length == 0 filename = files_parse_filename(@req.path_args) if @req.path_args[0] == '.theme' @req.path_args.shift return pre_act_theme end # confirm before delete return files_delete_confirm(filename) unless @req.is_post? return files_delete(filename) # delete it end
files¶ ↑
# File vendor/qwik/lib/qwik/act-files.rb, line 92 def ext_files if 0 < @req.path_args.length # has target file if @req.path_args[0] == '.theme' @req.path_args.shift return pre_act_theme end filename = files_parse_filename(@req.path_args) files = @site.files(@req.base) if files.nil? || ! files.exist?(filename) return c_notfound(_('No such file')) end if files_force_download?(filename) return c_download(files.path(filename).to_s) # Download it. end if ! Filename.allowable_characters_for_path?(filename) return c_download(files.path(filename).to_s) # Download it. end return c_simple_send(files.path(filename).to_s) # Send it. end # Upload the content. content = @req.query['content'] return files_put(content) if content # Show files form and the list. return show_files_form_and_the_list end
# File vendor/qwik/lib/qwik/act-comment.rb, line 111 def ext_hcomment #c_require_login # Guest can post. c_require_login # Guest cannot post. c_require_post date = @req.start_time.ymdx user = @req.query['name'] user = _('Anonymous') if user.nil? || user.empty? msg = @req.query['msg'] return c_nerror('no message') if msg.nil? || msg.empty? content = "- #{date} '''#{user}''' : #{msg}\n" comment_no = @req.query['comment_no'].to_i comment_no = 1 if comment_no < 1 style = @req.query['style'].to_i style = 0 if style != 1 page = @site[@req.base] str = page.load md5 = str.md5hex new_str, written = hcomment_add_to_page(str, comment_no, style, content) return c_nerror(_('Failed')) if !written begin page.put_with_md5(new_str, md5) rescue PageCollisionError return hcomment_error(_('Page collision detected.')) end c_make_log('hcomment') # COMMENT url = @req.base+'.html' return c_notice(_('Add a comment.'), url){ [[:h2, _('Message has been added.')], [:p, [:a, {:href=>url}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-history.rb, line 36 def ext_history c_require_pagename c_require_member return c_notice(_('Announcement')) { [[:h2, _('Announcement')], [:p, "TimeMachine function is disabled for server issue."]] } end
# File vendor/qwik/lib/qwik/act-html.rb, line 11 def ext_html c_require_page_exist c_require_member if Action.private_page?(@req.base) page = @site[@req.base] if MAX_PAGE_SIZE < page.size return c_nerror(_('Page too big.')) { [:div, [:p, _('The page is too big to show.')], [:p, _('Max is 100K bytes. Please truncate it.')], [:p, [:a, {:href=>"#{@req.base}.edit"}, _('Edit')]]] } end if ! c_login? c_set_html if @config.test # Only for test. @res.body = view_page_cache_generate(@req.base) return end pagename = @req.base dirpath = @site.cache_path file = Action.html_page_cache_path(dirpath, pagename) if view_page_cache_need_generate?(file) view_page_cache_generate(pagename) end c_simple_send(file.to_s, 'text/html; charset=Shift_JIS') return end #c_make_log('view') # do not check. #c_monitor('view') surface_view(@req.base) # common-surface.rb users = @config[:wysiwyg_users] if users && users.split(/,\s/).include?(@req.user) head = @res.body.get_path('//head') head << [:meta, {'http-equiv'=>'Refresh', :content=>"0; url=#{@req.base}.wysiwyg"}] end end
# File vendor/qwik/lib/qwik/act-list.rb, line 124 def ext_list_edit list_num = @req.ext_args[0].to_i item_num = @req.ext_args[1].to_i return c_nerror if list_num < 1 || item_num < 1 query = @req.query # [{""=>"ok", "value"=>"Aa", "_"=>""}] value = query['value'] begin plugin_edit(:list, list_num) {|content| new_content = Action.list_edit(content, item_num, value) new_content } rescue NoCorrespondingPlugin return c_nerror(_('Failed')) rescue PageCollisionError return mcomment_error(_('Page collision detected.')) end c_make_log('list_edit') # COMMENT c_set_status c_set_no_cache c_set_contenttype('text/plain') body = value c_set_body(body) end
# File vendor/qwik/lib/qwik/act-list.rb, line 174 def ext_list_pos list_num = @req.ext_args[0].to_i return c_nerror if list_num < 1 item_list = @req.query["sortable_list[]"].list item_list = Action.parse_list(item_list) new_content = '' begin plugin_edit(:list, list_num) {|content| new_content = Action.list_arrange(content, item_list) pp content, new_content new_content } rescue NoCorrespondingPlugin return c_nerror(_('Failed')) rescue PageCollisionError return mcomment_error(_('Page collision detected.')) end c_make_log('list_pos') # COMMENT c_set_status c_set_no_cache c_set_contenttype('text/plain') body = new_content c_set_body(body) end
# File vendor/qwik/lib/qwik/act-comment.rb, line 256 def ext_mcomment #c_require_login # Guest can also post comment. c_require_login # Guest cannot post. c_require_post c_require_page_exist date = @req.start_time.to_i num = @req.ext_args[0].to_i return c_nerror(_('Error')) if num < 1 style = @req.ext_args[1].to_i style = 0 if style != 1 user = @req.query['u'] user = _('Anonymous') if user.nil? || user.empty? msg = @req.query['m'] return c_nerror(_('No message.')) if msg.nil? || msg.empty? msg = msg.normalize_newline msg.gsub!("\n", "\\n") comment = "|#{date}|#{user}|#{msg}\n" begin plugin_edit(:mcomment, num) {|content| if style == 0 content += comment else content = comment + content end content } rescue NoCorrespondingPlugin return c_nerror(_('Failed')) rescue PageCollisionError return mcomment_error(_('Page collision detected.')) end c_make_log('mcomment') # COMMENT url = "#{@req.base}.html" return c_notice(_('Add a comment.'), url){ [[:h2, _('Message has been added.')], [:p, [:a, {:href=>url}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-md5.rb, line 9 def ext_md5 c_require_page_exist c_set_status c_set_no_cache c_set_contenttype('text/plain') c_set_body(@site[@req.base].get.md5hex) end
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 318 def ext_modulobe_files_upload content = @req.query['content'] # WEBrick::HTTPUtils::FormData image = @req.query['image'] return modulobe_files_put(content, image) if content return modulobe_files_error(_('Please specify file.')) end
# File vendor/qwik/lib/qwik/act-povray.rb, line 158 def ext_povray c_require_post c_require_page_exist num = @req.ext_args[0].to_i return c_nerror(_('Error')) if num < 1 text = @req.query['t'] return c_nerror(_('No text.')) if text.nil? || text.empty? text = text.normalize_newline begin plugin_edit(:povray, num) {|content| text } rescue NoCorrespondingPlugin return c_nerror(_('Failed')) rescue PageCollisionError return mcomment_error(_('Page collision detected.')) end c_make_log('povray') # TEXTAREA url = "#{@req.base}.html" return c_notice(_('Edit text done.'), url){ [[:h2, _('Edit text done.')], [:p, [:a, {:href=>url}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-presen.rb, line 92 def ext_presen c_require_pagename c_require_page_exist c_require_no_path_args c_require_no_ext_args # Get theme. page = @site[@req.base] content = page.load w = c_parse(content) theme = presen_get_theme(w) theme ||= PRESEN_DEFAULT_THEME w = c_res(content) w = presen_patch(w) c_set_html c_set_no_cache @res.body = PresenGenerator.generate(@site, @req.base, w, theme) end
# File vendor/qwik/lib/qwik/act-ring.rb, line 147 def ext_ring_invite page = @site[@req.base] href = page.url guest_mails = @req.query['guest_mail'] message = @req.query['message'] if guest_mails.nil? || guest_mails.empty? || message.nil? return ring_invite_goback(href) end if guest_mails.to_s == 'guest@example.com' return ring_invite_goback(href) end guest_mail_ar = Action.ring_invite_parse_guest_mails(guest_mails) if guest_mail_ar.length == 0 return ring_invite_goback(href) end ring_invite_guest(guest_mail_ar, message) return c_notice(_r(:INVITE_MAIL_IS_SENT)) { [[:h3, _r(:INVITE_MAIL_IS_SENT)], [:dl, [:dt, _r(:MESSAGE)], [:dd, message]], [:p, _r(:THANKYOU)], [:p, [:a, {:href=>href}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-ring.rb, line 335 def ext_ring_make href = "#{@req.base}.html" mail = @req.user ring_member_page = @site.get_superpage(RING_MEMBER) ring_member_page = @site.create("_#{RING_MEMBER}") if ring_member_page.nil? if ring_member_page.wikidb.exist?(mail) return ring_make_already_exist(href) end username = @req.query['username'] realname = @req.query['realname'] faculty = @req.query['faculty'] year = @req.query['year'] if username.nil? || username.empty? || realname.nil? || realname.empty? return ring_make_not_registerd(href) end newpage = ring_make_create_newpage(username) newkey = newpage.key now = @req.start_time ring_member_page.wikidb.add(mail, username, realname, faculty, year, newkey, now.to_i) return ring_make_registerd(href, username, realname, newkey) end
Append a a message to the page.
# File vendor/qwik/lib/qwik/act-ring.rb, line 444 def ext_ring_msg c_require_page_exist href = "#{@req.base}.html" message = @req.query['message'] # Check error. if ! message || message.empty? || message == _r(:MSG_INPUT_HERE) return ring_msg_input_message(href) end mail = @req.user datenum = @req.start_time.to_i.to_s # Add a message. content = ":{{ring_ul(#{mail})}} ({{ring_date(#{datenum})}}):#{message}\n" page = @site[@req.base] page.add(content) return c_notice(_r(:MSG_MESSAGE_IS_ADDED), href){ [[:h3, _r(:MSG_MESSAGE_IS_ADDED)], [:p, _r(:THANKYOU)], [:p, [:a, {:href=>href}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-save.rb, line 15 def ext_save(contents=nil, ext='html') c_require_login c_require_page_exist contents = @req.query['contents'] if contents.nil? return c_nerror('contents is nil.') if contents.nil? page = @site[@req.base] # Do not delete a page with password if contents.empty? && ! page.get_password @site.delete(@req.base) # DELETE c_make_log('delete') # DELETE c_monitor('delete') # DELETE # clear_rrefs(@req.base) site_updated return save_page_deleted end newcontents = Page.embed_password(contents) # embed the password if ! page.match_password?(newcontents) return save_password_does_not_match(contents) end contents = newcontents contents = contents.gsub(/\r/, '') md5hex = @req.query['md5hex'] md5hex = nil if page.get_password begin page.put_with_md5(contents, md5hex) # STORE rescue PageCollisionError # failed to save? return save_conflict(contents) end c_make_log('save') # STORE c_monitor('save') # STORE c_event('save') # STORE url = "#{@req.base}.#{ext}" # update_rrefs site_updated return save_page_is_saved(url) end
# File vendor/qwik/lib/qwik/act-schedule.rb, line 71 def ext_schedule num = @req.ext_args[0].to_i return c_nerror(_('Error')) if num < 1 query = @req.query new_table_str = schedule_construct(query) begin plugin_edit(:schedule, num) { new_table_str } rescue NoCorrespondingPlugin return c_nerror(_('Failed')) rescue PageCollisionError url = "#{@req.base}.html" editing_content = [:pre, new_table_str] message = edit_conflict_message(url, editing_content) return mcomment_error(_('Page collision detected.')) { message } end c_make_log('schedule') # COMMENT url = "#{@req.base}.html" return c_notice(_('Schedule'), url){ [[:h2, _('Schedule edit done.')], [:p, [:a, {:href=>url}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 63 def ext_sitebackup return c_nerror("no tar command") if ! SiteBackup.command_exist? c_require_member c_require_base_is_sitename backup = SiteBackup.new(@site, @config) if backup.latest? return c_notice("Download archive", "#{@site.sitename}.tgz", 200, 2) { [:p, "Backup process is complete. download ", [:a, {:href=>"#{@site.sitename}.tgz"}, "archive"], "." ] } end if backup.generating? return c_notice("in progress", "#{@site.sitename}.sitebackup", 200, 5) { [:p, "Backup process is running."] } end backup.generate return c_notice("starting", "#{@site.sitename}.sitebackup", 200, 5) { [:p, "Backup process is starting"] } end
# File vendor/qwik/lib/qwik/act-smil.rb, line 63 def ext_smil # $smil_debug = true $smil_debug = false ar = [] ar << @req.base ar += @req.ext_args ar << @req.ext filename = ar.join('.') file = @site.files(@req.base).path(filename) if $smil_debug return c_notice(1) { "filename is #{filename}" } end return c_simple_send(file.to_s, 'application/smil') end
# File vendor/qwik/lib/qwik/act-table.rb, line 85 def ext_table num = @req.ext_args[0].to_i return c_nerror(_('Error')) if num < 1 query = @req.query new_table_str = table_construct(query) begin plugin_edit(:table, num) { new_table_str } rescue NoCorrespondingPlugin return c_nerror(_('Failed')) rescue PageCollisionError url = "#{@req.base}.html" editing_content = [:pre, new_table_str] message = edit_conflict_message(url, editing_content) return mcomment_error(_('Page collision detected.')) { message } end c_make_log('table') # TABLE url = "#{@req.base}.html" return c_notice(_('Edit done.'), url){ [[:h2, _('Edit done.')], [:p, [:a, {:href=>url}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-tag.rb, line 33 def ext_tag target_tag = @req.base all_pages = Action.tag_get_pages(@site) pages = all_pages[target_tag] return c_nerror('no such tag') if pages.empty? div = [:div, {:class=>'tag_pages'}] pages.each {|key| page = @site[key] body = surface_get_body(page) div += body } return c_surface("tag : #{target_tag}"){ div } end
# File vendor/qwik/lib/qwik/act-textarea.rb, line 69 def ext_textarea c_require_post c_require_page_exist num = @req.ext_args[0].to_i return c_nerror(_('Error')) if num < 1 text = @req.query['t'] return c_nerror(_('No text.')) if text.nil? || text.empty? text = text.normalize_newline begin plugin_edit(:textarea, num) {|content| text } rescue NoCorrespondingPlugin return c_nerror(_('Failed')) rescue PageCollisionError return mcomment_error(_('Page collision detected.')) end c_make_log('textarea') # TEXTAREA url = "#{@req.base}.html" return c_notice(_('Edit text done.'), url){ [[:h2, _('Edit text done.')], [:p, [:a, {:href=>url}, _('Go back')]]] } end
only for download archive
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 91 def ext_tgz c_require_member c_require_base_is_sitename backup = SiteBackup.new(@site, @config) if backup.latest? return c_simple_send(backup.archive_path, "application/gzip") else return c_notfound { "no latest backup" } end end
# File vendor/qwik/lib/qwik/act-wema.rb, line 73 def ext_wema c_require_post c_require_login wp = WemaPage.new(@site, @site[@req.base]) redirect = "#{@req.base}.html" redirect = nil if $wema_debug mode = @req.query['mode'] wid = @req.query['id'] # wema id connected = @req.query['ln'] left = @req.query['l'] top = @req.query['t'] fg = @req.query['tc'] bg = @req.query['bg'] text = @req.query['body'] mode = 'delete' if mode == 'edit' && text.empty? case mode when 'edit' if wid.nil? || wid.empty? # create new wema = wp.create_new msg = _('New post-it is created.') else id = wid.sub(/\Aid/, '').to_i wp.get_wemas wema = wp[id] msg = _('Edit done.') end if wema wema.set(connected, left, top, fg, bg, text) c_make_log('wemaedit') # WEMAEDIT #c_monitor('wemaedit') # WEMAEDIT end return wema_jump(msg, redirect) when 'delete' if wid.nil? || wid.empty? return wema_jump(_('No action.'), redirect) end id = wid.sub(/\Aid/, '').to_i wp.get_wemas wema = wp[id] wp.delete(id) c_make_log('wemadelete') # WEMADELETE #c_monitor('wemadelete') # WEMADELETE return wema_jump(_('Delete a Post-it.'), redirect) when 'setpos' wid = nil if wid.empty? return c_nerror('wid is nil') if wid.nil? id = wid.sub(/\Aid/, '').to_i wp.get_wemas wema = wp[id] return c_nerror('can not get wema') if wid.nil? wema.setpos(left, top) #c_make_log('wemasetpos') # too many... #c_monitor('wemasetpos') return wema_jump(_('Set position.'), redirect) else return c_nerror("Unknown mode: [#{mode}]") end end
# File vendor/qwik/lib/qwik/act-wysiwyg.rb, line 73 def ext_wysiwyg c_require_pagename c_require_page_exist c_require_member c_require_no_path_args c_require_no_ext_args if 0 < @req.query.length return wysiwyg_save end return wysiwyg_editor_page(@site, @req.base) end
# File vendor/qwik/lib/qwik/act-archive.rb, line 68 def ext_zip c_require_member c_require_base_is_sitename if archive_running_path.exist? return c_notice(_('Running.')) { [:div, [:p, _("The process is working now.")], [:p, _("Pleae wait for a while.")], [:p, [:a, {:href=>"#{@req.base}.zip"}, _('Again')]]] } end if archive_path.exist? return c_simple_send(archive_path, 'application/zip') end # Start New thread. Thread.new { archive_running_path.write("running") SiteArchive.generate(@config, @site, self) archive_running_path.unlink } return c_notice(_('Start.')) { [:div, [:p, _("The archive process sgtarted.")], [:p, _("Pleae wait for a while.")], [:p, [:a, {:href=>"#{@req.base}.zip"}, _('Again')]]] } end
# File vendor/qwik/lib/qwik/act-file.rb, line 53 def file_html(href, klass, src, alt, message) return [:div, {:class=>'ref'}, [:a, {:href=>href}, [:img, {:class=>klass, :src=>src, :alt=>alt}], [:br], message]] end
# File vendor/qwik/lib/qwik/act-files.rb, line 172 def files_delete(filename) c_require_post url = "../#{@req.base}.html" begin @site.files(@req.base).delete(filename) rescue FileNotExist return c_nerror(_('Already deleted.'), url) rescue FailedToDelete return c_nerror(_('Failed to delete.'), url) end c_make_log('file delete') # FILE DELETE return c_notice(_('The file has been deleted.'), url) { [:p, [:a, {:href=>url}, _('Go back')]] } end
# File vendor/qwik/lib/qwik/act-files.rb, line 162 def files_delete_confirm(filename) encoded = Filename.encode(filename) action = "../#{@req.base}.file_del/#{encoded}" # Bad... return c_notice(_('Confirm file deletion')) { [:form, {:method=>'POST', :action=>action}, [:p, _("Push 'Delete' to delete a file")], [:p, [:input, {:type=>'submit', :value=>_('Delete')}]]] } end
# File vendor/qwik/lib/qwik/act-files.rb, line 142 def files_force_download?(filename) ext = filename.path.ext FILES_FORCE_DOWNLOAD.detect { |bad_ext| bad_ext.downcase == ext.downcase } end
called from act-edit
# File vendor/qwik/lib/qwik/act-files.rb, line 216 def files_form(pagename, upload_number=1) size = '40' ar = [] upload_number.times { ar << [:div, {:class=>'inputfile'}, [:input, {:type=>'file', :name=>'content'}]] } ar << [:div, {:class=>'input_submit'}, [:input, {:class=>'submit', :type=>'submit', :value=>_('Attach')}]] form = [:form, {:action=>"#{pagename}.files", :method=>'POST', :enctype=>'multipart/form-data'}, *ar] return form end
# File vendor/qwik/lib/qwik/act-files.rb, line 50 def files_list return files_list_internal(@req.base, @site.files(@req.base)) end
# File vendor/qwik/lib/qwik/act-files.rb, line 54 def files_list_internal(base, files) list = files.list return nil if list.empty? return list.map {|file| encoded = Filename.encode(file) [:li, [:a, {:href=>"#{base}.files/#{encoded}"}, file.to_page_charset], [:span, {:class=>'delete'}, ' (', [:a, {:href=>"#{base}.file_del/#{encoded}"}, _('Delete')], ')'], [:span, {:class=>'download'}, ' (', [:a, {:href=>"#{base}.download/#{encoded}"}, _('Download')], ')'], ] } end
# File vendor/qwik/lib/qwik/act-files.rb, line 135 def files_parse_filename(args) filename = args.join('/').set_url_charset # Must be UTF-8 filename = Filename.decode(filename) return filename end
# File vendor/qwik/lib/qwik/act-edit.rb, line 17 def generate_edit_page(contents=nil, message=nil) #c_monitor('startedit') c_editor(@site, @req.base, contents, message) end
# File vendor/qwik/lib/qwik/act-edit.rb, line 154 def generate_editor_page(title, h1, message, main, sidebar) @res.status = 200 template = @memory.template.get('editor') @res.body = Action.editor_generate(template, title, h1, message, main, sidebar) c_set_html c_set_no_cache return nil end
# File vendor/qwik/lib/qwik/common-notice.rb, line 28 def generate_notice_page(status, title, url=nil, msg='', sec=0) #url = nil # for debug @res.status = status template = @memory.template.get('notice') @res.body = Action.notice_generate(template, title, msg, url, false, sec) c_set_html c_set_no_cache return nil end
# File vendor/qwik/lib/qwik/common-plain.rb, line 20 def generate_plain_page(status, title, msg) c_set_status(status) c_set_html c_set_no_cache template = @memory.template.get('plain') body = Action.plain_generate(template, title, msg) c_set_body(body) nil end
# File vendor/qwik/lib/qwik/act-map.rb, line 107 def get_first_plugin(page, method) str = page.load elements = c_parse(str) elements.each {|element| if element[0] == :plugin && element[1][:method] == method return element end } return nil end
# File vendor/qwik/lib/qwik/act-event.rb, line 50 def get_start_time return @req.start_time end
# File vendor/qwik/lib/qwik/act-getpass.rb, line 71 def getpass_form(form_style='text-align: center; margin: 32px 0 48px;', div_style='margin: 16px 0 8px', klass='focus') return [:form, {:action=>'.getpass', :style=>form_style}, [:div, {:style=>div_style}, [:em, _('Mail address'), ': '], [:input, {:name=>'mail', :size=>'40', :istyle=>'3', :class=>klass}]], [:div, {:class=>'rightbutton'}, [:input, {:type=>'submit', :value=>_('Send')}]]] end
# File vendor/qwik/lib/qwik/act-getpass.rb, line 83 def getpass_not_member(user, ml) c_nerror(_('Members Only')) { [[:p, _('You input this e-mail address as user ID.'), [:br], [:strong, user]], [:p, _('This user with this ID is not a member of this group.'), [:br], [:strong, ml]], [:p, _('Only the member of this group can get a password.')], [:p, [:a, {:href=>'.getpass'}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-getpass.rb, line 62 def getpass_show_form c_notice(_('Get Password')) { [[:h2, _('You will receive the password by e-mail.')], [:p, _('Please input your mail address.')], getpass_form, [:p, [:a, {:href=>'.login'}, _('Go back to Login screen')]]] } end
# File vendor/qwik/lib/qwik/act-webservice.rb, line 171 def google_ad(str) str << '//' return [:div, {:style=>'text-align: center;'}, [:script, {:type=>'text/javascript'}, [:'!--', str]], [:script, {:type=>'text/javascript', :src=>'http://pagead2.googlesyndication.com/pagead/show_ads.js'}, '']] end
# File vendor/qwik/lib/qwik/act-comment.rb, line 163 def hcomment_add_to_page(str, comment_no, style, content) new_str = '' num = 1 written = false str.each {|line| if /\A\{\{hcomment/ =~ line && !written if num == comment_no new_str << content if style == 0 # new comment is on the bottom. new_str << line new_str << content if style == 1 # new comment is on the top. written = true else new_str << line num += 1 end else new_str << line end } return new_str, written end
# File vendor/qwik/lib/qwik/act-comment.rb, line 151 def hcomment_error(msg, url) return c_nerror(msg){ [[:h2, msg], [:p, msg], [:p, _('Go back and input again.')], [:dl, [:dt, _('Name')], [:dd, user], [:dt, _('Comment')], [:dd, msg], [:p, [:a, {:href=>url}, _('Go back')]]]] } end
# File vendor/qwik/lib/qwik/act-history.rb, line 75 def history_show(pagename, divs) ar = [] ar << [:style, "@import '.theme/css/wema.css';"] handle = [:div, {:class=>'wema', :id=>'curosr', :style=>'left:0px;top:0px;'}, [:div, {:class=>'menubar'}, [:span, {:class=>'handle'}, 'handle'], [:span, {:class=>'close'}, [:a, {:href=>'#'}, ' X ']]], # noop [:div, {:class=>'cont'}, [:span, {:id=>'indicator'}, _('Move this')]]] ar << handle section = [] section << [:div, {:id=>'eratable'}, ''] section << divs section << [:div, {:id=>'lines'}, ''] ar << [:div, {:class=>'day'}, [:div, {:class=>'section'}, section]] ar << [:script, {:type=>'text/javascript', :src=>'.theme/js/wema.js'}, ''] ar << [:script, {:type=>'text/javascript',:src=>'.theme/js/history.js'}, ''] title = _('Time machine')+" | #{pagename}" return c_plain(title) { ar } end
# File vendor/qwik/lib/qwik/act-file.rb, line 102 def icon_find(ext) mimetype = @res.get_mimetypes ext return icon_find_internal(mimetype, ext) end
# File vendor/qwik/lib/qwik/act-file.rb, line 107 def icon_find_internal(mimetype, ext) ext.downcase! type = ICON_SUF_TABLE[ext] return icon_path(type) if type if mimetype type = ICON_MIMETYPE_TABLE[mimetype] if type path = icon_path(type) return path if path end genre, spec = mimetype.split('/') type = ICON_GENRE_TABLE[genre] if type path = icon_path(type) return path if path end end return icon_path('generic') end
# File vendor/qwik/lib/qwik/act-file.rb, line 131 def icon_path(type) return icon_path_internal(@config.theme_dir.path+'i', type) end
# File vendor/qwik/lib/qwik/act-file.rb, line 135 def icon_path_internal(path, type) file = "#{type}.gif" return nil unless (path+file).exist? return ".theme/i/#{file}" end
# File vendor/qwik/lib/qwik/action.rb, line 56 def init(config, memory, req, res) @config, @memory, @req, @res = config, memory, req, res end
# File vendor/qwik/lib/qwik/common-gettext.rb, line 17 def init_catalog(catalog_factory, langs) langs.each {|lang| catalog = catalog_factory.get_catalog(lang) if catalog set_catalog(catalog) # GetText::set_catalog return end } end
# File vendor/qwik/lib/qwik/common-gettext.rb, line 13 def init_gettext init_catalog(@memory.catalog, @req.accept_language) end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 160 def int_to_time(n) return n.to_s+_('sec.') if n < 60 # under 1 min return (n/60).to_s+_('min.') if n < 60*60 # under 1 hour return (n/(60*60)).to_s+_('hour') if n < 60*60*24 # under 1 day return (n/(60*60*24)).to_s+_('day') if n < 60*60*24*30 # under 1 month return (n/(60*60*24*30)).to_s+_('month') if n < 60*60*24*365 # under 1 year return (n/(60*60*24*365)).to_s+_('year') if n < 60*60*24*365*100 # under 1 century return (n/(60*60*24*365*100)).to_s+_('century') end
# File vendor/qwik/lib/qwik/act-status.rb, line 140 def is_administrator? file = @config.etc_dir.path + "administrator.txt" return false if ! file.exist? admin = file.read.chomp return false if @req.user != admin return true end
# File vendor/qwik/lib/qwik/common-url.rb, line 29 def is_valid_url?(str) return %r!\Ahttp://[\-\_\.\/\?A-Za-z]+\z! =~ str end
# File vendor/qwik/lib/qwik/act-isearch.rb, line 46 def isearch_patch(body) # Destructive for the body form = body.get_path('//form') form[1][:action] = '.isearch' end
# File vendor/qwik/lib/qwik/act-isearch.rb, line 51 def isearch_result(site, ar) ul = [:ul] ar.each {|key| page = site[key] url = page.url ul << [:li, [:a, {:href=>url}, key]] } div = [:div, {:class=>'day'}, [:div, {:class=>'section'}, [:div, {:class=>'search_result'}, ul]]] title = _('Search result') return c_plain(title) { div } end
TODO: Show CC icon.
# File vendor/qwik/lib/qwik/act-license.rb, line 30 def license_text(license) msg = LICENSE[license] return '' if msg.nil? newmsg = _(msg) return newmsg end
# File vendor/qwik/lib/qwik/act-list.rb, line 79 def list_make_div(list_num, content) w = c_tokenize(content) div = [:div, {:class=>'list'}] list_id = "list_#{list_num}" ul, inplace_editors = list_make_ul(list_num, list_id, w) div << ul script = list_make_script(@req.base, list_num, list_id, inplace_editors) div << script return div end
# File vendor/qwik/lib/qwik/act-list.rb, line 113 def list_make_script(base, list_num, list_id, inplace_editors) list_action = "#{base}.#{list_num}.list_pos" script = '' script << PLG_LIST_SCRIPT if list_num == 1 inplace_editors.each {|span_id, action| script << "qwikSetInPlaceEditor('#{span_id}', '#{action}');\n" } script << "qwikCreateSortable('#{list_id}', '#{list_action}');\n" return [:script, {:type=>'text/javascript'}, script] end
# File vendor/qwik/lib/qwik/act-list.rb, line 95 def list_make_ul(list_num, list_id, w) ul = [:ul, {:id=>list_id}] inplace_editors = [] item_num = 1 w.each_element(:ul) {|li| #level = li[1] # FIXME: Use level info correctly. content = li[2] item_id = "item_#{list_num}_#{item_num}" span_id = "item_edit_area_#{list_num}_#{item_num}" action = "#{@req.base}.#{list_num}.#{item_num}.list_edit" ul << [:li, {:id=>item_id}, [:span, {:class=>"item_edit_area", :id=>span_id}, content]] inplace_editors << [span_id, action] item_num += 1 } return ul, inplace_editors end
# File vendor/qwik/lib/qwik/act-login.rb, line 170 def login_already_logged_in(user) ar = [] ar << [:p, _('You are now logged in with this user id.'), [:br], [:strong, user]] ar << [:p, _('If you would like to log in on another account,'), [:br], _('please log out first.')] ar << logout_form ar << [:hr] ar << login_go_frontpage return c_nerror(_('Already logged in.')){ar} end
# File vendor/qwik/lib/qwik/act-login.rb, line 81 def login_create_login_link return [:a, {:href=>'.login'}, 'Login'] end
# File vendor/qwik/lib/qwik/act-login.rb, line 182 def login_go_frontpage style = '' return [:div, {:class=>'go_frontpage',:style=>''}, [:a, {:href=>'FrontPage.html', :style=>style}, 'FrontPage']] end
called from action.rb
# File vendor/qwik/lib/qwik/act-login.rb, line 127 def login_invalid_user c_nerror(_('Login Error')){[ [:p, [:strong, _('Invalid ID (E-mail) or Password.')]], [:p, {:class=>'warning'}, _('If you have no password,'), _('Access here'), [:br], [:a, {:href=>'.getpass'}, [:em, _('Get Password')]]], login_page_form, login_page_menu, ]} end
# File vendor/qwik/lib/qwik/act-login.rb, line 188 def login_show_login_page(url) login_msg = nil if page = @site['_LoginMessage'] login_msg = [:div, {:class=>'warning'}, c_res(page.load)] end login_target_div = [:div, [:h2, _('Log in to '), [:em, url]], [:p, _('Please input ID (E-mail) and password.')]] div = [:div, {:class=>'login_page'}] div << login_target_div div << login_msg if login_msg div << login_page_form div << [:hr] div << [:div, [:h2, _('If you have no password')], [:p, _('Please input your mail address.')], getpass_form('', '', ''), # [:p, [:a, {:href=>'.sendpass'}, # _('You can send password for members.')]], ] div << [:hr] div << [:div, [:h2, [:a, {:href=>'.typekey'}, _('Log in by TypeKey')]], [:p, _('Please send mail address for authentication.')]] div << [:hr] div << [:div, [:h2, [:a, {:href=>'.basicauth'}, _('Log in by Basic Authentication.')]], [:p, _('For mobile phone users')]] # div << [:hr] # div << login_page_menu style = [:style, ' .container { margin-top: 20px; } '] return [style, div] end
# File vendor/qwik/lib/qwik/act-login.rb, line 234 def login_show_login_suceed_page url = 'FrontPage.html' title = _('Login') + ' ' + _('Success') return c_notice(title, url) { [login_go_frontpage] } end
# File vendor/qwik/lib/qwik/act-logout.rb, line 38 def logout_form return [:div, {:class=>'logout'}, [:form, {:method=>'POST', :action=>'.logout'}, [:input, {:type=>'hidden', :name=>'confirm', :value=>'yes'}], [:input, {:type=>'submit', :value=>_('Log out'), :class=>'focus'}]]] end
# File vendor/qwik/lib/qwik/act-logout.rb, line 28 def logout_show_confirm title = _('Log out')+' '+_('Confirm') c_notice(title) { [[:p, _('Push "Log out".')], logout_form, [:hr], [:p, [:a, {:href=>'FrontPage.html'}, _('Go next')]]] } end
# File vendor/qwik/lib/qwik/act-map.rb, line 120 def map_get_api_key file = @config.etc_dir.path+GOOGLE_MAPS_API_KEY_FILE return if ! file.exist? return file.open {|f| f.gets }.chomp end
# File vendor/qwik/lib/qwik/act-map.rb, line 131 def map_initial_script key = map_get_api_key #return if key.nil? # Fatal error. key ||= '' # Ad hoc. src = "http://maps.google.com/maps?file=api&v=1&key=#{key}" return [:script, {:src=>src, :type=>'text/javascript'}, ''] end
# File vendor/qwik/lib/qwik/act-map.rb, line 102 def map_make_page_utf8 @res.body = @res.body.format_xml.page_to_xml @res['Content-Type'] = "text/html; charset=#{Charset::UTF8}" end
# File vendor/qwik/lib/qwik/act-map.rb, line 220 def map_maparea(clat, clng, mag, content, mode='iframe') maparea = [:div, {:class=>'maparea'}] # Add initial script. #maparea << map_initial_script # Add <div id='map'></div> style = 'width: 696px; height: 382px;' style = 'width: 100%; height: 600px;' if mode == 'full' maparea << [:div, {:id=>'map', :style=>style}, ''] maparea << [:div, {:id=>'message', :style=>'font-size:x-small;'}, ''] end
# File vendor/qwik/lib/qwik/act-map.rb, line 139 def map_script(clat, clng, mag, content, mode='iframe') maparea = [] # Prepare markers. elements = c_parse(content) markers = [] marker = nil elements.each {|element| if element[0] == :h2 marker = [] markers << marker marker << element else if marker marker << element end end } ms = [] markers.each {|marker| h2 = marker[0] if h2[1] == '[' && h2[3] == ']' lat, lng = h2[2].split(',') h2[1] = '' # Destruct headers. h2[2] = '' h2[3] = '' ms << [lat, lng, marker] end } marker_script = '' ms.each {|lat, lng, marker| s = marker.rb_format_xml(-1, -1) s = s.sub(/\n/, '') marker_script << "qwikSetMark(#{lat}, #{lng}, '#{s}');\n" } # Add script. clat = clat.to_f clng = clng.to_f mag = mag.to_i # You should set width for div element in the marker. script = " function qwikMakeMap() { if (GBrowserIsCompatible()) { // Define the function inside. function qwikSetMark(lat, lng, body) { var point = new GPoint(lng, lat); var html=\"<div style='width:220px'>\"+body+\"</div>\"; var marker = new GMarker(point); map.addOverlay(marker); GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); marker.openInfoWindowHtml(html); } var map = new GMap(document.getElementById('map')); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.centerAndZoom(new GPoint(#{clng}, #{clat}), #{mag}); GEvent.addListener(map, 'moveend', function() { var center = map.getCenterLatLng(); var latLngStr = '* [' + center.y + ',' + center.x + '] '; document.getElementById('message').innerHTML = latLngStr; }); #{marker_script} } } " maparea << [:script, {:type=>'text/javascript'}, "\n//", [:'![CDATA[', "\n\n"+script+"\n//"], "\n"] return maparea end
# File vendor/qwik/lib/qwik/act-map.rb, line 126 def map_style return [:style, '.header { display: none ! important; } body { background: #fff; }'] end
# File vendor/qwik/lib/qwik/act-comment.rb, line 236 def mcomment_construct_messages(content) messages = [] content.each {|line| line.chomp! dummy, date, user, msg = line.split('|', 4) date = Time.at(date.to_i).ymd msg ||= '' msg.gsub!(/\\n/, "\n") mm = [] msg.each {|m| mm << m mm << [:br] } messages << [:div, {:class=>'msg'}, [:dl, [:dt, [:span, {:class=>'date'}, date], [:span, {:class=>'user'}, user]], [:dd, *mm]]] } return messages end
# File vendor/qwik/lib/qwik/act-comment.rb, line 304 def mcomment_error(msg, url) return c_nerror(msg){ [[:h2, msg], [:p, msg], [:p, _('Go back and input again.')], [:dl, [:dt, _('Name')], [:dd, user], [:dt, _('Comment')], [:dd, msg], [:p, [:a, {:href=>url}, _('Go back')]]]] } end
# File vendor/qwik/lib/qwik/act-member.rb, line 46 def member_add_exec(tomail) return member_error(_('Error')) if tomail.nil? return member_error(_('Invalid Mail')) if ! MailAddress.valid?(tomail) return member_error(_('Already exists')) if @site.member.exist?(tomail) @site.member.add(tomail, @req.user) c_make_log("member_add\t#{tomail}") # member_add return member_error(_('Error')) if ! @site.member.exist?(tomail) return c_notice(_('Member added')) { [[:p, _('Member added')], [:hr], [:p, [:a, {:href=>'.member_add'}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-member.rb, line 33 def member_add_form return c_notice(_('Add a member')) { [[:form, {:action=>".member_add", :style=>'text-align: center; margin: 32px 0 32px;'}, [:p, [:em, _('Mail address to add'), ': ']], [:p, [:input, {:name=>'tomail', :class=>'focus'}]], [:div, {:class=>'rightbutton'}, [:input, {:value=>_('Add'), :type=>'submit'}]]], [:hr], [:p, [:a, {:href=>'FrontPage.html'}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-member.rb, line 64 def member_error(title) return c_nerror(title) { [[:p, title], [:hr], [:p, [:a, {:href=>'.member_add'}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-metadata.rb, line 51 def metadata_atom_xml return @site.metadata.generate_atom end
# File vendor/qwik/lib/qwik/act-metadata.rb, line 22 def metadata_clear_cache path = @site.cache_path + "rss.xml" path.unlink if path.exist? path = @site.cache_path + "atom.xml" path.unlink if path.exist? end
rss¶ ↑
Called from act-metadata.rb
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 148 def metadata_model_xml # Check pages that has .mdlb file. page_keys = Hash.new(0) @site.each {|page| files = @site.files(page.key) files.each {|filename| if /\.mdlb\z/ =~ filename page_keys[page.key] += 1 end } } # Collect model files and check last_time. last_time = nil models = [] page_keys.keys.sort.each {|key| page = @site[key] str = page.load tokens = TextTokenizer.tokenize(str) tokens.each {|token| if token[0] == :plugin && token[1] == 'modulobe_model' filename = token[2] files = @site.files(page.key) file = files.path(filename) mtime = file.mtime last_time = mtime if last_time.nil? || last_time < mtime content = token[3] content_tokens = TextTokenizer.tokenize(content) title = author = comment = nil content_tokens.each {|ctoken| next if ctoken[0] != :dl title = ctoken[2] if ctoken[1] == 'title' author = ctoken[2] if ctoken[1] == 'author' comment = ctoken[2] if ctoken[1] == 'comment' } title ||= 'no title' author ||= 'no name' comment ||= 'no comment' models << [mtime, page, file, title, author, comment] end } } xml = [] xml << [:'?xml', '1.0', 'utf-8'] rss = [:rss, {:version=>'2.0', :'xmlns:creativeCommons'=> 'http://backend.userland.com/creativeCommonsRssModule'}] top_url = c_relative_to_absolute('/') channel = [:channel, [:title, 'Modulobe model gallery'], [:link, top_url], [:description, 'This is a model list of Modulobe Wiki.'], [:language, 'ja'], [:managingEditor, 'modulobe@qwik.jp'], [:webMaster, 'modulobe@qwik.jp'], [:lastBuildDate, last_time.rfc1123_date], [:ttl, '60']] models.sort.each {|mtime, page, file, title, author, comment| basename = file.basename url = c_relative_to_absolute(page.key+'.files/'+basename) # Check thumb is exist. thumb_file = file.dirname+'.thumb'+(file.basename('.mdlb').to_s+'.gif') if ! thumb_file.exist? # make it. end thumb = page.key+'.files/.thumb/'+file.basename('.mdlb').to_s+'.gif' thumb_url = c_relative_to_absolute(thumb) html = "<p><img src=\"#{thumb_url}\" alt=\"#{title}\" width=\"100\" height=\"75\"/><p>#{comment}</p>" length = file.size item = [:item, [:title, title], [:link, url], [:description, html], [:author, author], [:pubDate, mtime.rfc1123_date], [:enclosure, {:url=>url, :length=>length, :type=>'application/xml'}], [:'creativeCommons:license', 'http://creativecommons.org/licenses/by/2.1/jp/']] channel << item } rss << channel xml << rss return xml end
# File vendor/qwik/lib/qwik/act-metadata.rb, line 47 def metadata_rss_xml return @site.metadata.generate_rss20 end
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 392 def modulobe_files_error(msg) return c_surface(_('Error')){ [[:h2, {:style=>'margin:2em;text-align:center;'}, msg], [:p, {:style=>'margin:2em;text-align:center;'}, [:a, {:href=>@req.base+'.html'}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 325 def modulobe_files_put(content, image) c_require_post files = @site.files(@req.base) fullfilename = content.filename if fullfilename.empty? return modulobe_files_error(_('Please contact the administrator.')) end # Get basename. filename = fullfilename.sub(/\A.*[\/\\]([^\/\\]+)\z/) { $1 } result_filename = files.fput(filename, content) list = [] if filename == result_filename list << [:p, [:strong, filename], ' : ', _('The file is saved.')] else list << [:p, [:strong, filename], ' -> ', [:strong, result_filename], ' : ', _('The file is saved with this filename.')] end if image img_fullfilename = image.filename if img_fullfilename && ! img_fullfilename.empty? img_filename = img_fullfilename.sub(/\A.*[\/\\]([^\/\\]+)\z/) { $1 } ext = Filename.extname(img_filename) if ext == 'gif' img_filename = File.basename(result_filename, '.mdlb')+'.gif' files.put(img_filename, image) list << [:p, _('The image is also saved.')] end end end c_make_log('modulobe file attach') # Modulobe FILE ATTACH files = @site.files(@req.base) file = files.path(result_filename) model = Modulobe::ModelFile.new(file) model.get_internal_info name = model.name author = model.author comment = model.comment comment ||= '' comment.gsub!(/\n/, "\\n") page = @site[@req.base] v = page.load page.add(" * #{name} {{modulobe_model(#{result_filename}) :title: #{name} :author: #{author} :comment: #{comment} }} {{mcomment}} ") list << [:hr] url = @req.base+'.html' list << [:p,_('Go next'),' : ',[:a,{:href=>url},url]] return c_surface(_('File attachment completed')){list} end
# File vendor/qwik/lib/qwik/modulobe.rb, line 20 def modulobe_image_link(file) image_file = file.to_s.sub(/\.mdlb\z/, '.gif').path base = file.basename('.mdlb').to_s+'.gif' return image_file, @req.base+'.files/'+base end
# File vendor/qwik/lib/qwik/modulobe.rb, line 15 def modulobe_model_link(file) base = file.basename.to_s return file, @req.base+'.files/'+base end
# File vendor/qwik/lib/qwik/modulobe.rb, line 26 def modulobe_thumb_link(file) base = file.basename('.mdlb').to_s+'.gif' thumb_file = file.dirname+'.thumb'+base return thumb_file, @req.base+'.files/.thumb/'+base end
# File vendor/qwik/lib/qwik/act-monitor.rb, line 59 def monitor_disconnect monitor_message('disconnect') end
# File vendor/qwik/lib/qwik/act-monitor.rb, line 63 def monitor_message(title) c_set_status c_set_html c_set_no_cache('no-cache', 'no-cache, must-revalidate') w = [:msg, title] w = w.format_xml.page_to_xml if ! $test c_set_body(w) end
# File vendor/qwik/lib/qwik/act-monitor.rb, line 47 def monitor_save c_set_status c_set_html c_set_no_cache('no-cache', 'no-cache, must-revalidate') page = @site[@req.base] str = page.get_body w = c_res(str) w = c_tdiary_resolve(w) w = w.format_xml.page_to_xml if ! $test c_set_body(w) end
# File vendor/qwik/lib/qwik/act-charset.rb, line 53 def my_char_ids(arg) return unless /\A[0-9]+\z/ =~ arg.to_s return "&my-#{arg};".de_er.char.ids.to_s end
# File vendor/qwik/lib/qwik/act-charset.rb, line 58 def my_char_kage_url return 'http://127.0.0.1:5100/' end
# File vendor/qwik/lib/qwik/act-new.rb, line 68 def new_already_exist(title, key) ar = [] ar << [:h2, _('Already exists')] form = new_form(title) { [:p, [:a, {:href=>key+'.html'}, [:strong, title]], _(' already exists.'), [:br], _('Please specify another title.')] } return new_tail(ar, form) end
# File vendor/qwik/lib/qwik/act-new.rb, line 79 def new_confirm(title) ar = [] ar << [:h2, _('Confirm')] form = new_form(title) { [:p, _('Push create.')] } return new_tail(ar, form) end
# File vendor/qwik/lib/qwik/act-new.rb, line 88 def new_form(title=nil) form = [:form, {:action=>'.new', :method=>'POST'}, [:dl, [:dt, _('Title')], [:dd, [:input, {:name=>'t', :value=>title, :class=>'focus'}]]]] form << yield if block_given? form << [:p, [:input, {:type=>'submit', :value=>_("New page")}]] end
# File vendor/qwik/lib/qwik/act-new.rb, line 62 def new_input_title ar = [] form = new_form return new_tail(ar, form) end
# File vendor/qwik/lib/qwik/act-new.rb, line 96 def new_tail(ar, form) ar << [:div, {:class=>'form'}, form] ar << [:hr] ar << [:p, [:a, {:href=>"FrontPage.html"}, _("Go back")]] return c_notice(_('New page')) { ar } end
# File vendor/qwik/lib/qwik/act-describe.rb, line 34 def notuse_plg_description_list_dl list = [:dl] self.description_list(@req.accept_language).each {|name| hash = description_get(name, @req.accept_language) list << [:dt, [:a, {:href=>"#{name}.describe"}, [:em, name], " | ", [:strong, hash[:dt]]]] list << [:dd, hash[:dd]] } return [:div, {:class=>'description-list'}, list] end
# File vendor/qwik/lib/qwik/act-config.rb, line 17 def notyet_ext_config method = "config_#{@req.base}" return c_nerror if ! self.respond_to?(method) return self.send(method) end
# File vendor/qwik/lib/qwik/act-under-const.rb, line 40 def notyet_ext_go_back_to_work c_notice('hello, world!'){'hi, there.'} end
¶ ↑
‘Go Back to Work.’ plugin Inspired from www.marktaw.com/getbacktowork.htm
# File vendor/qwik/lib/qwik/act-under-const.rb, line 36 def notyet_plg_go_back_to_work return [:strong, 'hello, world!'] end
# File vendor/qwik/lib/qwik/common-resolve.rb, line 25 def nu2_resolve_all_plugin(wabisabi) wabisabi.make_index return wabisabi.index_each_tag(:plugin) {|e| new_ele = resolve_plugin(e) e.replace(new_ele) } end
# File vendor/qwik/lib/qwik/act-history.rb, line 45 def nu_ext_history c_require_pagename c_require_member #c_require_page_exist # You can see the history of the deleted page. return c_nerror('no path args') if 0 < @req.path_args.length return c_nerror('no ext args') if 0 < @req.ext_args.length =begin divs = [] key = @req.base @site.backupdb.each_by_key(key) {|v, time| res = [:div, {:class=>'period'}, c_res(v)] divs << [:div, {:class=>'era', :id=>time.to_i.to_s}, res] } =end key = @req.base list = backup_list(@site, key) divs = list.map {|v, time| v = @site.backupdb.get(key, time) [:div, {:class=>'era', :id=>time.to_s}, [:div, {:class=>'period'}, c_res(v)]] } return history_show(@req.base, divs) end
# File vendor/qwik/lib/qwik/act-login.rb, line 72 def nu_login_create_login_link(msg='Login') sitename = @site.sitename pagename = @req.base href = '/.login' href += "?site=#{sitename}" if sitename href += "&page=#{pagename}" if pagename return [:a, {:href=>href}, msg] end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 113 def nu_plg_srecent(max = -1) max = max.to_i ar = [] now = @req.start_time list = @site.date_list overflow = nil list.reverse.each_with_index {|page, i| if 0 <= max && max < (i += 1) overflow = [:p,{:class=>'recent'}, [:a, {:href=>'RecentList.html'}, [:em, _('more...')]]] break end time = page.mtime difftime = now.to_i - time.to_i timestr = time.ymdx.to_s li = [:li, [:a, {:href=>"#{page.key}.html", :title=>timestr}, page.get_title]] if @req.user li += [' ', [:span, {:class=>'ago'}, int_to_time(difftime)+_(' ago')]] end ar << li } div = [:div, {:class=>'recent'}, [:ul, ar]] div << overflow if overflow return div end
# File vendor/qwik/lib/qwik/act-presen.rb, line 147 def nu_presen_get_theme(content) theme = 'i18n' wabisabi = c_res(content) wabisabi.each {|ele| if ele.is_a?(Array) && ele[0] == :plugin && ele.attr[:method] == 'presen_theme' theme = ele.attr[:param] end } theme end
Make index before call this method. Use parent.
# File vendor/qwik/lib/qwik/common-resolve.rb, line 17 def nunuresolve_all_plugin(wabisabi) #wabisabi.make_index wabisabi.index_each_tag(:plugin) {|e| resolve_plugin(e) } return wabisabi end
# File vendor/qwik/lib/qwik/act-redirect.rb, line 47 def old_redirect if @req.unparsed_uri url = @req.unparsed_uri else url = '/'+@req.path_args[0] end if /\A\/((?:http|https|ftp|file)):\// =~ url scheme = $1 url = url.sub(/\A\/#{scheme}:\//, "#{scheme}:/") end c_notice('redirect', url) { [:p, 'redirect', [:br], [:strong, url]] } end
# File vendor/qwik/lib/qwik/common-res.rb, line 12 def p_error(msg) return [:div, {:class=>'error'}, [:strong, _('Error'), ':'], ' ', msg] end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 33 def pagelist_get pagelist_path = @site.cache_path + "pagelist.dat" unless pagelist_path.exist? pagelist_update return [] end dat = pagelist_path.read ar = Marshal.load(dat) return ar end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 9 def pagelist_update running_path = @site.cache_path + "pagelist.dat.running" pagelist_path = @site.cache_path + "pagelist.dat" return if running_path.exist? Thread.new { running_path.write("running") ar = [] list = @site.date_list list.reverse.each {|page| key = page.key time = page.mtime.to_i title = page.get_title ar << [key, time, title] } dat = Marshal.dump(ar) pagelist_path.write(dat) running_path.unlink if running_path.exist? } end
# File vendor/qwik/lib/qwik/act-plan.rb, line 68 def plan_make_html(pages) day = 60 * 60 * 24 nowi = @req.start_time.to_i pages = pages.select {|pagekey, datei| page = @site[pagekey] diff = datei - nowi -day < diff } return nil if pages.empty? ul = [:ul] pages.sort_by {|pagekey, datei| datei }.each {|pagekey, datei| page = @site[pagekey] title = page.get_title date = Time.at(datei) now = Time.at(nowi) date_abbr = Time.date_abbr(now, date) em_title = Time.date_emphasis(now, date, title) ul << [:li, "#{date_abbr} ", [:a, {:href=>"#{pagekey}.html"}, em_title]] } return ul end
Only for demonstration for the PrettyBacktrace
function.
# File vendor/qwik/lib/qwik/common-backtrace.rb, line 10 def plg__qwik_test_for_raise_exception no_such_local_variable end
# File vendor/qwik/lib/qwik/act-style.rb, line 355 def plg_a(page, text=page) return [:a, {:href=>"#{page}.html"}, text] end
# File vendor/qwik/lib/qwik/act-aa.rb, line 9 def plg_aa content = yield return [:pre, {:class=>'aa'}, content] end
# File vendor/qwik/lib/qwik/act-basic.rb, line 155 def plg_act(act, msg=act) return [:a, {:href=>".#{act}"}, _(msg)] end
# File vendor/qwik/lib/qwik/act-metadata.rb, line 13 def plg_atom return rss_button('atom.xml', 'ATOM') end
# File vendor/qwik/lib/qwik/act-backup.rb, line 29 def plg_backup_list return if @req.user.nil? return if ! defined?(@req.base) || @req.base.nil? return page_attribute('backup', _('Show backup')) end
# File vendor/qwik/lib/qwik/act-sample.rb, line 94 def plg_bhello content = yield content = content.map {|line| "hello, #{line.chomp}!\n" }.join return [:pre, content] end
# File vendor/qwik/lib/qwik/act-style.rb, line 379 def plg_block_div(div_class='', a='', &b) return unless CSS.valid?(div_class) b = '' b = yield if block_given? msg = a.to_s + b.to_s x = c_res(msg) x << '' if x.empty? return [:div, {:class=>div_class}, *x] end
# File vendor/qwik/lib/qwik/act-book.rb, line 55 def plg_book(key) page = @site[BOOK_SEARCH] ar = [] ar << "book:#{key} " page.wikidb.array.each {|name, args| url, encoding = args sk = key sk = sk.to_sjis.escape if encoding == 'sjis' sk = sk.to_euc.escape if encoding == 'euc' sk = sk.to_utf8.escape if encoding == 'utf8' url = url.index("$1") ? url.sub(/\$1/, sk) : url+sk ar << [:a, {:href=>url}, name] ar << ' ' } return [:div, {:class=>'box'}, ar] end
# File vendor/qwik/lib/qwik/act-calc.rb, line 127 def plg_calc str = yield tokens = TextTokenizer.tokenize(str) table = [] sum = [] used_prefix = [] used_suffix = [] tokens.each {|token| case token[0] when :table col = [] token[1..-1].each_with_index {|t, i| prefix, n, suffix = Action.parse_num(t) col << t if n sum[i] ||= 0 if sum[i] != :NaN sum[i] += n end if prefix if used_prefix[i].nil? used_prefix[i] = prefix end end if suffix if used_suffix[i].nil? used_suffix[i] = suffix end end else sum[i] = :NaN end } table << col else return 'you can use only tables in calc plugin' end } if 0 < sum.length sum_str = [] sum.each_with_index {|s, i| if s == :NaN sum_str << '' else sum_str << [used_prefix[i], s.to_s, used_suffix[i]].join end } tokens << [:table, *sum_str] end tree = TextParser.make_tree(tokens) table = tree[0] last_tr = table.last last_tr.insert(1, {:class=>'sum'}) return tree end
# File vendor/qwik/lib/qwik/act-style.rb, line 401 def plg_center(a='', &b) return plg_style_div('text-align:center;', &b) end
# File vendor/qwik/lib/qwik/act-christel.rb, line 74 def plg_christel(width = 320) width = width.to_i.to_s content = yield message, image_url = Array(content) message.chomp! image_url.chomp! if image_url query_str = { :m => message.set_page_charset.to_euc, :u => image_url }.to_query_string url = "http://gedo-style.com/crstl/crstl.php?#{query_str}" return [:img, {:src=>url, :width=>width}] end
# File vendor/qwik/lib/qwik/act-code.rb, line 66 def plg_code(filename=nil, base_linenum=1) content = '' content = yield if block_given? pre = [:pre] content.each_line.with_index {|line, index| line.chomp! linenum = index + base_linenum.to_i klass = 'line ' klass += if linenum % 2 == 0 then 'even' else 'odd' end style = "background:url(.num/#{linenum}.png) no-repeat;" pre << [:span, {:class=>klass, :style=>style}, line] pre << "\n" } return [:div, {:class=>'code'}, pre] end
comment¶ ↑
# File vendor/qwik/lib/qwik/act-comment.rb, line 58 def plg_comment action = "#{@req.base}.comment" user = @req.user return [:div, {:class=>'comment'}, [:form, {:action=>action}, [:dl, [:dt, _('User')], [:dd, [:em, user]], [:dt, _('Message')], [:dd, [:textarea, {:name=>'msg', :cols=>'40', :rows=>'7'}, '']], [:dd, [:input, {:type=>'submit', :value=>'POST'}]]]]] end
# File vendor/qwik/lib/qwik/act-counter.rb, line 27 def plg_counter return [:div, {:class=>'counter'}, [:iframe, {:src=>"#{@req.base}.counter", :style=>' margin:0; padding:0; width:5em;height:1em; border: 0; '}, '']] end
# File vendor/qwik/lib/qwik/act-style.rb, line 434 def plg_css str = yield return 'error' unless CSS.valid?(str) return [:style, str] end
# File vendor/qwik/lib/qwik/act-style.rb, line 365 def plg_css_inhibit_pattern return plg_code { CSS::INHIBIT_PATTERN.join("\n") } end
# File vendor/qwik/lib/qwik/act-mail.rb, line 25 def plg_date(time_str = nil) return unless time_str.is_a?(String) if /\A\d+\z/ =~ time_str # Only number. time = Time.at(time_str.to_i) date = time.strftime("%b #{time.day}, %Y") return [:span, {:class=>'date'}, date] elsif /\A\d\d\d\d\-\d\d\-\d\d\z/ =~ time_str # 2005-04-19 return [:span, {:class=>'date'}, time_str] end return end
# File vendor/qwik/lib/qwik/act-charset.rb, line 17 def plg_define_char str = yield mode = nil i = nil h = {} tokens = c_tokenize(str) tokens.each {|t| e = t[0] case e when :dt # not yet. when :dd # not yet. when :definition_term_close, :definition_desc_close mode = nil when :normal_text s = t[:s] if mode == :definition_term_open i = s elsif mode == :definition_desc_open h[i] = s end end } if h['my'] c = "&my-#{h['my']};".de_er.char h.each {|k, v| c[k] = v } end return end
# File vendor/qwik/lib/qwik/act-describe.rb, line 45 def plg_description_list list = [:ul] self.description_list(@req.accept_language).each {|name| hash = description_get(name, @req.accept_language) list << [:li, [:a, {:href=>"#{name}.describe"}, [:em, name], ' ', [:strong, hash[:dt]]], ' ', hash[:dd]] } return [:div, {:class=>'description-list'}, list] end
# File vendor/qwik/lib/qwik/act-diary.rb, line 32 def plg_diary(include_days = 10) keys = [] @site.each {|page| if /\A#{@req.base}_(\d\d\d\d\d\d\d\d)\z/ =~ page.key keys << page.key end } recent_days = keys.sort.reverse[0, include_days] div = [] recent_days.each {|key| page = @site[key] div << [:h2, [:a, {:href=>page.url}, page.get_title]] div += plg_include(key) } return div end
# File vendor/qwik/lib/qwik/act-emode.rb, line 11 def plg_emode_date_link years = [] months = {} emode_each_month {|y, m| years << y unless years.include?(y) months[y] = [] if months[y].nil? months[y] << m } list = [:ul] years.each {|y| ar = [:li] ar << "20#{y} " months[y].each {|m| ar << [:a, {:href=>y+m+'.html'}, m] ar << ' ' } ar.pop list << ar } return [:div, list] end
# File vendor/qwik/lib/qwik/act-emode.rb, line 36 def plg_emode_include_recent max = 0 emode_each_month {|y, m| ym = (y+m).to_i max = ym if max < ym } str = sprintf('%04d', max) return plg_include(str) end
Show current event.¶ ↑
# File vendor/qwik/lib/qwik/act-event.rb, line 11 def plg_event(pagename=nil) return if defined?(@event_defined) @event_defined = true pagename ||= @req.base url = "#{pagename}.event" url = c_relative_to_root(url) ar = [] div = [:div, {:id=>'event'}] div << [:strong, 'plg_event'] if @config.debug ar << div ar << [:script, {:type=>'text/javascript', :src=>'.theme/js/event.js'}, ''] ar << [:script, {:type=>'text/javascript'}, " //alert('start'); g_eventwatcher.add('#{url}'); g_eventwatcher.start(); "] return ar end
# File vendor/qwik/lib/qwik/act-basic.rb, line 159 def plg_ext(ext, msg=ext) return [:a, {:href=>"#{@req.base}.#{ext}"}, _(msg)] end
# File vendor/qwik/lib/qwik/act-file.rb, line 10 def plg_file(f=nil, alt=f, base=@req.base) return if f.nil? encoded = Filename.encode(f) href = "#{base}.files/#{encoded}" download = "#{base}.download/#{encoded}" files = @site.files(base) if files.nil? || ! files.exist?(f) src = icon_path('broken') return [:div, {:class=>'ref'}, [:a, {:href=>href}, [:img, {:class=>'icon', :src=>src, :alt=>alt}], [:br], alt]] end src = thumb_check(f) if src return [:div, {:class=>'ref'}, [:a, {:href=>href}, [:img, {:class=>'thumb', :src=>src, :alt=>alt}], [:br], alt], [:br], [:a, {:href=>download}, 'download'] ] end ext = Filename.extname(f) src = icon_find(ext) if src return [:div, {:class=>'ref'}, [:a, {:href=>href}, [:img, {:class=>'icon', :src=>src, :alt=>alt}], [:br], alt], [:br], [:a, {:href=>download}, 'download'] ] end return [:div, {:class=>'ref'}, [:a, {:href=>href}, alt]] end
# File vendor/qwik/lib/qwik/act-files.rb, line 190 def plg_files_page_total total = @site.files(@req.base).total msg = sprintf(_("Total %s in this page"), total.byte_format) return [:span, msg] end
# File vendor/qwik/lib/qwik/act-files.rb, line 196 def plg_files_site_total total = @site.files_total max_total = @config[:max_total_file_size] warn_size = @config[:max_total_warn_size] msg = _("Attached files total:") + " #{total.byte_format}" if max_total < total msg = [msg + ", ", [:strong, _('Total file size exceeded.')]] elsif max_total - warn_size < total warn_msg = sprintf(_("%s left"), (max_total - total).byte_format) msg = [msg + ", ", [:strong ,warn_msg]] end return [:span, {:class => 'files_site_total'}, msg] end
# File vendor/qwik/lib/qwik/act-style.rb, line 389 def plg_float_left(a='', &b) return plg_style_div('float:left;', &b) end
# File vendor/qwik/lib/qwik/act-style.rb, line 393 def plg_float_right(a='', &b) return plg_style_div('float:right;', &b) end
# File vendor/qwik/lib/qwik/act-tableform.rb, line 14 def plg_form(dest=nil, method=nil) str = yield dest = @req.base unless dest && ! dest.empty? action = dest.to_s.escape action += '.html' if action[0] != ?. http_method = nil if method http_method = 'GET' if method == 'GET' http_method = 'POST' if method == 'POST' end hash = {:method=>http_method, :action=>action} hash.delete_if {|k, v| v.nil? } form = [:form, hash] form += c_res(str) return form end
# File vendor/qwik/lib/qwik/act-basic.rb, line 178 def plg_generate_time return nil if @req.user.nil? return [:span, {:class=>'attribute'}, _('Generation time'), ': ', [:em, "__qwik_page_generate_time__", _('seconds')]] end
Google AdSense¶ ↑
# File vendor/qwik/lib/qwik/act-webservice.rb, line 131 def plg_google_ad(id=nil) id ||= 'pub-5746941487859743' str = <<'EOT' google_ad_client = "#{id}"; google_alternate_color = 'eeeeee'; google_ad_width = 120; google_ad_height = 240; google_ad_format = '120x240_as'; google_ad_channel ='2257701812'; google_ad_type = 'text_image'; google_color_border = 'ffffff'; google_color_bg = 'ffffff'; google_color_link = '00cccc'; google_color_url = '00cc66'; google_color_text = '000000'; EOT return google_ad(str) end
hatena point¶ ↑
# File vendor/qwik/lib/qwik/act-webservice.rb, line 89 def plg_hatena_point(hatena_account) page = @site[@req.base] url = c_relative_to_absolute(page.url) rdf =[:'rdf:RDF', {:'xmlns:rdf'=>'http://www.w3.org/1999/02/22-rdf-syntax-ns#', :'xmlns:foaf'=>'http://xmlns.com/foaf/0.1/'}, [:'rdf:Description', {:'rdf:about'=>url}, [:'foaf:maker', {:'rdf:parseType'=>'Resource'}, [:'foaf:holdsAccount', [:'foaf:OnlineAccount', {:'foaf:accountName'=>hatena_account}, [:'foaf:accountServiceHomepage', {:'rdf:resource'=>'http://www.hatena.ne.jp/'}]]]]]] return [:span, {:class=>'hatena_point'}, rdf] end
Hiki style comment¶ ↑
# File vendor/qwik/lib/qwik/act-comment.rb, line 91 def plg_hcomment(style='0') action = @req.base+'.hcomment' style = style.to_i style = 0 if style != 1 # @hcomment_num is global for an action. @hcomment_num = 0 if !defined?(@hcomment_num) @hcomment_num += 1 num = @hcomment_num return [:div, {:class=>'hcomment'}, [:form, {:method=>'POST', :action=>action}, _('Name'), ': ', [:input, {:name=>'name', :size=>10}], ' ', _('Comment'), ': ', [:input, {:name=>'msg', :size=>50}], ' ', [:input, {:type=>'submit', :name=>'comment', :value=>_('Submit')}], [:input, {:type=>'hidden', :name=>'comment_no', :value=>num}], [:input, {:type=>'hidden', :name=>'style', :value=>style}]]] end
# File vendor/qwik/lib/qwik/act-sample.rb, line 90 def plg_hello(target='world') return [:strong, "hello, #{target}!"] end
# File vendor/qwik/lib/qwik/act-embed-html.rb, line 154 def plg_html return unless block_given? str = yield wabisabi = HtmlToWabisabi.parse(str) v = WabisabiValidator.valid?(wabisabi) if v == true return wabisabi else return "can not use [#{v}]" end end
# File vendor/qwik/lib/qwik/act-style.rb, line 359 def plg_img(f, alt=f, link=nil) img = [:img, {:src=>f, :alt=>alt}] img = [:a, {:href=>link}, img] if link return img end
# File vendor/qwik/lib/qwik/act-file.rb, line 60 def plg_imgfile(f=nil, alt=f, base=@req.base) return nil if f.nil? src = base+'.files/'+f return [:img, {:src=>src, :alt=>alt}] end
# File vendor/qwik/lib/qwik/act-include.rb, line 29 def plg_include(pagename) pagename = pagename.to_s page = @site[pagename] return nil if page.nil? org_base = @req.base @req.base = pagename body = surface_get_body(page) @req.base = org_base return body end
# File vendor/qwik/lib/qwik/act-interwiki.rb, line 43 def plg_interwiki(arg, *d) wiki, pagename = arg.split(':') return if pagename.nil? text = "#{wiki}:#{pagename}" text = yield if block_given? iw = @site.interwiki href = iw.href(wiki, pagename) return [:span, {:class=>'interwiki'}, text] if href.nil? [:a, {:href=>href, :class=>'interwiki'}, text] end
# File vendor/qwik/lib/qwik/act-book.rb, line 84 def plg_isbn(isbn, t=nil) isbn = isbn.to_s isbn1 = isbn.gsub(/ISBN/i, '') isbn2 = isbn1.gsub(/-/, '') a = @site.siteconfig['aid'] aid = "/#{a}" if a link = @site[ISBN_LINK] db = link.wikidb ar = [] msg = t msg = "isbn:#{isbn}" if t.nil? ar << msg ar << ' ' db.array.each {|name, args| args = args.dup url = args.shift next if url.nil? url = url.sub_str('#{isbn1}', isbn1) url = url.sub_str('#{isbn2}', isbn2) url = url.sub_str('#{aid}', aid) ar << [:a, {:href=>url}, name] ar << ' ' } return [:div, {:class=>'box'}, ar] end
# File vendor/qwik/lib/qwik/act-book.rb, line 73 def plg_isbn_amazon(isbn, t=nil) isbn = isbn.to_s msg = t msg = "isbn:#{isbn}" if t.nil? a = @site.siteconfig['aid'] aid = "/#{a}" if a return [:a, {:href=>"http://www.amazon.co.jp/exec/obidos/ASIN/#{isbn}#{aid}/ref=nosim/"}, msg] end
# File vendor/qwik/lib/qwik/act-keywords.rb, line 47 def plg_keywords(pagename=@req.base) return "no mecab" if ! $have_mecab page = @site[pagename] return if page.nil? content = page.get nodes = Action.nodes_get(content) hash = Hash.new { 0 } nodes.each {|surface, feature| hash[surface] += 1 } w = hash.keys.sort.map {|surface| num = Math.sqrt(hash[surface]) * CLOUD_BASE_FONT_SIZE num = CLOUD_MAX_FONT_SIZE if CLOUD_MAX_FONT_SIZE < num fontsize = "%.2fpx" % num href = "#{surface.escape}.search" [:a, {:style=>"font-size:#{fontsize};", :href=>href}, surface] } return [:div, {:class=>'keywords'}, *w] end
# File vendor/qwik/lib/qwik/act-lang.rb, line 9 def plg_lang(lang) # lang should be only two letters length. return 'error' unless /\A[a-z][a-z]\z/ =~ lang alang = @req.accept_language[0] return '' unless alang && alang == lang s = yield return c_res(s) end
# File vendor/qwik/lib/qwik/act-lang.rb, line 21 def plg_lang_select pagebase = @req.base if /\A([0-9A-Za-z]+)_([a-z][a-z])\z/ =~ @req.base pagebase = $1 lang = $2 end list = [] @req.accept_language.each {|lang| pagename_with_lang = "#{pagebase}_#{lang}" if @site.exist?(pagename_with_lang) #list << pagename_with_lang list << lang end } return nil if list.empty? list.unshift '' return list.map {|lang| page = "#{pagebase}" page = "#{pagebase}_#{lang}" if ! lang.empty? lang = "default" if lang.empty? [:a, {:href=>"#{page}.html"}, lang] } end
# File vendor/qwik/lib/qwik/act-basic.rb, line 169 def plg_last_modified return if ! defined?(@req.base) || @req.base.nil? page = @site[@req.base] return if page.nil? date = page.mtime return [:span, {:class=>'attribute'}, _('Last modified'), ': ', [:em, date.ymd]] end
# File vendor/qwik/lib/qwik/act-style.rb, line 397 def plg_left(a='', &b) return plg_style_div('text-align:left;', &b) end
# File vendor/qwik/lib/qwik/act-license.rb, line 22 def plg_license(license) text = license_text(license) return if text.nil? w = c_parse(text) return [:div, {:class=>'license'}] + w end
# File vendor/qwik/lib/qwik/act-list.rb, line 65 def plg_list content = nil content = yield if block_given? content ||= '' @list_num = 0 if ! defined?(@list_num) @list_num += 1 list_num = @list_num div = list_make_div(list_num, content) return div end
# File vendor/qwik/lib/qwik/act-login.rb, line 85 def plg_login_user return [:em, @req.user] end
# File vendor/qwik/lib/qwik/act-mail.rb, line 10 def plg_mail(from = '', time = nil) h2 = [:h2] h2 << plg_date(time) if time h2 << ' From: '+MailAddress.obfuscate(from) content = yield content = MailAddress.obfuscate_str(content) content = c_pre_text { content } ar = [] ar << h2 ar += content return ar end
# File vendor/qwik/lib/qwik/act-map.rb, line 28 def plg_map(clat, clng, mag=0) # Prepare maplink div. href = ".map?s=#{@req.sitename}&k=#{@req.base}" fullhref = "#{href}&m=full" #href = c_relative_to_root(href) #fullhref = c_relative_to_root(fullhref) href = "/#{href}" fullhref = "/#{fullhref}" div = [:div, {:class=>'maplink'}, [:iframe, {:src=>href, :style=>'width:700px;height:400px;border:0;'}, ''], [:br], [:div, {:style=>'margin: 0 0 1em 0;'}, [:a, {:href=>fullhref, :style=>'font-size:x-small;'}, _('Show map in full screen.')]]] content = yield elements = c_res(content) div += elements return div end
# File vendor/qwik/lib/qwik/act-comment.rb, line 196 def plg_mcomment(style='0', cols='50', rows='4') # @mcomment_num is global for an action. @mcomment_num = 0 if !defined?(@mcomment_num) @mcomment_num += 1 num = @mcomment_num style = style.to_i style = 0 if style != 1 action = "#{@req.base}.#{num}.#{style}.mcomment" content = '' content = yield if block_given? messages = mcomment_construct_messages(content) div = [:div, {:class=>'mcomment'}] div += messages if style == 0 form = [:form, {:method=>'POST', :action=>action}, [:p, _('Name'), ': ', [:input, {:name=>'u', :size=>'30'}]], [:p, _('Comment'), ': ', [:textarea, {:name=>'m', :cols=>cols, :rows=>rows}, '']], [:input, {:type=>'submit', :value=>_('Submit')}]] form = [:form, {:method=>'POST', :action=>action}, [:table, [:tr, [:th, _('Name')], [:td, [:input, {:name=>'u', :size=>'30'}]]], [:tr, [:th, _('Comment')], [:td, [:textarea, {:name=>'m', :cols=>cols, :rows=>rows}, '']]], [:tr, [:th, ''], [:td, [:input, {:type=>'submit', :value=>_('Submit')}]]]]] div << form div += messages if style == 1 return div end
Thanks to Mr. Shuhei Yamamoto.
# File vendor/qwik/lib/qwik/act-mlsubmitform.rb, line 18 def plg_ml_submit_form href = "/formmail.php?user=#{@req.user}&site=#{@site.sitename}" return [:a, {:href=>href, :target=>'_new'}, _('Mlcommit')] end
upload¶ ↑
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 275 def plg_modulobe_files_form(pagename=nil) base = @req.base base = pagename if pagename ar = [] ar << [:style, ' div.modulobe_uploader { margin: 10px 0; padding: 10px; border: 1px solid #ccc; background-color: #fff; } div.modulobe_uploader table { margin: 0; padding: 0; border: 0; width: 100%; } div.modulobe_uploader td, div.modulobe_uploader th { margin: 0; padding: 2px 10px; border: 0; } div.modulobe_uploader th { text-align: right; } div.modulobe_uploader td input { font-size: small; } '] ar << [:div, {:class=>'modulobe_uploader'}, [:form, {:method=>'POST', :action=>base+'.modulobe_files_upload', :enctype=>'multipart/form-data'}, [:table, [:tr, [:th, _('Model file'), ' : '], [:td, [:input, {:type=>'file', :name=>'content', :size=>'30'}]]], [:tr, [:th, _('Image file'), ' : '], [:td, [:input, {:type=>'file', :name=>'image', :size=>'30'}]]], [:tr, [:td, ''], [:td, [:input, {:type=>'submit', :value=>_('Attach')}]]]]]] return ar end
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 79 def plg_modulobe_model(model) div = [:div, {:class=>'modulobe_model'}] # image files = @site.files(@req.base) file = files.path(model) return [:div, 'No file exist.'] if ! file.exist? model = Modulobe::ModelFile.new(file) href, url, img = model.prepare_link(self, "#{@req.base}.files") # description content = yield #tokens = c_tokenize(content) tokens = TextTokenizer.tokenize(content) author = 'anonymous' title = 'no title' comment = 'no comment' tokens.each {|token| if token[0] == :dl author = token[2] if token[1] == 'author' title = token[2] if token[1] == 'title' comment = token[2] if token[1] == 'comment' end } comment.gsub!(/\\n/, "\n") comment = c_res(comment) desc = [[:h3, [:a, {:href=>href}, title]], [:p, _('Author'), ': ', [:strong, author]], [:p, comment]] table = [:table, [:tr, [:td, {:class=>'img'}, img], [:td, {:class=>'desc'}, desc]]] div << table if ! defined?(@modulobe_model_style) @modulobe_model_style = true div << [:style, MODULOBE_MODEL_STYLE] end return div end
list¶ ↑
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 129 def plg_modulobe_model_list pagename = @req.base page = @site[pagename] return if page.nil? files = @site.files(pagename) page.cache[:modellist] ||= Modulobe::ModelList.new(files) modellist = page.cache[:modellist] return if modellist.empty? div = [:div, {:class=>'files'}] path = c_relative_to_root(pagename+'.files') div << modellist.get_table(self, path) div << modellist.get_style return div end
monitor plugin¶ ↑
# File vendor/qwik/lib/qwik/act-monitor.rb, line 20 def plg_monitor(pagename=@req.base) return if defined?(@monitor_defined) @monitor_defined = true script = " g_monitor_env.add('#{pagename}'); g_monitor_env.start(); " div = [:div, {:id=>'monitor'}] div << "monitor(#{pagename})" if defined?($test) && $test div << [:script, {:type=>'text/javascript', :src=>'.theme/js/monitor.js'}, ''] div << [:script, {:type=>'text/javascript'}, script] return div end
# File vendor/qwik/lib/qwik/act-style.rb, line 444 def plg_monta(*a) element = :span txt = a.shift if block_given? element = :div txt = yield end return if txt.nil? return [element, {:style=>MONTA_STYLE, :onmouseup=>MONTA_SCRIPT}, txt] end
# File vendor/qwik/lib/qwik/act-charset.rb, line 62 def plg_my_char(arg) ids = my_char_ids(arg).to_utf8 return if ids.empty? ids = ids.de_er n = ids.gsub(/#0/, CHISE::IDC_LR). gsub(/#1/, CHISE::IDC_AB). gsub(/#2/, CHISE::IDC_LM). gsub(/#3/, CHISE::IDC_AM). gsub(/#4/, CHISE::IDC_FS). gsub(/#5/, CHISE::IDC_FA). gsub(/#6/, CHISE::IDC_FB). gsub(/#7/, CHISE::IDC_FL). gsub(/#8/, CHISE::IDC_UL). gsub(/#9/, CHISE::IDC_UR). gsub(/#a/i, CHISE::IDC_LL). gsub(/#b/i, CHISE::IDC_OV) ids = n base = ids.to_a.map {|ch| sprintf('u%04x',ch.ucs) }.join pngfile = "#{base}.gothic.png" return [:img, {:src=>"#{my_char_kage_url}#{pngfile}", :style=>"width:1em;", :alt=>pngfile}] end
# File vendor/qwik/lib/qwik/act-plan.rb, line 64 def plg_new_plan return [:a, {:href=>'.plan'}, _('Create a new plan')] end
Multiline comment¶ ↑
# File vendor/qwik/lib/qwik/act-comment.rb, line 186 def plg_nomore_mcomment(style='0', cols='50', rows='4') # Just show the content. No more post. content = '' content = yield if block_given? messages = mcomment_construct_messages(content) div = [:div, {:class=>'mcomment'}] div += messages return div end
# File vendor/qwik/lib/qwik/act-license.rb, line 9 def plg_notice msg = yield w = c_parse(msg) div = [:div, {:class=>'notice'}] + w return div end
# File vendor/qwik/lib/qwik/act-basic.rb, line 192 def plg_only_member return nil if @req.user.nil? s = yield return if s.nil? return c_res(s) end
# File vendor/qwik/lib/qwik/act-password.rb, line 36 def plg_password(pass=nil) # password plugin is parsed in act-edit.rb return nil end
# File vendor/qwik/lib/qwik/act-plan.rb, line 55 def plg_plan div = [:div, [:h2, _('Plan')]] pages = @site.get_pages_with_date return if pages.empty? div << plan_make_html(pages) div << [:p, plg_new_plan] return div end
meta function¶ ↑
# File vendor/qwik/lib/qwik/act-basic.rb, line 212 def plg_plugin_list desc = descriptions_hash plg_desc = plugin_descriptions(desc) ul = [:ul] plugin_list.each {|plugin_name| if plg_desc[plugin_name] desc_link = plg_desc[plugin_name].first ul << [:li, [:a, {:href=>"#{desc_link}.describe"}, plugin_name]] else ul << [:li, plugin_name] end } return ul end
# File vendor/qwik/lib/qwik/act-povray.rb, line 60 def plg_povray if ! povray_exist? return [:div, {:class=>'povray'}, [:p, 'No povray command.'] ] end # Generate a povray file. content = '' content = yield if block_given? pngfilename, stapath = povray_generate(content) # @povray_num is global for an action. @povray_num = 0 if ! defined?(@povray_num) @povray_num += 1 action = "#{@req.base}.#{@povray_num}.povray" cols = 0 rows = 1 # Add an empty line. content.each_line {|line| len = line.chomp.length cols = len if cols < len rows += 1 } cols = MIN_COLS if cols < MIN_COLS rows = MIN_ROWS if rows < MIN_ROWS cols = MAX_COLS if MAX_COLS < cols rows = MAX_ROWS if MAX_ROWS < rows status = [:div, {:class=>'status'}] begin sta = stapath.read st, et = sta.to_a status << [:p, 'Start : ', Time.at(st.to_i).ymdax] if st status << [:p, 'End : ', Time.at(et.to_i).ymdax] if et status << [:p, 'Past : ', Time.at(et.to_i).ymdax] if et rescue status << [:p, 'The rendering is started.'] end div = [:div, {:class=>'povray'}, [:img, {:src=>"#{@req.base}.files/#{pngfilename}"}], [:br], [:form, {:method=>'POST', :action=>action}, [:textarea, {:name=>'t', :cols=>cols, :rows=>rows}, content], [:br], [:input, {:type=>'submit', :value=>_('Update')}]], [:br], status] return div end
# File vendor/qwik/lib/qwik/act-text.rb, line 14 def plg_pre_text str = yield return c_pre_text { str } end
# File vendor/qwik/lib/qwik/act-presen.rb, line 59 def plg_presen return nil if ! defined?(@req.base) || @req.base.nil? return page_attribute('presen', _('Presentation mode')) end
# File vendor/qwik/lib/qwik/act-presen.rb, line 53 def plg_presen_switch return nil if ! defined?(@req.base) || @req.base.nil? return plg_ext('presen', _('Present')) if /^Presen/ =~ @req.base return nil end
# File vendor/qwik/lib/qwik/act-presen.rb, line 65 def plg_presen_theme(theme) return # Do nothing. end
# File vendor/qwik/lib/qwik/act-presen.rb, line 69 def plg_presen_theme_list return [:ul, *presen_theme_list.map {|t| [:li, t] }] end
# File vendor/qwik/lib/qwik/act-sample.rb, line 112 def plg_quote text = '' text = yield if block_given? ar = [] text.each {|line| ar << line ar << [:br] } bq = [:blockquote, [:p, {:style=>'font-size:smaller;'}, *ar]] return bq end
# File vendor/qwik/lib/qwik/act-basic.rb, line 117 def plg_qwik_test return 'test' end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 69 def plg_recent_list(max = -1) return c_res(recent_str(max)) end
# File vendor/qwik/lib/qwik/act-style.rb, line 405 def plg_right(a='', &b) return plg_style_div('text-align:right;', &b) end
# File vendor/qwik/lib/qwik/act-ring.rb, line 477 def plg_ring_date(n) time = Time.at(n.to_i) return [:span, {:class=>'ring_date'}, time.ymdx] end
# File vendor/qwik/lib/qwik/act-ring.rb, line 576 def plg_ring_get_user_from_pagename(pagename) page = @site.get_superpage(RING_MEMBER) return if page.nil? page.wikidb.each {|k, ar| if ar[4] == pagename return k end } return '' end
invite¶ ↑
Show invite form
# File vendor/qwik/lib/qwik/act-ring.rb, line 105 def plg_ring_invite_form(dest=nil) action = "#{@req.base}.ring_invite" your_mail = plg_ring_show('mail') your_username = plg_ring_show('user') your_name = plg_ring_show('name') guest_mail = 'guest@example.com' w = [:div, {:class=>'form'}, [:form, {:method=>'POST', :action=>action}, [:table, [:tr, [:th, _r(:BULLET)+_r(:YOUR_MAIL)], [:td, your_mail]], [:tr, [:th, _r(:BULLET)+_r(:YOUR_USER)], [:td, your_username]], [:tr, [:th, _r(:BULLET)+_r(:YOUR_NAME)], [:td, your_name]], [:tr, [:th, _r(:BULLET)+_r(:MAIL)], [:td, [:textarea, {:cols=>'40', :rows=>'4', :name=>'guest_mail'}, guest_mail]]], [:tr, [:td, {:class=>'msg', :colspan=>2}, _r(:INVITE_INPUT_GUEST_MAIL)]], [:tr, [:th, _r(:BULLET)+_r(:MESSAGE)], [:td, [:textarea, {:cols=>'40', :rows=>'7', :name=>'message'}, _r(:INVITE_MESSAGE_DUMMY_TEXT)]]], [:tr, [:td, {:class=>'msg', :colspan=>2}, _r(:INVITE_DESC)]], [:tr, [:th, ''], [:td, [:input, {:type=>'submit', :class=>'submit', :value=>_r(:INVITE_DO_INVITE)}]]]]]] return w end
# File vendor/qwik/lib/qwik/act-ring.rb, line 143 def plg_ring_invite_go(arg=nil) # obsolete return end
# File vendor/qwik/lib/qwik/act-ring.rb, line 255 def plg_ring_invite_list(arg=nil) page = @site.get_superpage(RING_INVITE_MEMBER) return if page.nil? ar = page.wikidb.hash.to_a dl = [:dl] ar.reverse.each {|k, v| guest_mail = k guest_name, host_mail, message, time = v ymd = '' if time.is_a? String time = Time.at(time.to_i) ymd = time.ymd end userlink = plg_ring_ul(host_mail) dt = [:dt, userlink, "#{_r(:RIGHT_ARROW)}#{guest_name} (#{guest_mail}) #{ymd}"] dd = [:dd, message] dl << dt dl << dd } return [:div, {:class=>'ring_invite_list'}, dl] end
# File vendor/qwik/lib/qwik/act-ring.rb, line 558 def plg_ring_link(mail) user = plg_ring_user(mail, 'user') if user.nil? || user.empty? doc = c_res("[[anonymous]]") return doc[0][1] end pagename = plg_ring_user(mail, 'pagename') if pagename.nil? || pagename.empty? key = "[[#{user}]]" else key = "[[#{user}|#{pagename}]]" if pagename end doc = c_res(key) return doc[0][1] end
maker¶ ↑
make user page from template¶ ↑
colinux:9190/ring.sfc.keio.ac.jp/_TestActRingMaker.html
# File vendor/qwik/lib/qwik/act-ring.rb, line 284 def plg_ring_make_form(dest=nil) action = "#{@req.base}.ring_make" mail = @req.user return [:div, {:class=>'form'}, [:form, {:action=>action, :method=>'POST'}, [:table, [:tr, [:th, _r(:BULLET)+_r(:MAIL)], [:td, mail]], [:tr, [:th, _r(:BULLET)+_r(:NAME)], [:td, [:input, {:name=>'username'}]]], [:tr, [:td, {:class=>'msg', :colspan=>2}, _r(:MAKER_USER_NAME_DESC)]], [:tr, [:th, _r(:BULLET)+_r(:REALNAME)], [:td, [:input, {:name=>'realname'}]]], [:tr, [:th, _r(:BULLET)+_r(:NYUUGAKU_GAKUBU)], [:td, [:select, {:name=>'faculty'}, [:option, {:name=>_r(:FACULTY_SS)}, _r(:FACULTY_SS)], [:option, {:name=>_r(:FACULTY_EI)}, _r(:FACULTY_EI)], [:option, {:name=>_r(:FACULTY_KI)}, _r(:FACULTY_KI)], [:option, {:name=>_r(:FACULTY_SM)}, _r(:FACULTY_SM)]]]], [:tr, [:th, _r(:BULLET)+_r(:NYUUGAKU_NENDO)], [:td, [:select, {:name=>'year'}, [:option, {:name=>'1990'}, '1990'], [:option, {:name=>'1991'}, '1991'], [:option, {:name=>'1992'}, '1992'], [:option, {:name=>'1993'}, '1993'], [:option, {:name=>'1994'}, '1994'], [:option, {:name=>'1995'}, '1995'], [:option, {:name=>'1996'}, '1996'], [:option, {:name=>'1997'}, '1997'], [:option, {:name=>'1998'}, '1998'], [:option, {:name=>'1999'}, '1999'], [:option, {:name=>'2000'}, '2000'], [:option, {:name=>'2001'}, '2001'], [:option, {:name=>'2002'}, '2002'], [:option, {:name=>'2003'}, '2003']]]], [:tr, [:th, ''], [:td, [:input, {:value=>_r(:MAKER_REGISTER), :type=>'submit', :class=>'submit'}]]]]]] end
# File vendor/qwik/lib/qwik/act-ring.rb, line 331 def plg_ring_make_go(arg=nil) return # obsolete end
msg¶ ↑
write a message¶ ↑
colinux:9190/ring.sfc.keio.ac.jp/_TestActRingMsg.html
# File vendor/qwik/lib/qwik/act-ring.rb, line 419 def plg_ring_message_form(arg=nil) action = "#{@req.base}.ring_msg" username = @req.user div = [:div, {:class=>'form'}, [:form, {:method=>'POST', :action=>action}, [:table, [:tr, [:th, _r(:BULLET)+_r(:USER)], [:td, username]], [:tr, [:th, _r(:BULLET)+_r(:MESSAGE)], [:td, [:textarea, {:name=>'message', :cols=>'40', :rows=>'7'}, _r(:MSG_INPUT_HERE)]]], [:tr, [:th, ''], [:td, [:input, {:type=>'submit', :class=>'submit', :value=>" POST! "}]]]]]] return div end
# File vendor/qwik/lib/qwik/act-ring.rb, line 439 def plg_ring_message_go(arg=nil) return # obsolete end
see the personal information of this page
# File vendor/qwik/lib/qwik/act-ring.rb, line 598 def plg_ring_personal_info return [:dl, [:dt, _r(:NAME)+' E-mail'], [:dd, plg_ring_see(:name), " <", plg_ring_see(:mail), ">"], [:dt, _r(:NYUGAKU)], [:dd, plg_ring_see(:year), _r(:YEAR)+' ', plg_ring_see(:faculty)]] end
see the information of the owner of this page
# File vendor/qwik/lib/qwik/act-ring.rb, line 590 def plg_ring_see(arg) pagename = @req.base user = plg_ring_get_user_from_pagename(pagename) return '' if user.nil? return plg_ring_user(user, arg) end
ring_user_link
# File vendor/qwik/lib/qwik/act-ring.rb, line 607 def plg_ring_ul(mail) span = [:span, {:class=>'ring_ul'}] user = plg_ring_user(mail, 'user') if user.nil? return span << mail end userpage = plg_ring_user(mail, 'pagename') if userpage.nil? return span << user end return span << [:a, {:href=>"#{userpage}.html"}, user] end
show user information¶ ↑
# File vendor/qwik/lib/qwik/act-ring.rb, line 536 def plg_ring_user(mail, type) ar = ring_user_info(RING_MEMBER, mail) return nil if ar.nil? type = type.to_s # Primary key is the mail address. return mail if type == 'mail' # You can select the values from these types. types = %w(user name faculty year pagename time) typenum = types.index(type) return nil if typenum.nil? return ar[typenum] end
# File vendor/qwik/lib/qwik/act-metadata.rb, line 9 def plg_rss return rss_button('rss.xml', 'RSS') end
# File vendor/qwik/lib/qwik/act-ruby.rb, line 26 def plg_ruby(*argv) return [:p, "Ruby plugin is not enabled."] if ! @config.enable_ruby return if ! block_given? ruby_code = yield require 'date' th = Thread.new { $SAFE = 4 eval(ruby_code) } result = th.value.to_s wabisabi = HTree(result).to_wabisabi return [:p, wabisabi] end
# File vendor/qwik/lib/qwik/act-schedule.rb, line 22 def plg_schedule content = nil content = yield if block_given? if content.nil? || content.empty? # no contents now = @req.start_time content = Action.schedule_default_content(now) end w = c_parse(content) return p_error(_('You can only use a table.')) if 1 < w.length table = w[0] if table.nil? || table[0] != :table return p_error(_('You can only use a table.')) end if WabisabiTable.error_check(table) return p_error(_('You can only use text.')) end WabisabiTable.prepare(table) # @schedule_num is global for an action. @schedule_num = 0 if !defined?(@schedule_num) @schedule_num += 1 num = @schedule_num action = "#{@req.base}.#{num}.schedule" div = [:div, {:class=>'table'}, [:form, {:method=>'POST', :action=>action}, table, [:div, {:class=>'submit'}, [:input, {:type=>'submit', :value=>_('Update')}]]]] return div end
# File vendor/qwik/lib/qwik/act-search.rb, line 38 def plg_search_form(focus = false) return search_form(focus) end
# File vendor/qwik/lib/qwik/act-searchwords.rb, line 10 def plg_search_word_cloud list = @site.get_search_words [:span] + list.map{|em| w = em.word.to_s.escape if em.nil? em = Word.new(w, 1, Time.new) end [[:span, {:class => "search_word#{em.count}"}, [:a, {:href => ".search?q=#{w}"}, em.word]], [:span, {:class => "search_word_delete"}, [:a, {:href => ".delete?q=#{w}"}, [:img, {:src => ".theme/css/delete.png",:border =>"0", :alt => "del"}]]]] } end
# File vendor/qwik/lib/qwik/act-aa.rb, line 14 def plg_show_aa(type=nil, message=nil, &b) s = aa_get(type, message, &b) return [:pre, {:class=>'aa'}, s] end
# File vendor/qwik/lib/qwik/act-history.rb, line 30 def plg_show_history return if @req.user.nil? return if ! defined?(@req.base) || @req.base.nil? return page_attribute('history', _('Show history')) end
# File vendor/qwik/lib/qwik/act-plan.rb, line 47 def plg_side_plan div = [:div, [:h2, _('Plan')]] pages = @site.get_pages_with_date div << plan_make_html(pages) if ! pages.empty? div << [:p, plg_new_plan] return div end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 74 def plg_side_recent(*a) return [ [:h2, _('Recent change')], plg_srecent(*a) ] end
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 58 def plg_sitebackup return "no tar command" if ! SiteBackup.command_exist? return page_attribute('sitebackup', _('Site backup'), @site.sitename) end
sitelog viewer
# File vendor/qwik/lib/qwik/act-sitelog.rb, line 28 def plg_sitelog dl = [:dl] @site.sitelog.list.each {|k, v| user, cmd, pagename = v user = 'anonymous' if user.nil? || user.empty? user = MailAddress.obfuscate(user) if ! user.empty? dl << [:dt, "#{Time.at(k.to_i).ymdx} - #{user}"] dl << [:dd, "#{cmd}: ", [:a, {:href=>"#{pagename}.html"}, pagename]] } return dl end
# File vendor/qwik/lib/qwik/act-style.rb, line 430 def plg_small(a='', &b) return plg_style_span('font-size:smaller;', a, &b) end
# File vendor/qwik/lib/qwik/act-smil.rb, line 31 def plg_smil(title=nil) @smil_num = 0 if !defined?(@smil_num) @smil_num += 1 file = "#{@req.base}.#{@smil_num}.smil" str = yield title = file if title.nil? gen = SmilGenerator.new gen.parse(str) smil = gen.generate_smil smil_str = smil.format_xml.page_to_xml # make it to utf8 @site.files(@req.base).put(file, smil_str, true) # override table = gen.generate_html div = [:div, {:class=>'smil'}, table, [:p, [:a, {:href=>file}, file]]] return div end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 81 def plg_srecent(max = -1) max = max.to_i ar = [] now = @req.start_time list = pagelist_get overflow = nil list.each_with_index {|a, i| if 0 <= max && max < (i += 1) overflow = [:p,{:class=>'recent'}, [:a, {:href=>'RecentList.html'}, [:em, _('more...')]]] break end key, t, title = a time = Time.at(t) difftime = now.to_i - time.to_i timestr = time.ymdx.to_s li = [:li, [:a, {:href=>"#{key}.html", :title=>timestr}, title]] if @req.user li += [' ', [:span, {:class=>'ago'}, int_to_time(difftime)+_(' ago')]] end ar << li } div = [:div, {:class=>'recent'}, [:ul, ar]] div << overflow if overflow return div end
# File vendor/qwik/lib/qwik/act-style.rb, line 369 def plg_style_div(style='', a='', &b) return unless CSS.valid?(style) b = '' b = yield if block_given? msg = a.to_s + b.to_s x = c_res(msg) x << '' if x.empty? return [:div, {:style=>style}, *x] end
# File vendor/qwik/lib/qwik/act-style.rb, line 409 def plg_style_span(style='', a='') return unless CSS.valid?(style) b = '' b = yield if block_given? msg = a.to_s + b.to_s x = c_res(msg) w = x[0] war = [] if w.nil? war << '' elsif w.first == :p w.shift war += w else war << w end return [:span, {:style=>style}, *war] end
Bloglines¶ ↑
# File vendor/qwik/lib/qwik/act-webservice.rb, line 115 def plg_sub_bloglines(url=nil, icon='modern4') return unless /\A[a-z0-9]+\z/ =~ icon url = @site.site_url if url.nil? button = [:a, {:href=>"http://www.bloglines.com/sub/#{url}"}, [:img, {:src=>"http://www.bloglines.com/images/sub_#{icon}.gif", :border=>'0', :alt=>'subscribe Bloglines'}]] return button end
# File vendor/qwik/lib/qwik/act-calc.rb, line 76 def plg_tab_calc str = yield table = Action.tab_to_table(str) WabisabiTable.fill_empty_td(table) Action.table_calc(table) return table end
# File vendor/qwik/lib/qwik/act-table.rb, line 40 def plg_table content = nil content = yield if block_given? if content.nil? || content.empty? # no contents content = Action.table_default_content end w = c_parse(content) return p_error(_('You can only use a table.')) if 1 < w.length table = w[0] if table.nil? || table[0] != :table return p_error(_('You can only use a table.')) end if WabisabiTable.error_check(table) return p_error(_('You can only use text.')) end WabisabiTable.prepare(table) # @table_num is global for an action. @table_num = 0 if !defined?(@table_num) @table_num += 1 num = @table_num action = "#{@req.base}.#{num}.table" div = [:div, {:class=>'table'}, [:form, {:method=>'POST', :action=>action}, table, [:div, {:class=>'submit'}, [:input, {:type=>'submit', :value=>_('Update')}]]]] return div end
# File vendor/qwik/lib/qwik/act-tableform.rb, line 9 def plg_tableform(dest=nil) content = yield return TableForm.generate(self, dest, content, @req.base) end
# File vendor/qwik/lib/qwik/act-text.rb, line 9 def plg_text str = yield return c_res(str) end
# File vendor/qwik/lib/qwik/act-textarea.rb, line 42 def plg_textarea # @textarea_num is global for an action. @textarea_num = 0 if ! defined?(@textarea_num) @textarea_num += 1 action = "#{@req.base}.#{@textarea_num}.textarea" content = '' content = yield if block_given? cols = rows = 1 content.each {|line| len = line.chomp.length cols = len if cols < len rows += 1 } cols = TEXTAREA_MIN_COLS if cols < TEXTAREA_MIN_COLS rows = TEXTAREA_MIN_ROWS if rows < TEXTAREA_MIN_ROWS cols = TEXTAREA_MAX_COLS if TEXTAREA_MAX_COLS < cols rows = TEXTAREA_MAX_ROWS if TEXTAREA_MAX_ROWS < rows return [:div, {:class=>'textarea'}, [:form, {:method=>'POST', :action=>action}, [:textarea, {:name=>'t', :cols=>cols, :rows=>rows}, content], [:br], [:input, {:type=>'submit', :value=>_('Update')}]]] end
theme_list
¶ ↑
# File vendor/qwik/lib/qwik/act-theme.rb, line 112 def plg_theme_list return [:ul, *theme_list.map {|t| [:li, t] }] end
# File vendor/qwik/lib/qwik/act-mlsubmitform.rb, line 13 def plg_thislist return @site.ml_address end
# File vendor/qwik/lib/qwik/act-mlsubmitform.rb, line 9 def plg_thissitename return @site.title end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 54 def plg_title_list str = @site.title_list.map {|page| "- #{page.mtime.ymd} : [[#{page.key}]]" }.join("\n") return c_res(str) end
# File vendor/qwik/lib/qwik/act-toc.rb, line 49 def plg_toc # deleted return nil end
# File vendor/qwik/lib/qwik/act-webservice.rb, line 189 def plg_translate(lang, message=nil) if lang == 'ej' lp = 'ENJA' elsif lang == 'je' lp = 'JAEN' else return nil end page = @site[@req.base] return if page.nil? full_url = c_relative_to_absolute(page.url) #base = 'http://www.excite.co.jp/world/english/web/' base = 'http://www.excite.co.jp/world/english/web/proceeding/' url = "#{base}?wb_lp=#{lp}&wb_url=#{full_url}" if message.nil? message = 'translate' if lang == 'ej' message += ' (e->j)' elsif lang == 'je' message += ' (j->e)' end end e = [:a, {:href=>url}, message] return e end
# File vendor/qwik/lib/qwik/act-webservice.rb, line 185 def plg_translate_je(msg=nil) return plg_translate('je', msg) end
# File vendor/qwik/lib/qwik/act-sample.rb, line 108 def plg_tt(text) return [:tt, text] end
# File vendor/qwik/lib/qwik/act-smil.rb, line 53 def plg_video(*args) name = @req.base name = args.shift if 0 < args.length msg = yield v = Video.new(@site, name) v.parse(msg) v.generate_file return v.to_xml end
warning for CSS
¶ ↑
# File vendor/qwik/lib/qwik/act-theme.rb, line 220 def plg_warning_for_css content, type = css_get_from_site_theme('theme.css') return nil if content.nil? if content != INVALID_CSS_INDICATOR return [:span, 'Attached CSS content is safe.'] else return [:strong, 'Invalid elements are used in your CSS file.'] end end
# File vendor/qwik/lib/qwik/act-wysiwyg.rb, line 46 def plg_watch(pagename=@req.base, ext=nil) ext ||= 'html' return if defined?(@watch_defined) @watch_defined = true #//alert('hi'); script = " g_watcher_env.add('#{pagename}', '#{ext}'); g_watcher_env.start(); g_weditor.init('#{pagename}', '#{ext}'); g_weditor.check(); " md5 = @site[pagename].get.md5hex div = [:div, {:id=>'watch'}] if @config.debug || defined?($test) && $test # div << "watch(#{pagename})" end div << [:input, {:type=>'hidden', :name=>'watch_md5', :value=>md5}] div << [:script, {:type=>'text/javascript', :src=>'.theme/js/watch.js'}, ''] div << [:script, {:type=>'text/javascript'}, script] return div end
# File vendor/qwik/lib/qwik/act-wema.rb, line 64 def plg_wema return if @site[@req.base].nil? return if defined?(@wema_generated) wp = WemaPage.new(@site, @site[@req.base]) wemas = wp.get_wemas @wema_generated = true return WemaHtmlGenerator.generate(wemas, @req.base) end
Show only if there is already wema.
# File vendor/qwik/lib/qwik/act-wema.rb, line 51 def plg_wema_compat return if @site[@req.base].nil? return if defined?(@wema_generated) wp = WemaPage.new(@site, @site[@req.base]) wemas = wp.get_wemas if wemas.empty? # create wema link. return [:a, {:href=>'PluginWema.describe'}, _('Post-it')] end @wema_generated = true return WemaHtmlGenerator.generate(wemas, @req.base) end
# File vendor/qwik/lib/qwik/act-wysiwyg.rb, line 40 def plg_wysiwyg return if @req.user.nil? return page_attribute('wysiwyg', _('Edit in this page')) end
# File vendor/qwik/lib/qwik/act-archive.rb, line 49 def plg_zip return page_attribute('zip', _('Site archive'), @site.sitename) end
# File vendor/qwik/lib/qwik/act-basic.rb, line 245 def plugin_descriptions(desc) plg_desc = {} desc.each {|k, v| v.each {|line| if /\{\{([a-z_]+)/ =~ line name = $1 plg_desc[name] = [] if ! plg_desc[name] if ! plg_desc[name].include? k plg_desc[name] << k end end } } return plg_desc end
rewrite plugin¶ ↑
# File vendor/qwik/lib/qwik/common-basic.rb, line 46 def plugin_edit(plugin_name, plugin_num) # Get the original page. page = @site[@req.base] str = page.load md5 = str.md5hex # Split the page into paragraphs. paragraphs = Plugin.split(str) # Replace the content of the plugin. written = false new_paras = Plugin.rewrite(paragraphs, plugin_name, plugin_num) {|plugin| plugin_org_content = plugin[2] || '' plugin_altered_content = yield(plugin_org_content) plugin[2] = plugin_altered_content # Destructive. written = true plugin } raise NoCorrespondingPlugin if ! written # Reconstruct the page from the lines. new_page_str = Plugin.join(new_paras) page.put_with_md5(new_page_str, md5) return nil end
# File vendor/qwik/lib/qwik/act-basic.rb, line 229 def plugin_list return self.methods.grep(/\Aplg_/).map {|name| name.sub(/\Aplg_/) {''} }.reject {|name| IGNORE_PLUGINS.any? {|re| re =~ name } }.sort end
# File vendor/qwik/lib/qwik/act-povray.rb, line 117 def povray_exist? return POVRAY_CMD.path.exist? end
# File vendor/qwik/lib/qwik/act-povray.rb, line 121 def povray_generate(content) files = @site.files(@req.base) base = content.md5hex povfilename = "#{base}.pov" pngfilename = "#{base}.png" povpath = files.path(povfilename) pngpath = files.path(pngfilename) pngtmppath = "/tmp/#{pngfilename}" msgpath = files.path("#{base}.povmsg").path stapath = files.path("#{base}.povsta").path return pngfilename, stapath if stapath.exist? # Already started. files.overwrite(povfilename, content) # Render it background. t = Thread.new { cmd = "#{POVRAY_CMD} #{povpath} -O#{pngtmppath}" #system cmd stapath.open('wb') {|sta| sta.puts Time.now.to_i.to_s msgpath.open('wb') {|msg| Open3.popen3(cmd) {|stdin, stdout, stderr| while line = stderr.gets msg.print line end } } sta.puts Time.now.to_i.to_s } system "#{MV_CMD} #{pngtmppath} #{pngpath}" } return pngfilename, stapath end
ref: webrick/httpauth.rb
# File vendor/qwik/lib/qwik/act-httpauth.rb, line 31 def pre_act_basicauth if ! @req.user # Try to Login by using Basic Auth. realm = 'qwik' @res['WWW-Authenticate'] = "Basic realm=\"#{realm}\"" # status code must be 401 return c_notice(_('Log in by Basic Authentication.'), nil, 401) { [[:h2, _('Logging in by Basic Authentication.')], [:p, _("Please input ID (E-mail) and password.")], [:hr], [:p, [:a, {:href=>'FrontPage.html'}, _('Go back')]]] } end # Already logged in. if @req.auth != 'basicauth' # But, the method is not Basic Auth. return c_notice(_('Login by cookie')) { [[:h2, _('You are already login by cookie.')], [:hr], [:p, [:a, {:href=>'FrontPage.html'}, _('Go back')]]] } end return c_notice(_('Log in by Basic Authentication.')) { [[:h2, _('Log in using Basic Authentication.')], [:hr], [:p, [:a, {:href=>'FrontPage.html'}, _('Go back')]]] } end
CSS
¶ ↑
# File vendor/qwik/lib/qwik/act-theme.rb, line 156 def pre_act_css str = '' return nil if @req.path_args.empty? if @req.path_args.length == 1 filename = @req.path_args[0] content, type = css_get_from_site_theme(filename) return c_notfound if content.nil? @res['Content-Type'] = type @res.body = content return end url = @req.path_args.join('/') content = css_get_by_url(url) return c_notfound if content.nil? @res['Content-Type'] = 'text/css' @res.body = content return end
Send password by e-mail.
# File vendor/qwik/lib/qwik/act-getpass.rb, line 13 def pre_act_getpass mail = @req.query['mail'] if mail.nil? user = @req.user if ! @site.is_open? && user && ! @site.member.exist?(user) raise RequireMember end return getpass_show_form end if ! MailAddress.valid?(mail) return c_nerror(_('Invalid mail address')) { [[:p, [:em, mail], [:br], _('The mail address format is wrong.'), [:br], _('Please confirm the input again.')], [:p, [:a, {:href=>'.getpass'}, _('Please access again.')]]] } end if ! @site.is_open? && ! @site.member.exist?(mail) ml = @site.ml_address return getpass_not_member(mail, ml) end passmail = generate_password_mail(mail) sendmail = Sendmail.new(@config.smtp_host, @config.smtp_port, @config.test) begin sendmail.send(passmail) rescue return c_nerror(_('Send Password Error')) { [[:p, _('Send failed because of system error.')], [:p, _('Please contact the administrator.')], [:p, [:a, {:href=>'.login'}, _('Go back to Login screen')]]] } end return c_notice(_('Send Password done')) { [[:p, {:style=>'margin: 1.5em 0'}, _('I send the password to this mail address.'), [:br], _('Please check your mailbox.')], [:p, {:style=>'margin: 1.5em 0'}, [:em, mail]], [:hr], [:p, [:a, {:href=>'.login'}, _('Go back to Login screen')]]] } end
login¶ ↑
# File vendor/qwik/lib/qwik/act-login.rb, line 139 def pre_act_login if @req.user return login_already_logged_in(@req.user) end user = @req.query['user'] # login from query pass = @req.query['pass'] if ! user return c_notice(_('Login')) { login_show_login_page(@site.site_url) # show login page } end begin raise InvalidUserError if user.nil? || user.empty? raise InvalidUserError unless MailAddress.valid?(user) gen = @memory.passgen raise InvalidUserError unless gen.match?(user, pass) rescue InvalidUserError @res.clear_cookies # IMPORTANT! return login_invalid_user # password does not match end sid = session_store(user) @res.set_cookie('sid', sid) # Set Session id by cookie. return login_show_login_suceed_page end
# File vendor/qwik/lib/qwik/act-logout.rb, line 9 def pre_act_logout return basicauth_logout if @req.auth == 'basicauth' confirm = @req.query['confirm'] if confirm.nil? || confirm != 'yes' return logout_show_confirm end session_clear @res.clear_cookie('user') # Remove cookies from browser. @res.clear_cookie('pass') @res.clear_cookie('sid') return c_notice(_('Log out done.'), 'FrontPage.html') { [:p, [:a, {:href=>'FrontPage.html'}, _('Go back')]] } end
# File vendor/qwik/lib/qwik/act-map.rb, line 52 def pre_act_map sitename = @req.query['s'] pagekey = @req.query['k'] mode = @req.query['m'] # Prepare site. @site = @memory.farm.get_site(sitename) if @site.nil? @site = @memory.farm.get_top_site return action_no_such_site(@req.sitename) end if ! @site.is_open? c_require_member # IMPORTANT: Security check. end page = @site[pagekey] c_nerror('No such page.') if page.nil? plugin = get_first_plugin(page, 'map') param = plugin[1][:param] args = Action.plugin_parse_args(param) clat = args.shift.to_f clng = args.shift.to_f mag = args.shift.to_i content = plugin[2] ar = [] ar << map_style maparea = map_maparea(clat, clng, mag, content, mode) ar << maparea title = 'map' c_plain(title){ar} head = @res.body.get_path('/head') head << map_initial_script head << map_script(clat, clng, mag, content, mode) body = @res.body.get_path('/body') body[1][:onload] = 'qwikMakeMap();' footer= @res.body.get_path("//div[@class='footer']") footer.clear if ! @config.test map_make_page_utf8 end end
# File vendor/qwik/lib/qwik/act-redirect.rb, line 37 def pre_act_redirect url = @req.query['url'] if url return c_notice('redirect', url) { [:p, 'redirect', [:br], [:strong, url]] } end return old_redirect end
new¶ ↑
# File vendor/qwik/lib/qwik/act-ring.rb, line 483 def pre_act_ring_new id = @req.query['id'] mail = @req.query['mail'] # We need the id and mail. if id.nil? || mail.nil? return c_nerror('No id nor mail') end res = ring_new_create_account(id, mail) if res == 'exist' return c_nerror('Already exist') end div = [:div, [:p, 'id is ', id], [:p, 'mail is ', mail]] return c_notice(_r(:NEW_CREATED)) { div } end
# File vendor/qwik/lib/qwik/act-typekey.rb, line 15 def pre_act_typekey if @req.query.length == 0 return typekey_redirect_to_typekey end sitetoken = typekey_get_sitetoken return typekey_error_no_sitetoken if sitetoken.nil? tk = TypeKey.new(sitetoken, '1.1') key = typekey_get_publickey(tk) email = @req.query['email'] name = @req.query['name'] nick = @req.query['nick'] ts = @req.query['ts'] # time stamp sig = @req.query['sig'] # <email>::<name>::<nick>::<ts>::<site-token> begin tk.verify(email, name, nick, ts, sig) rescue VerifyFailed return c_notice(_('Verify failed.')) { _('Verify failed.') } rescue TimeOutError return c_notice(_('Time out.')) { _('Time out.') } end sid = session_store(email) @res.set_cookie('sid', sid) # Set Session id by cookie return c_notice(_('Login')+' '+_('Success'), 'FrontPage.html') { [:p, [:a, {:href=>'FrontPage.html'}, _('Go next')]] } end
Null ext.
# File vendor/qwik/lib/qwik/action.rb, line 244 def pre_ext_ sitename = @req.base title = "redirect to site : #{sitename}" url = c_relative_to_root("#{sitename}/") c_notice(title, url) { [:h2, title] } end
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 244 def pre_ext_mdlbrss xml = [] xml << [:'?xml', '1.0', 'utf-8'] rss = [:rss, {:version=>'2.0'}] moved_url = c_relative_to_absolute('/model.xml') channel = [:channel, [:title, 'moved'], [:link, moved_url], [:description, 'moved.'], [:lastBuildDate, Time.at(0).rfc1123_date], [:ttl, '60']] item = [:item, [:title, 'moved'], [:link, moved_url], [:description, 'moved'], [:pubDate, Time.at(0).rfc1123_date]] channel << item rss << channel xml << rss @res['Content-Type'] = 'application/xml' @res.body = xml @res.body = @res.body.format_xml.page_to_xml if ! @config.test return nil end
# File vendor/qwik/lib/qwik/act-metadata.rb, line 29 def pre_ext_xml method = "metadata_#{@req.base}_#{@req.ext}" return c_nerror(_('Error')) if ! self.respond_to?(method) site_cache_path = @site.cache_path site_cache_path.check_directory feed_filename = "#{@req.base}.#{@req.ext}" feed_path = site_cache_path + feed_filename if ! feed_path.exist? feed = self.send(method) feed_string = feed.format_xml.page_to_xml feed_path.write(feed_string) end return c_simple_send(feed_path, 'application/xml') end
# File vendor/qwik/lib/qwik/act-presen.rb, line 132 def presen_get_theme(wabisabi) if wabisabi.is_a?(String) # for test wabisabi = c_parse(wabisabi) end theme = nil wabisabi.each {|ele| if ele.is_a?(Array) && ele[0] == :plugin && ele.attr[:method] == 'presen_theme' theme = ele.attr[:param] end } return theme end
# File vendor/qwik/lib/qwik/act-presen.rb, line 115 def presen_patch(wabisabi) if wabisabi.is_a?(String) # for test wabisabi = c_parse(wabisabi) end nw = [] wabisabi.each {|ele| if ele.is_a?(Array) && ele[0] == :plugin && ele.attr[:method] == 'com' # do nothing else nw << ele end } return nw end
# File vendor/qwik/lib/qwik/act-presen.rb, line 75 def presen_theme_list themes = [] theme_path = @config.theme_dir.path+'s5' theme_path.each_entry {|d| s = d.to_s next if /\A\./ =~ s next if PRESEN_THEME_IGNORE_DIR.include?(s) dir = theme_path+d next unless dir.directory? themes << d.to_s } return themes.sort end
# File vendor/qwik/lib/qwik/act-pagelist.rb, line 141 def recent_str(max = -1) max = max.to_i ar = [] last_day = nil add_day = true @site.date_list.reverse.each_with_index {|page, i| break if 0 <= max && max < (i += 1) if add_day day = page.mtime.ymd.to_s if last_day.nil? || day != last_day ar << "** #{day}" last_day = day end end ar << "- [[#{page.key}]]" } ar.join("\n") end
# File vendor/qwik/lib/qwik/act-tableform.rb, line 31 def req_user return @req.user end
# File vendor/qwik/lib/qwik/common-resolve.rb, line 10 def resolve_all_plugin(wabisabi) return wabisabi.each_tag(:plugin) {|w| resolve_plugin(w) } end
# File vendor/qwik/lib/qwik/common-resolve.rb, line 33 def resolve_plugin(w) attr = w.attr return [] if attr.nil? method = attr[:method] return [] if method.nil? || method.empty? param = attr[:param] param ||= '' if w[2] data = w[2].to_s result = self.c_call_plugin(method, param) { data } else result = self.c_call_plugin(method, param) end result = [] if result.nil? #result = [] if result.empty? result = [result] if ! result.is_a?(Array) return result end
# File vendor/qwik/lib/qwik/act-ring.rb, line 61 def ring_catalog if @memory[:ring_catalog].nil? @memory[:ring_catalog] = ring_generate_catalog end return @memory[:ring_catalog] end
# File vendor/qwik/lib/qwik/act-ring.rb, line 216 def ring_dummy_template str = '#{guest_mail} #{message} #{host_name} #{host_mail} http://ring.sfc.keio.ac.jp/.getpass?mail=#{guest_mail} ' return str end
# File vendor/qwik/lib/qwik/act-ring.rb, line 68 def ring_generate_catalog catalog = {} page = @site.get_superpage(RING_CATALOG) if page.nil? page = @site.create("_#{RING_CATALOG}") page.store(RING_CATALOG_CONTENT) end if page wdb = page.wikidb wdb.hash.each {|k, v| catalog[k.intern] = v } end return catalog end
# File vendor/qwik/lib/qwik/act-ring.rb, line 178 def ring_invite_goback(href) return c_nerror(_r(:INVITE_NOSEND)) { [[:h3, _r(:INVITE_NOSEND)], [:p, _r(:CONFIRM_YOUR_INPUT)], [:p, [:a, {:href=>href}, _('Go back')]]] } end
In this method, we actually add the guest user.
# File vendor/qwik/lib/qwik/act-ring.rb, line 201 def ring_invite_guest(guest_mail_ar, message) host_mail = @req.user page = @site.get_superpage(RING_INVITE_MEMBER) page = @site.create('_'+RING_INVITE_MEMBER) if page.nil? now = @req.start_time member = @site.member guest_mail_ar.each {|guest_mail| next if member.exist_qwik_members?(guest_mail) member.add(guest_mail, host_mail) page.wikidb.add(guest_mail, '', host_mail, message, now.to_i) ring_invite_sendmail(host_mail, guest_mail, '', message) } end
# File vendor/qwik/lib/qwik/act-ring.rb, line 226 def ring_invite_sendmail(host_mail, guest_mail, guest_name, message) host_name = plg_ring_user(host_mail, 'name') host_name ||= '' host_from = "#{host_name} <#{host_mail}>" guest_to = guest_mail subject = _r(:INVITE_SUBJECT) template_page = @site.get_superpage(RING_INVITE_MAIL_TEMPLATE) if template_page content = template_page.load else content = ring_dummy_template end content.gsub!(/\#\{host_name\}/, host_name) content.gsub!(/\#\{host_mail\}/, host_mail) content.gsub!(/\#\{guest_mail\}/, guest_mail) content.gsub!(/\#\{message\}/, message) mail = { :from => host_from, :to => guest_to, :subject => subject, :content => content, } sm = Sendmail.new(@config.smtp_host, @config.smtp_port, @config.test) sm.send(mail) end
# File vendor/qwik/lib/qwik/act-ring.rb, line 397 def ring_make_already_exist(href) return c_nerror(_r(:MAKER_ALREADY_REGISTERD)) { [[:h3, _r(:MAKER_ALREADY_REGISTERD)], [:p, _r(:CONFIRM_YOUR_INPUT)], [:p, [:a, {:href=>href}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-ring.rb, line 374 def ring_make_create_newpage(user) template_page = @site.get_superpage(RING_PAGE_TEMPLATE) if template_page content = template_page.load else content = ring_maker_dummy_template end content.sub!(/\#\{username\}/, user) page = @site.create_new # Create new file. page.store(content) return page end
# File vendor/qwik/lib/qwik/act-ring.rb, line 389 def ring_make_not_registerd(href) return c_nerror(_r(:MAKER_NOT_REGISTERD)) { [[:h3, _r(:MAKER_NOT_REGISTERD)], [:p, _r(:CONFIRM_YOUR_INPUT)], [:p, [:a, {:href=>href}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-ring.rb, line 405 def ring_make_registerd(href, username, realname, newkey) return c_notice(_r(:MAKER_REGISTERD)) { [[:h3, _r(:MAKER_REGISTERD)], [:dl, [:dt, _r(:USER)], [:dd, username], [:dt, _r(:REALNAME)], [:dd, realname]], [:p, [:a, {:href=>"#{newkey}.html"}, _r(:MAKER_THE_PAGE)], _r(:MAKER_SEE)]] } end
# File vendor/qwik/lib/qwik/act-ring.rb, line 364 def ring_maker_dummy_template str = '* #{username} * profile {{ring_personal_info}} * message {{ring_message_form}} ' return str end
# File vendor/qwik/lib/qwik/act-ring.rb, line 470 def ring_msg_input_message(href) return c_notice(_r(:MSG_INPUT_MESSAGE), href, 200, 3) { # 3sec. [[:h3, _r(:MSG_INPUT_MESSAGE)], [:p, [:a, {:href=>href}, _('Go back')]]] } end
# File vendor/qwik/lib/qwik/act-ring.rb, line 504 def ring_new_create_account(id, mail) message = _r(:NEW_FROM_SFCNEJP) host_mail = 'info@ring.sfc.ne.jp' # dummy page = @site.get_superpage(RING_INVITE_MEMBER) page = @site.create('_'+RING_INVITE_MEMBER) if page.nil? now = @req.start_time guest_mail = id member = @site.member return 'exist' if member.exist_qwik_members?(guest_mail) member.add(guest_mail, host_mail) page.wikidb.add(guest_mail, '', host_mail, message, now.to_i) #ring_invite_sendmail(host_mail, guest_mail, '', message) return nil end
user¶ ↑
manage user information.¶ ↑
# File vendor/qwik/lib/qwik/act-ring.rb, line 523 def ring_user_info(key, mail) # Get member database page. page = @site.get_superpage(key) return nil if page.nil? # Get the correspondig record to the mail. ar = page.wikidb[mail] return nil if ar.nil? # No record. return ar end
# File vendor/qwik/lib/qwik/action.rb, line 66 def run init_gettext # for maps plugin support. sitename = @req.query['site'] @req.sitename = sitename if sitename pagename = @req.query['page'] @req.base = pagename if pagename # Get site. @site = @memory.farm.get_site(@req.sitename) if @site.nil? @site = @memory.farm.get_top_site unless @req.plugin == 'theme' return action_no_such_site(@req.sitename) end end begin # Get user. login_get_user # Do PRE Action. method = "pre_act_#{@req.plugin}" if self.respond_to?(method) return self.send(method) end # Do PRE Ext. method = "pre_ext_#{@req.ext}" if self.respond_to?(method) return self.send(method) end # Check auth for the site. require_mail = true require_member = true if @site.is_open? require_mail = false require_member = false end if require_mail && @req.user.nil? @res.clear_cookies return action_go_login end if require_member && !@site.member.exist?(@req.user) user = @req.user ml = @site.ml_address return action_go_login if user.nil? return action_member_only_form(user, ml) end # Do action. if @req.plugin action = @req.plugin method = "act_#{action}" if self.respond_to?(method) return self.send(method) else return c_nerror("no such action : #{action}") end end # Do ext action. ext = @req.ext method = "ext_#{ext}" if self.respond_to?(method) return self.send(method) else # Special attached file mode. @req.path_args = ["#{@req.base}.#{@req.ext}"] @req.base = 'FrontPage' return act_files end rescue InvalidUserError @res.clear_cookies # important return login_invalid_user rescue RequireLogin return action_require_login rescue RequireMember return action_go_login if @req.user.nil? return action_member_only_form(@req.user, @site.ml_address) rescue RequirePost return action_require_post rescue PageNotFound return action_page_not_found rescue RequireNoPathArgs return action_require_no_path_args rescue BaseIsNotSitename return action_require_base_is_sitename rescue WEBrick::HTTPStatus::Status raise $! rescue StandardError e = $! # Why? pp e.message pp e.backtrace raise e #return c_nerror(e.message){ backtrace_html($!) } end end
# File vendor/qwik/lib/qwik/act-save.rb, line 87 def save_conflict(contents) pagename = @req.base page = @site[pagename] differ = DiffGenerator.generate(contents, page.load) return save_edit_conflict(pagename, differ, contents) end
# File vendor/qwik/lib/qwik/act-save.rb, line 94 def save_edit_conflict(pagename, differ, contents) url = pagename+'.html' editing_contents = [:div, {:class=>'differ'}, differ] message = edit_conflict_message(url, editing_contents) return generate_edit_page(contents, message) end
# File vendor/qwik/lib/qwik/act-save.rb, line 60 def save_page_deleted url = 'FrontPage.html' c_notice(_('Page is deleted.'), url) { [[:h2, _('Page is deleted.')], [:p, [:a, {:href=>url}, _('Go next')]]] } end
# File vendor/qwik/lib/qwik/act-save.rb, line 101 def save_page_is_saved(url) return c_notice(_('Page is saved.'), url){ [[:h2, _('Page is saved.')], [:p, [:a, {:href=>url}, _('Go next')]]] } end
# File vendor/qwik/lib/qwik/act-save.rb, line 68 def save_password_does_not_match(contents) message = [:div, {:class=>'day'}, [:h2, _('Password does not match.')], [:div, {:class=>'section'}, [:p, [:tt, '{{password('], _('Password'), [:tt, ')}}']], [:p, _('Please find a line like that above, then input password in parentheses.')]]] return generate_edit_page(contents, message) end
# File vendor/qwik/lib/qwik/act-schedule.rb, line 102 def schedule_construct(query) table = [] query.each {|k, v| prefix, col, row = k.split('_') next if prefix != 't' || col.nil? || row.nil? col = col.to_i row = row.to_i table[row] = [] if table[row].nil? table[row][col] = v } # Check last row last_tr = table.last empty = true last_tr.each {|col| if col && ! col.empty? empty = false end } if empty table[table.length-1] = nil # Delete the last row. end str = '' table.each_with_index {|row, y| next if row.nil? row.each_with_index {|col, x| str << "|#{col}" } str << "\n" } return str end
# File vendor/qwik/lib/qwik/act-search.rb, line 43 def search_form(focus = false, query = nil) query_attr = {:name=>'q'} query_attr[:class] = 'focus' if focus query_attr[:value] = query if query return [:form, {:action=>'.search'}, [:input, query_attr], [:input, {:type=>'submit', :value=>_('Search')}]] end
# File vendor/qwik/lib/qwik/act-search.rb, line 78 def search_form_page(title = _('Search'), notice = nil, query = nil) body = [] body << [:h2, notice] if notice body << [:div, {:class => 'form'}, search_form(true, query)] return c_notice(title) { body } end
# File vendor/qwik/lib/qwik/act-search.rb, line 67 def search_get_query query = @req.query['q'] return query if query && ! query.empty? query = @req.base return query if query && ! query.empty? && query != "FrontPage" #return query if query && ! query.empty? return nil end
called also from act-isearch.rb
# File vendor/qwik/lib/qwik/act-search.rb, line 86 def search_notfound_page(query) return search_form_page(_('Search result'), _('No match.'), query) end
# File vendor/qwik/lib/qwik/act-search.rb, line 90 def search_result(site, ar, query = nil) ul = [:ul] ar.each {|key, line, i| page = site[key] url = page.url ul << [:li, [:h3, [:a, {:href => url}, page.get_title]], [:span, {:class => 'content'}, line], [:div, [:a, {:href => url}, url]]] } div = [] div << [:div, {:class => 'day'}, [:div, {:class => 'section'}, [:div, {:class=>'form'}, search_form(true, query)]]] div << [:div, {:class => 'day'}, [:div, {:class => 'section'}, [:div, {:class => 'search_result'}, ul]]] title = _('Search result') + ": " + query return c_plain(title) { div } end
# File vendor/qwik/lib/qwik/act-sendpass.rb, line 49 def sendpass_show_form members = @site.member.list.sort return c_notice(_('Send Password')) { [[:h2, _('You can send password for the members.')], [:p, _('Please select members to send password.')], [:form, {:action=>'.sendpass', :method=>'post', :style=>'text-align: center; margin: 32px 0 48px;'}, [:ul, members.map {|member| [:li, [:input, {:type=>'checkbox', :name=>member}, ' '+member]] } ], [:input, {:type=>'submit', :value=>_('Send Password')}]]] } end
logout¶ ↑
# File vendor/qwik/lib/qwik/common-session.rb, line 31 def session_clear sid = @req.cookies['sid'] # Get sid from cookie. return if sid.nil? || sid.empty? # return if you don't have session id. sdb = @memory.sessiondb user = sdb.get(sid) # Get user from SessionDB. return if user.nil? # return if there is no session id. sdb.clear(sid) end
# File vendor/qwik/lib/qwik/act-files.rb, line 125 def show_files_form_and_the_list c_require_member ar = plg_files_form(20) w = c_notice(_('Attach file')) {[ [:p, _('Attach a file')], ar ]} return w end
# File vendor/qwik/lib/qwik/act-site.rb, line 10 def site_delete_unused_config_files files1 = %w{ ,members ,count ,config ,charset ,alerted ,forward ,permanent ,unlimited ,waiting-members ,waiting-message } files1.each {|f1, i| p1 = (sitepath + f1) if p1.exist? p1.unlink li << "deleted. " li << [:a, {:href=>"/#{sitename}/"}, "/#{sitename}/"] ul << li end } end
# File vendor/qwik/lib/qwik/act-theme.rb, line 89 def site_theme return @site.siteconfig['theme'] end
# File vendor/qwik/lib/qwik/act-theme.rb, line 93 def site_theme_path files = @site.files(SITE_THEME) if files && files.exist?(THEME_FILE) #return "/#{@site.sitename}/.css/theme.css" #return c_relative_to_root(".css/theme.css") return ".css/theme.css" end t = site_theme if /\Ahttp:\/\// =~ t #return "/#{@site.sitename}/.css/#{t}" #return c_relative_to_root(".css/#{t}") return ".css/#{t}" end return ".theme/#{t}/#{t}.css" end
# File vendor/qwik/lib/qwik/action.rb, line 60 def site_updated pagelist_update metadata_clear_cache archive_clear_cache end
# File vendor/qwik/lib/qwik/act-status.rb, line 9 def status_get_date(time) return "* " + time.strftime("%Y-%m-%dT%H:%M:%S") + "\n" end
# File vendor/qwik/lib/qwik/act-status.rb, line 13 def status_get_memory(ps) str = '' ps.each_line {|line| user, pid, cpu, mem, vsz, rss, tty, stat, start, time, command = line.split(nil, 11) next if /^sh/ =~ command next if /^grep/ =~ command next if /^ruby/ =~ command next if %r|^/bin/sh| =~ command next if time == "0:00" command = 'quickml-server' if /quickml-server/ =~ command command = 'qwikweb-server' if /qwikweb-server/ =~ command vsz = vsz.to_i / 1000 rss = rss.to_i / 1000 str << "#{vsz}MB #{rss}MB #{command}\n" } str end
# File vendor/qwik/lib/qwik/act-status.rb, line 35 def status_get_objects ar = [] num = 0 string_length = 0 ObjectSpace.each_object {|obj| num += 1 name = obj.class.name ar << name if name == "String" string_length += obj.length end =begin if name == "String" || name == "Regexp" || name == "Class" || name == "Hash" || name == "Bignum" || name == "Module" || name == "Float" || name == "Array" # do nothing else ar << name end =end } hash = Hash.new(0) ar.each {|classname| hash[classname] += 1 } ar2 = [] hash.each {|k, v| ar2 << [v, k] } ar3 = ar2.sort.reverse str = "* get_objects\n" str << "object num #{num.commify}\n" str << "string_length #{string_length.commify}\n" ar3.each {|v, k| str << "#{v}\t#{k}\n" } str end
# File vendor/qwik/lib/qwik/act-status.rb, line 87 def status_get_objects2 ar = [] num = 0 ObjectSpace.each_object {|obj| ar << obj.class.name num += 1 } ar3 = ar.sort.uniq str = '' str << "object num #{num}\n" ar3.each {|v| str << "#{v}\n" } str end
# File vendor/qwik/lib/qwik/act-status.rb, line 107 def status_show_httprequests(now) ar = [] ObjectSpace.each_object {|obj| ar << obj if obj.class.name == "WEBrick::HTTPRequest" } str = "* WEBrick::HTTPRequest\n" ar.each {|req| #diff = now - req.start_time path = req.unparsed_uri ua = req["user-agent"] #str << "#{path}\t#{ua}\n" str << "#{path}\n" str << "#{ua}\n" } str end
# File vendor/qwik/lib/qwik/act-status.rb, line 125 def status_show_requests(now) ar = [] ObjectSpace.each_object {|obj| ar << obj if obj.class.name == "Qwik::Request" } str = "* Qwik::Request\n" ar.each {|req| diff = now - req.start_time path = req.unparsed_uri str << "#{path}\t#{diff}\n" } str end
# File vendor/qwik/lib/qwik/common-surface.rb, line 28 def surface_generate(title, msg, patch=true) template = @memory.template.get('surface') adminmenu = c_page_res('_AdminMenu') if patch li = adminmenu.get_path('//ul/li[2]') li.clear if li end data = { :title => title, :theme_path => site_theme_path, :adminmenu => adminmenu, :toc => nil, # Do not use toc. :h1 => title, # same as title. :body => msg, :sidemenu => surface_get_sidemenu, :pageattribute => c_page_res('_PageAttribute'), } surface_template(template, data) return template end
act-include:22, act-tag:49
# File vendor/qwik/lib/qwik/common-surface.rb, line 77 def surface_get_body(page) tree = page.get_body_tree w = Resolver.resolve(@site, self, tree) w = TDiaryResolver.resolve(@config, @site, self, w) return w end
# File vendor/qwik/lib/qwik/common-surface.rb, line 59 def surface_view_generate(pagename) page = @site[pagename] template = @memory.template.get('surface') data = { :title => @site.get_page_title(pagename), :theme_path => site_theme_path, :adminmenu => c_page_res('_AdminMenu'), :toc => toc_inside, :h1 => page.get_title, :body => surface_get_body(page), :sidemenu => surface_get_sidemenu, :pageattribute => c_page_res('_PageAttribute'), } surface_template(template, data) return template end
# File vendor/qwik/lib/qwik/act-table.rb, line 116 def table_construct(query) table = [] query.each {|k, v| prefix, col, row = k.split('_') next if prefix != 't' || col.nil? || row.nil? col = col.to_i row = row.to_i table[row] = [] if table[row].nil? table[row][col] = v } # Check last row last_tr = table.last empty = true last_tr.each {|col| if col && ! col.empty? empty = false end } if empty table[table.length-1] = nil # Delete the last row. end str = '' table.each_with_index {|row, y| next if row.nil? row.each_with_index {|col, x| str << "|#{col}" } str << "\n" } return str end
from act-archive.rb. Used for archive.
# File vendor/qwik/lib/qwik/act-theme.rb, line 141 def theme_files(theme) dir = @config.theme_dir.path+theme return unless dir.directory? files = [] dir.each_entry {|f| file = dir+f next if file.directory? s = f.to_s next if /\A\./ =~ s || /\~\z/ =~ s || s == 'CVS' files << f.to_s } return files end
# File vendor/qwik/lib/qwik/act-theme.rb, line 118 def theme_list themes = [] theme_path = @config.theme_dir.path theme_path.each_entry {|d| s = d.to_s next if /\A\./ =~ s next if THEME_IGNORE_DIR.include?(s) dir = theme_path+d next unless dir.directory? themes << d.to_s } return themes.sort end
# File vendor/qwik/lib/qwik/act-file.rb, line 73 def thumb_check(f) ext = Filename.extname(f) return thumb_generate(f) if PageFiles.is_image?(ext) return nil end
FIXME: Use tokenes instead of tree.
# File vendor/qwik/lib/qwik/act-toc.rb, line 19 def toc_inside page = @site[@req.base] return nil if page.nil? wabisabi = page.get_body_tree wabisabi ||= [] res = TDiaryResolver.new(@config, @site, self) tokens = [] wabisabi.each_tag(:h2, :h3, :h4, :h5, :h6) {|w| tag = w.element_name head = REPLACE_TOC[tag] name = TDiaryResolver.get_title_name(w) if tag == :h2 label = res.encode_label(name) link = [[:a, {:href=>"#"+label}, w.text]] w = head + [link] else w = head + [w.text] end tokens << w } return nil if tokens.length == 0 w = TextParser.make_tree(tokens).get_single w = [[:h5, _('Contents')], [:div, {:id=>'tocinside'}, w]] return w end
# File vendor/qwik/lib/qwik/act-typekey.rb, line 52 def typekey_error_no_sitetoken return c_nerror(_('Cannot use.')) { [:p, _('There is no site token for TypeKey.')] } end
# File vendor/qwik/lib/qwik/act-typekey.rb, line 78 def typekey_get_publickey(tk) # Make cache timeout to 100 years. Only for test. #tk.key_cache_timeout = 60 * 60 * 24 * 365 * 100 # 100 years tk.key_cache_timeout = 60 * 60 * 24 * 365 * 2 # 2 years cache_path = @config.cache_dir.path+'typekey-publickey.txt' tk.key_cache_path = cache_path.to_s return tk.get_key end
# File vendor/qwik/lib/qwik/act-typekey.rb, line 72 def typekey_get_sitetoken file = @config.etc_dir.path+TYPEKEY_SITETOKEN_FILE return nil if ! file.exist? return file.read.chomp end
# File vendor/qwik/lib/qwik/act-typekey.rb, line 58 def typekey_redirect_to_typekey sitetoken = typekey_get_sitetoken return typekey_error_no_sitetoken if sitetoken.nil? tk = TypeKey.new(sitetoken, '1.1') # http://example.com/test/.typekey ret_url = c_relative_to_absolute('.typekey') url = tk.get_login_url(ret_url, true) return c_nredirect('Go TypeKey', url) # Redirect to TypeKey end
called from act-archive
# File vendor/qwik/lib/qwik/act-html.rb, line 69 def view_page_cache_generate(pagename) w = surface_view_generate(pagename) str = w.format_xml # format xml with "\n" dirpath = @site.cache_path Action.html_page_cache_store(dirpath, pagename, str) return w end
# File vendor/qwik/lib/qwik/act-html.rb, line 61 def view_page_cache_need_generate?(file) return true if ! file.exist? return true if file.mtime < @site.last_page_time return true if @req.header['cache-control'] == ['no-cache'] return false end
# File vendor/qwik/lib/qwik/act-wema.rb, line 144 def wema_jump(msg, url) return c_nredirect(msg, url) if $wema_redirect return c_notice(msg, url) end
# File vendor/qwik/lib/qwik/act-wysiwyg.rb, line 97 def wysiwyg_editor_page(site, pagename) page = site[pagename] str = page.load w = c_parse(str) # without resolve #w = c_tdiary_resolve(w) md5hex = str.md5hex ar = Action.wysiwyg_generate(pagename, w, md5hex, $test) title = "#{pagename} : "+_('Edit in this page') c_surface(title, false) { ar } wysiwyg_patch_sidemenu return nil end
# File vendor/qwik/lib/qwik/act-wysiwyg.rb, line 87 def wysiwyg_save wtext = @req.query['wtext'] return c_nerror('null content') if wtext.nil? || wtext.empty? wtext = wtext.gsub(/\ \;/, '') # delete_bogus wabisabi = HtmlToWabisabi.parse(wtext) wiki = WabisabiToWiki.translate(wabisabi) return ext_save(wiki, 'wysiwyg') # in act-save.rb end
Private Instance Methods
# File vendor/qwik/lib/qwik/act-files.rb, line 233 def files_put(content) c_require_member c_require_post site_total = @site.files_total max_total_file_size = @config[:max_total_file_size] warn_size = @config[:max_total_warn_size] list = [] content.each_data {|data| fullfilename = data.filename next if fullfilename.empty? # Get basename. #filename = fullfilename.path.basename.to_s filename = Action.get_basename(fullfilename) max_size = @site.siteconfig['max_file_size'].to_i if max_size < data.length list << [:p, [:strong, filename], [:em, _('Maximum size exceeded.')], [:br], _('Maximum size'), max_size, [:br], _('File size'), data.length, [:br]] next elsif max_total_file_size < site_total list << [:p, [:strong, filename], ' : ', [:em, _('The file is not saved.')], [:br], [:strong, _('Total file size exceeded.')],[:br], _('Maximum total size'), max_total_file_size.byte_format, [:br], _('Current total size'), site_total.byte_format, [:br]] #get next even total file size is exceeded #to display which files are not saved explicitly next end # If the file is saved as another name, you can use return value. filename = @site.files(@req.base).fput(filename, data) c_make_log('file attach') # FILE ATTACH site_total += data.length page = @site[@req.base] page.add("\n{{file(#{filename})}}\n") # files_update_page if max_total_file_size < site_total list << [:p, [:strong, filename], ' : ', _('The file is saved.'), [:br], [:strong, _('Exceeded limit.')]] elsif max_total_file_size - warn_size < site_total msg = _("Reaching limit.") + " " + sprintf(_("%s left"), (max_total_file_size - site_total).byte_format) list << [:p, [:strong, filename], ' : ', _('The file is saved.'), [:br], [:strong, msg]] else list << [:p, [:strong, filename], ' : ', _('The file is saved.')] end } url = "#{@req.base}.html" ar = list + [ [:hr], [:p, _('Go next'), ' : ', [:a, {:href=>url}, url]], ] return c_notice(_('File attachment completed'), url) { ar } end
# File vendor/qwik/lib/qwik/act-getpass.rb, line 96 def generate_password_mail(user) password = @memory.passgen.generate(user) msg = '' msg << _('This is your user name and password: ')+"#{@site.host_url}\n" msg << "\n" msg << _('Username')+": #{user}\n" msg << _('Password')+": #{password}\n" msg << "\n" msg << _('Please access login page')+" #{@site.site_url}.login\n" msg << "\n" msg << _('You can input the user name and password from this URL automatically.')+"\n" msg << "#{@site.site_url}.login?user=#{user}&pass=#{password}\n" mail = { :from => @site.ml_address, :to => user, :subject => _('Your password:')+" #{@site.host_url}", :content => msg, } return mail end
# File vendor/qwik/lib/qwik/act-login.rb, line 244 def login_page_form return [:div, {:class=>'login'}, [:form, {:method=>'POST', :action=>'.login'}, [:dl, [:dt, _('ID'), '(E-mail)', ': '], [:dd, [:input, {:name=>'user', :istyle=>'3', :class=>'focus'}]], [:dt, _('Password'), ': '], [:dd, [:input, {:type=>'password', :name=>'pass'}]]], [:p, [:input, {:type=>'submit', :value=>_('Login')}]]]] end
# File vendor/qwik/lib/qwik/common-surface.rb, line 138 def new_surface_template(template, data) template.make_index w = template.index_tag(:head) w.insert(1, [:title, data[:title]]) media = 'screen,tv,print' w.insert(w.length, [:link, {:href=>'.theme/css/base.css', :media=>media, :rel=>'stylesheet', :type=>'text/css'}]) w.insert(w.length, [:link, {:href=>data[:theme_path], :media=>media, :rel=>'stylesheet', :type=>'text/css'}]) w.insert(w.length, [:link, {:href=>'rss.xml', :title=>'RSS 0.91', :rel=>'alternate', :type=>"application/rss+xml"}]) js = Action.generate_js w.insert(w.length, *js) w = template.index_class('adminmenu') w << data[:adminmenu] w = template.index_class('toc') if data[:toc].nil? w.clear else w << data[:toc] end w = template.index_tag(:h1) w << data[:h1] w = template.index_class('body_enter') w.clear w = template.index_class('body_main') w << data[:body] w = template.index_class('sidebar') w << data[:sidemenu] w = template.index_class('body_leave') w << [:div, {:class=>'day'}, [:div, {:class=>'comment'}, [:div, {:class=>'caption'}, [:div, {:class=>'page_attribute'}, data[:pageattribute]]]]] return nil # Do not return any value. Just destruct the template. end
build using template¶ ↑
Destructive for template.
# File vendor/qwik/lib/qwik/common-surface.rb, line 95 def old_surface_template(template, data) w = template.get_tag('head') # TAKETIME: Here! w.insert(1, [:title, data[:title]]) media = 'screen,tv,print' w.insert(w.length, [:link, {:href=>'.theme/css/base.css', :media=>media, :rel=>'stylesheet', :type=>'text/css'}]) w.insert(w.length, [:link, {:href=>data[:theme_path], :media=>media, :rel=>'stylesheet', :type=>'text/css'}]) js = Action.generate_js w.insert(w.length, *js) w = template.get_by_class('adminmenu') # TAKETIME: Here! w << data[:adminmenu] w = template.get_by_class('toc') # TAKETIME: Here! if data[:toc].nil? w.clear else w << data[:toc] end w = template.get_tag('h1') # TAKETIME: Here! w << data[:h1] w = template.get_by_class('body_enter') # TAKETIME: Here! w.clear w = template.get_by_class('body_main') # TAKETIME: Here! w << data[:body] w = template.get_by_class('sidebar') # TAKETIME: Here! w << data[:sidemenu] w = template.get_by_class('body_leave') # TAKETIME: Here! w << [:div, {:class=>'day'}, [:div, {:class=>'comment'}, [:div, {:class=>'caption'}, [:div, {:class=>'page_attribute'}, data[:pageattribute]]]]] return nil # Do not return any value. Just destruct the template. end