DoctorD90

Txt2Html.tcl 1.0.0

Apr 27th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.91 KB | None | 0 0
  1. ### Txt2Html.tcl 1.0.0 fFG93nkC
  2.  
  3. #SUGGESTED
  4. # PBinSrc.tcl fMrtKqyq
  5.  
  6. #LICENSE
  7. # Copyright © 2013 Alberto Dietze "DoctorD90"
  8. #
  9. #    This program is free software: you can redistribute it and/or modify
  10. #    it under the terms of the GNU General Public License as published by
  11. #    the Free Software Foundation, either version 3 of the License, or
  12. #    (at your option) any later version.
  13. #
  14. #    This program is distributed in the hope that it will be useful,
  15. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. #    GNU General Public License for more details.
  18. #
  19. #    You should have received a copy of the GNU General Public License
  20. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
  23.  
  24. #PATERNITY
  25. #Coder: DoctorD90
  26. #Network: irc.OnlineGamesNet.net
  27. #Chan: #eHito
  28.  
  29. #PURPOSE
  30. #Converts text files into html pages.
  31.  
  32. #USAGE
  33. #Add this script to your eggdrop's list to load it.
  34.  
  35.  
  36. ### DON'T EDIT ANYTHING BELOW ###
  37.  
  38. proc txt2html {file lines {title ""}} {
  39.   if {![string length $file] || ![llength $lines]} {
  40.     return 0
  41.   }
  42.   if {![string match -nocase "*.html" $file]} {
  43.     append file ".html"
  44.   }
  45.   if {![string length $title]} {
  46.     set title [string trim [join [lrange [split [lindex [split $file "/"] end] "."] 0 end-1]]]
  47.   }
  48.   set fs [open "$file" w]
  49.   puts $fs "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><br><HTML>"
  50.   puts $fs "  <HEAD>"
  51.   puts $fs "    <META CONTENT=\"text/html; charset=ISO-8859-1\" http-equiv=\"content-type\">"
  52.   puts $fs "      <TITLE>$title</TITLE>"
  53.   puts $fs "  </HEAD>"
  54.   puts $fs "  <BODY>"
  55.   puts $fs [join $lines "<br>\n"]
  56.   puts $fs "  </BODY>"
  57.   puts $fs "</HTML>"
  58.   close $fs
  59.   return 1
  60. }
  61.  
  62. ###
  63. putlog "Txt2Html.tcl LOADED"
Advertisement