Show
Ignore:
Timestamp:
08/08/08 18:25:30 (4 months ago)
Author:
hb
Message:

platform/tdiary/plugin/microsummary.rb: added create_xml.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/plugin/microsummary.rb

    r7899 r17267  
    77add_header_proc do 
    88        generator_xml = @conf['generator.xml'] 
    9  
     9         
    1010        if generator_xml != nil and @mode == 'latest' and !@cgi.valid?( 'date' ) 
    1111                %Q|\t<link rel="microsummary" href="#{generator_xml}" type="application/x.microsummary+xml">\n| 
     
    1313end 
    1414 
     15def create_xml file_name 
     16        xml = <<-XML 
     17<?xml version="1.0" encoding="UTF-8"?> 
     18<generator xmlns="http://www.mozilla.org/microsummaries/0.1" 
     19           name="tDiary Entry Title"> 
     20  <template> 
     21    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
     22      <output method="text"/> 
     23      <template match="/"> 
     24        <value-of select="html/head/title"/> 
     25        <choose> 
     26          <when test="boolean(descendant::div[attribute::class='body'][1]/div[attribute::class='section'][last()]/h3)"> 
     27            <text> - </text> 
     28            <value-of select="descendant::div[attribute::class='body'][1]/div[attribute::class='section'][last()]/h3"/> 
     29          </when> 
     30          <when test="boolean(descendant::div[attribute::class='day'][1]/h2)"> 
     31            <text> - </text> 
     32            <value-of select="descendant::div[attribute::class='day'][1]/h2"/> 
     33          </when> 
     34        </choose> 
     35      </template> 
     36    </transform> 
     37  </template> 
     38  <update interval="240"/> 
     39  <pages> 
     40   <include>^#{@conf.base_url.gsub(/\./, '\\.')}$</include> 
     41  </pages> 
     42</generator> 
     43XML 
     44         
     45        begin 
     46                File::open( file_name, 'w' ) do |f| 
     47                        f.print to_utf8( xml ) 
     48                end 
     49        rescue 
     50        end 
     51end 
     52 
    1553def microsummary_init 
    16    @conf['generator.xml'] ||= "" 
     54        @conf['generator.xml'] ||= "" 
     55        create_xml( @conf['generator.xml'] ) unless File::exists? @conf['generator.xml'] 
    1756end 
    1857 
    1958if @mode == 'saveconf' 
    20    def saveconf_microsummary 
     59        def saveconf_microsummary 
    2160                @conf['generator.xml'] = @cgi.params['generator.xml'][0] 
    2261        end