Class: Template
Constant Summary collapse
- @@log =
init_logger- @@fdelim =
'%='- @@placeholders =
{:dict_list => 'dict_list', :glossary => 'index'}
- @@def_template =
%~<?xml version="1.0" encoding="utf-8"?> <!-- created with HTML2Index #{VERSION}--> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="application/xhtml+xml" /> <meta name="revisit-after" content="30 days" /> <title>Glossaire</title> <style type="text/css"> body {font-family:LinuxBiolinum, Trebuchet;} h1 {margin-left:1em; margin-bottom:1em;} div.content {margin-bottom:9em;margin-left:2em;width:80%;border:1px solid #000060;padding:1em;border-radius:1em;} div.sources {border:0.5pt solid #000060;border-radius:1em;padding:0 0.5em 0 0.5em;background-color:#e0e0f0;margin:3em;width:40em;} dt {font-weight:bold;color:#000070;} div.navtop {border:1px solid #000000;border-radius:1em;background-color:#ffffff;font-weight:bold;font-size:1.3em;position:fixed;top:1em;right:7em;} a {text-decoration:none;} a:hover {border:1px solid #800000;border-radius:1em;} dd i {text-decoration:underline;} #omega {color:#a000a0;font-weight:bold;text-align:right;margin-right:12em;} </style> </head> <body> <div class="navtop" title="début"><a href="#top">⇧</a></div> <div><a id="top"></a></div> <p style="position:absolute;right:2em;top:2em;">généré avec html2index #{VERSION}, #{Date.today.to_s}</p> <h1>Glossaire </h1> <div class="sources"> <h2>Sources</h2> <!-- ============================ --> <!-- Insert list of dictionaries --> #{@@fdelim}#{@@placeholders[:dict_list]}#{@@fdelim.reverse} <!-- ============================ --> </div> <div class="content"> <!-- ============================ --> <!-- Insert glossary --> #{@@fdelim}#{@@placeholders[:glossary]}#{@@fdelim.reverse} <!-- ============================ --> <div id="omega">Ω</div> </div> </body> </html>~
Instance Attribute Summary collapse
-
#template ⇒ Object
Returns the value of attribute template.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Template
constructor
A new instance of Template.
- #to_s ⇒ Object
Methods included from Logging
debout, formatter, init_logger, log_level=, log_level?, log_target=
Constructor Details
#initialize ⇒ Template
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/template.rb', line 33 def initialize() @log = @@log @log.level = $log_level template_file = $configuration.template @template = nil if template_file msg = File_Checking::file_check(template_file, :file, :readable ) if !msg ftype = File_Checking::file_type(template_file) if ftype && !ftype.empty? && !ftype[0].downcase.match("(html|xml) .*document") msg = template_file.dup << ' does not look like a valid template file for (x)html: ' << ftype.join('; ') end end if(!msg) @template = File.read(template_file) @log.debug('using template ' << template_file) else @log.warn('Cannot use template ' << template_file << ': ' << msg << "\n\tusing default template") end end end |
Instance Attribute Details
#template ⇒ Object
Returns the value of attribute template.
66 67 68 |
# File 'lib/template.rb', line 66 def template @template end |
Class Method Details
.default(name) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/template.rb', line 68 def self::default(name) case name when :fdelim @@fdelim when :placeholders @@placeholders when :def_template @@def_template else @log.error('Do not know ' << name.to_s) @log.error('Aborting. Bye!') end end |
Instance Method Details
#to_s ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/template.rb', line 55 def to_s str = nil if @template && @template.respond_to?(:to_str) str = @template else @log.warn('Empty template, using default!') str = @@def_template end str end |