Class: OpenTag
- Inherits:
-
Tag
- Object
- TreeObject
- SGMLObject
- Tag
- OpenTag
- Defined in:
- lib/rwd/rwd.rb,
lib/rwd/xml.rb,
lib/rwd/sgml.rb
Instance Attribute Summary
Attributes inherited from Tag
Attributes inherited from TreeObject
#children, #closed, #level, #parent, #subtype, #text, #upordown, #visible
Instance Method Summary collapse
-
#initialize(*args) ⇒ OpenTag
constructor
A new instance of OpenTag.
- #postchildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda = false) ⇒ Object
- #postchildren_to_sgml(res) ⇒ Object
- #postchildren_to_x(res, closetags) ⇒ Object
- #prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda = false) ⇒ Object
- #prechildren_to_sgml(res) ⇒ Object
- #prechildren_to_x(res, closetags) ⇒ Object
- #template(html, vars) ⇒ Object
Methods inherited from SGMLObject
Methods inherited from TreeObject
Methods included from ParseTree
Methods included from TextArray
Constructor Details
#initialize(*args) ⇒ OpenTag
83 84 85 86 |
# File 'lib/rwd/sgml.rb', line 83 def initialize(*args) super @upordown = Down end |
Instance Method Details
#postchildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda = false) ⇒ Object
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
# File 'lib/rwd/rwd.rb', line 497 def postchildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda=false) case @subtype when "vertical", "window", "helpwindow", "tab", "panel" res << Format % ["BefPost", @subtype] if $rwd_debug if @args.include?("spacing") res << "<tr><td> </td></tr>" * (@args["spacing"].to_i) end when "horizontal", "row" res << Format % ["BefPost", @subtype] if $rwd_debug end res << Format % ["Post", @subtype] if $rwd_debug case @subtype when "application" when "window", "helpwindow" args = @args.deep_dup args["nohelpbutton"] = (not help) template = $rwd_html_2 template = $rwd_html_PDA_2 if pda res << (template(template, args)) when "p" then res << "</p>" when "pre" then res << "</pre>" when "big" then res << "</big></p>" when "small" then res << "</small></p>" when "list" then res << "</ul>" when "item" then res << "</li>" when "empty" then res << "</p>" when "image" then res << "" when "progressbar" then res << "" when "br" then res << "" when "hr" then res << "" when "b" then res << "</b>" when "i" then res << "</i>" when "a" then res << "</a>" when "vertical" then res << "</table>" when "horizontal" then res << "</tr></table>" when "table" then res << "</table>" when "row" then res << "</tr>" when "hidden" then res << "</p>" when "text" then res << "</p>" when "textarea" then res << "</p>" when "password" then res << "</p>" when "checkbox" then res << "</p>" when "radio" then res << "</p>" when "select" res << "</select>" $select = nil when "option" then res << "</option>" when "button" then res << "" when "back" then res << "" when "cancel" then res << "" when "help" then res << "" when "quit" then res << "" when "close" then res << "" when "main" then res << "" when "reset" then res << "" when "closewindow" then res << "" when "tabs" res << " </td>" res << " </tr>" res << "</table>" when "tab" res << "</table>" when "panel" res << " </table>" res << " </td>" res << " </tr>" res << " </table>" res << " </td>" res << " </tr>" res << "</table>" else puts "</#{@subtype}>" res << "</#{@subtype}>" end before.pop after.pop aft = after[-1] res << Format % ["After", @subtype] if ($rwd_debug and not aft.nil?) res << aft if not aft.nil? end |
#postchildren_to_sgml(res) ⇒ Object
106 107 108 |
# File 'lib/rwd/sgml.rb', line 106 def postchildren_to_sgml(res) res << "</#{@subtype}>" if @closed end |
#postchildren_to_x(res, closetags) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rwd/xml.rb', line 81 def postchildren_to_x(res, ) if unless @children.length == 0 or (@children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.compress.empty?) res << "\n" if @children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.lf.split(/\n/).length > 1 res << " "*(@level-1) unless @children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.lf.split(/\n/).length == 1 res << "</#{@subtype}>" res << "\n" end end end |
#prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda = false) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/rwd/rwd.rb', line 271 def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda=false) bef = before[-1] res << Format % ["Before", @subtype] if ($rwd_debug and not bef.nil?) res << bef if not bef.nil? res << Format % ["Pre", @subtype] if $rwd_debug align = AC align = "align='#{@args["align"]}'" if @args.include?("align") valign = VA valign = "valign='#{@args["valign"]}'" if @args.include?("valign") value1 = "" value1 = varshtml[@args["name"]] if varshtml.include?(@args["name"]) value1 = @args["value"] if @args.include?("value") value2 = "" value2 = varsstring[@args["name"]] if varsstring.include?(@args["name"]) value2 = @args["value"] if @args.include?("value") cellspacing = 3 cellspacing = 0 if pda case @subtype when "application" when "window", "helpwindow" args = @args.deep_dup args["nohelpbutton"] = (not help) template = $rwd_html_1 # template = $rwd_html_PDA_1 if pda res << (template(template, args)) when "p" then res << "<p #{align}>" when "pre" then res << "<pre #{align}>" when "big" then res << "<p #{align}><big>" when "small" then res << "<p #{align}><small>" when "list" then res << "<ul #{align}>" when "item" then res << "<li #{align}>" when "empty" then res << "<p><br>" when "image" width = "width='#{@args["width"]}" if @args.include?("width") height = "height='#{@args["height"]}'" if @args.include?("height") res << "<img src='#{@args["src"]}' alt='#{@args["alt"]}' #{width} #{height}>" when "progressbar" width = 200 res << "<table>" res << " <tr>" res << " <td colspan='2'><img src='rwd_pixel.gif' height='1' width='#{width+5}'></td>" res << " </tr>" res << " <tr>" res << " <td bgcolor='#DDDDDD'><img src='rwd_pixel.gif' height='10' width='#{(width*@args["value"].to_f).to_i}'></td>" res << " <td bgcolor='#EEEEEE'><img src='rwd_pixel.gif' height='10' width='#{(width*(1.0-@args["value"].to_f)).to_i}'></td>" res << " </tr>" res << "</table>" when "br" then res << "<br>" when "hr" then res << "<hr>" when "b" then res << "<b>" when "i" then res << "<i>" when "a" if @args.include?("href") res << "<a href='#{@args["href"]}' target='#{@args["target"] or "_blank"}'>" else res << "<a href='javascript:document.bodyform.rwd_action.value=\"#{@args["action"]}\";document.bodyform.submit();'>" end when "vertical" then res << "<table #{AC} border='#{$rwd_border}' cellspacing='#{cellspacing}' cellpadding='0'>" when "horizontal" then res << "<table #{AC} border='#{$rwd_border}' cellspacing='#{cellspacing}' cellpadding='0'><tr #{align} #{valign}>" when "table" then res << "<table #{AC} border='#{$rwd_border}' cellspacing='#{cellspacing}' cellpadding='0'>" when "row" then res << "<tr #{align} #{valign}>" when "hidden" then res << "<p #{align}><input name='#{@args["name"]}' value='#{value1}' type='hidden'>" when "text" maxlength = "" maxlength = "maxlength='%s'" % @args["maxlength"] if @args.include?("maxlength") size = "" size = "size='%s'" % @args["size"] if @args.include?("size") size = "size='%s'" % 10 if pda res << "<p #{align}><input name='#{@args["name"]}' value='#{value1}' type='text' #{maxlength} #{size}>" oneormorefields << "true" when "textarea" res << "<p #{align}><textarea name='#{@args["name"]}' rows='25' cols='80'>#{value2.crlf}</textarea>" oneormorefields << "true" when "password" maxlength = "" maxlength = "maxlength='%s'" % @args["maxlength"] if @args.include?("maxlength") size = "" size = "size='%s'" % 10 if pda res << "<p #{align}><input name='#{@args["name"]}' value='#{value1}' type='password' #{maxlength} #{size}>" oneormorefields << "true" when "checkbox" if varshtml[@args["name"]] == "on" switches[@args["name"]] = true res << "<p #{align}><input name='#{@args["name"]}' checked='on' type='checkbox'>" else switches[@args["name"]] = false res << "<p #{align}><input name='#{@args["name"]}' type='checkbox'>" end oneormorefields << "true" when "radio" if varshtml[@args["name"]] == value1 # ??? 1 or 2? res << "<p #{align}><input name='#{@args["name"]}' checked='on' value='#{value1}' type='radio'>" else res << "<p #{align}><input name='#{@args["name"]}' value='#{value1}' type='radio'>" end oneormorefields << "true" when "select" res << "<select #{align} name='#{@args["name"]}' width='#{@args["width"]} size='#{@args["size"]}'>" # ??? Misschien nog iets met 'multiple'? name = @args["name"] $select = varshtml[name] oneormorefields << "true" when "option" if $select == @children[0].text res << "<option selected='true'>" else res << "<option>" end when "button" res << "<input type='submit' value='#{@args["caption"]}' onclick='document.bodyform.rwd_action.value=\"#{@args["action"]}\";'>" firstaction << @args["action"] if (firstaction.empty? and @args.include?("action")) oneormorefields << "true" when "back" res << "<input type='submit' value='Back' onclick='document.bodyform.rwd_action.value=\"rwd_back\";'>" firstaction << "rwd_back" if firstaction.empty? oneormorefields << "true" when "cancel" res << "<input type='submit' value='Cancel' onclick='document.bodyform.rwd_action.value=\"rwd_cancel\";'>" firstaction << "rwd_cancel" if firstaction.empty? oneormorefields << "true" when "help" res << "<input type='submit' value='Help' onclick='document.bodyform.rwd_action.value=\"rwd_help\";'>" firstaction << "rwd_help" if firstaction.empty? oneormorefields << "true" when "quit" res << "<input type='submit' value='Quit' onclick='document.bodyform.rwd_action.value=\"rwd_quit\";'>" firstaction << "rwd_quit" if firstaction.empty? oneormorefields << "true" when "close" res << "<input type='submit' value='Close' onclick='window.close();'>" firstaction << "rwd_quit" if firstaction.empty? oneormorefields << "true" when "main" res << "<input type='submit' value='Main' onclick='document.bodyform.rwd_action.value=\"rwd_main\";'>" firstaction << "rwd_main" if firstaction.empty? oneormorefields << "true" when "reset" res << "<input type='reset' value='Reset'>" firstaction << "rwd_quit" if firstaction.empty? # ??? oneormorefields << "true" when "closewindow" #res << "<script type='text/javascript'>\n" # ??? #res << "<!--\n" #res << " window.close();\n" #res << "//-->\n" #res << "</script>" when "tabs" res << "<table #{AC} border='#{$rwd_border}' cellspacing='0' cellpadding='0'>" res << " <tr #{AL}>" res << " <td #{AL} class='tabs'>" res << " <table #{AL} border='#{$rwd_border}' cellspacing='0' cellpadding='0'>" res << " <tr #{AL}>" #res << " <td class='notab'> </td>" tabs.each do |obj| name = obj.args["name"] caption = obj.args["caption"] res << "<td #{AL} class='notab'> </td>" unless obj == tabs[0] if name == tab res << "<td #{AC} class='activetab'><tt> #{caption} </tt></td>" else res << "<td #{AC} class='passivetab'><a href='javascript:document.bodyform.rwd_action.value=\"rwd_tab_#{name}\";document.bodyform.submit();'><tt> #{caption} </tt></a></td>" end end res << " <td class='notab' width='100%'> </td>" res << " </tr>" res << " </table>" res << " </td>" res << " </tr>" res << " <tr #{align}>" res << " <td #{align} class='tabblad'>" when "tab" res << "<table #{AC} border='#{$rwd_border}' cellspacing='3' cellpadding='0'>" when "panel" level = (@args["level"] or "normal") res << "<table #{AC} border='#{$rwd_border}' cellspacing='0' cellpadding='0'>" res << " <tr #{align}>" res << " <td #{align} class='panel1'>" if level == "normal" res << " <td #{align} class='panel1high'>" if level == "high" res << " <td #{align} class='panel1low'>" if level == "low" res << " <table #{AC} border='#{$rwd_border}' cellspacing='0' cellpadding='0'>" res << " <tr #{align}>" res << " <td #{align} class='panel2'>" if level == "normal" res << " <td #{align} class='panel2high'>" if level == "high" res << " <td #{align} class='panel2low'>" if level == "low" res << " <table #{AC} border='#{$rwd_border}' cellspacing='3' cellpadding='0'>" else puts "<#{@subtype}>" res << "<#{@subtype}>" end bef = nil aft = nil case @subtype when "vertical", "window", "helpwindow", "tab", "panel" res << Format % ["AftPre", @subtype] if $rwd_debug if @args.include?("spacing") s = "<tr><td> </td></tr>" * (@args["spacing"].to_i) else s = "" end bef = "#{s}<tr #{align} #{valign}><td #{align}>" aft = "</td></tr>" when "horizontal", "row" res << Format % ["AftPre", @subtype] if $rwd_debug bef = "<td #{align}>" aft = "</td>" end before.push(bef) after.push(aft) end |
#prechildren_to_sgml(res) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rwd/sgml.rb', line 88 def prechildren_to_sgml(res) a = [@subtype] @args.sort.each do |k, v| if not v.include?("'") a << "#{k}='#{v}'" else if not v.include?('"') a << "#{k}=\"#{v}\"" else a << "#{k}='#{v.gsub(/\'/, '"')}'" end end end res << "<#{a.join(" ")}>" + @text end |
#prechildren_to_x(res, closetags) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rwd/xml.rb', line 48 def prechildren_to_x(res, ) a = [@subtype] args = @args.dup args.delete("id") args.delete("name") args = args.sort args.unshift(["id", @args["id"]]) if @args.include?("id") args.unshift(["name", @args["name"]]) if @args.include?("name") args.each do |k, v| if not v.include?("'") a << "#{k}='#{v}'" else if not v.include?('"') a << "#{k}=\"#{v}\"" else a << "#{k}='#{v.gsub(/\'/, '"')}'" end end end if @children.length == 0 or (@children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.compress.empty?) res << " "*(@level-1) + "<#{a.join(" ")}/>" + "\n" else if @children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.lf.split(/\n/).length == 1 res << " "*(@level-1) + "<#{a.join(" ")}>" else res << " "*(@level-1) + "<#{a.join(" ")}>" + "\n" end end end |
#template(html, vars) ⇒ Object
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
# File 'lib/rwd/rwd.rb', line 585 def template(html, vars) res = [] a = {} vars.each do |k, v| a[k.upcase] = v end logo = nil logo = File.(vars["logo"], $rwd_files) if vars.include?("logo") logo = nil unless logo.nil? or File.file?(logo) watermark = nil watermark = File.(vars["watermark"], $rwd_files) if vars.include?("watermark") watermark = nil unless watermark.nil? or File.file?(watermark) a["LOGO"] = "" unless not logo.nil? a["WATERMARK"] = "" unless not watermark.nil? a["HELPBUTTON"] = (not (vars["nohelpbutton"])) a["BACKBUTTONS"] = (not (vars["nobackbuttons"])) a["BACKBUTTONS"] = (not (vars["nobackbuttons"])) a["CLOSEBUTTON"] = (not (vars["noclosebutton"])) if a.include?("WIDTH") a["WIDTH1"] = "width='#{a["WIDTH"]}'" a["WIDTH2"] = a["WIDTH"] else a["WIDTH1"] = " " a["WIDTH2"] = "1" end html.split(/\r*\n/).each do |line| if line =~ /%[A-Z0-9]+%/ a.each do |k, v| v = false if (v.kind_of?(String) and v.empty?) if line.include?("%#{k}%") line.gsub!("%#{k}%", "#{v}") if v end end line = "<!-- #{line.scan(/%[A-Z0-9]+%/).join(" ")} -->" if line =~ /%[A-Z0-9]+%/ end res << line end res.join("\n") end |