Thread: HTML: everything from generated to WYSIWYG

  1. #1
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057

    HTML: everything from generated to WYSIWYG

    [For reference, here's my website: http://dwks.theprogrammingsite.com/]

    My website has undergone many changes. The first half a dozen or so versions of it I didn't even release. Then I wrote a version similar to what you see now. Then I modified it to use CSS.

    Now I want to change it again. I was writing my website entirely in hand-coded HTML, and as you are probably aware this becomes very tedious. So I looked into alternatives, and eventually I came up with the Perl module Text::Template. It's neat: you can embed Perl code directly into a file. It works pretty well; I can automatically generate links.htm with the following (note that I made up the extensions):

    links.ih
    Code:
    {
        $root = '.';
        $title = links;
        &include("$root/head.iht");
    }
    <h1>DWK's links</h1>
    
    <p><big>H</big>ere are some links I've
    accumulated. (On forums, unless otherwise noted, I'm usually the user
    {&mono('dwks')}.)</p>
    
    <p>Click <a href="links.htm" target="_new">here</a> to open a new window.</p>
    
    {
        my $data = {
            'General' => [
                {
                    'name' => 'Google',
                    'url' => 'http://www.google.com/',
                    'description' => 'My favorite search engine. ' . &mono(':)')
                        . ' To search for "C game programming", you can use ' .
                        &monolink("http://www.google.com/search?q=c+game+programming")
                        . ' -- useful for slow internet connections etc.'
                },
                {
                    'name' => 'Wikipedia',
                    'url' => 'http://www.wikipedia.org/',
                    'description' => 'An online encyclopedia.'
                },
                {
                    'name' => 'Firefox',
                    'url' => 'http://www.firefox.com/',
                    'description' => 'The home page for Mozilla Firefox, an excellent web browser.'
                }
            ],
            'Programming' => [
                {
                    'name' => 'Dev-C++',
                    'url' => 'http://www.bloodshed.net/devcpp.html',
                    'description' => 'The download site for Dev-C++, a free Win32 development enviroment for C and C++.'
                },
                {
                    'name' => 'DJGPP',
                    'url' => 'http://www.delorie.com/djgpp/',
                    'description' => 'The download site for DJGPP (or RHIDE), a free DOS development enviroment.'
                        . ' It has POSIX support, and can compile really old programs that use DOS interrupts and int86'
                        . ' and graphics mode 13h.'
                },
                {
                    'name' => 'Nehe',
                    'url' => 'http://nehe.gamedev.net/',
                    'description' => 'An excellent site (with tutorials) for OpenGL.'
                },
                {
                    'name' => 'SDL',
                    'url' => 'http://www.libsdl.org/',
                    'description' => 'The offical SDL (Simple DirectMedia Layer) page. The SDL is a multi-platform'
                        . ' (Win32, Linux, Mac, etc) graphics (and sound, etc) library.'
                }
            ],
            'Programming forums' => [
                {
                    'name' => 'CBoard',
                    'url' => 'http://cboard.cprogramming.com/',
                    'description' => "An excellent programming forum for C/C++/C# etc. There's also an FAQ, " .
        &monolink("http://faq.cprogramming.com/") . ' The main page is at (you guessed it) ' .
        &monolink("http://www.cprogramming.com/")
                },
                {
                    'name' => 'TPSBoard',
                    'url' => 'http://board.theprogrammingsite.com/',
                    'description' => 'A good (but small) programming forum, with sections for C, C++, Java, etc.'
                },
                {
                    'name' => 'DaniWeb',
                    'url' => 'http://www.daniweb.com/techtalkforums/',
                    'description' => 'A very busy board for programming and technology.'
                }
            ]
        };
        
        foreach my $section (sort keys &#37;$data) {
            $OUT .= "<h3>$section</h3>\n"
                . '<ul class="linklist">' . "\n";
            
            foreach(@{$data->{$section}}) {
                $OUT .= &include('linkitem.iht');
            }
            
            $OUT .= "</ul>\n\n";
        }
    }
    
    {&include("$root/tail.iht")}
    linkitem.iht
    Code:
        <li><a href="{$_->{'url'}}">{$_->{'name'}} | {&mono($_->{'url'})}</a><br />
        {$_->{'description'}}</li>
    The other files are boring, so I don't show them here.

    But then I thought that links.ih was getting a little unwieldy. Perhaps I could use XML to store the data. So I'm looking into that.

    I really should change that text . . . I wrote it in a few seconds as placeholder text, not thinking I would actually publish it . . .

    Anyway, it just seemed like I was making everything too complicated. How else can I generate these webpages? What do people on this board use?

    My website has Perl, PHP, and a MySQL database, if that means anything. Out of the three, however, I only know how to use Perl.

    On the other end of the spectrum, I have a friend who knows absolutely nothing about HTML and wants to create a web page. What WYSIWYG editors or whatever could I recommend to them?

    [edit] 5,200th post! [/edit]
    Last edited by dwks; 10-10-2007 at 03:00 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #2
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    http://freerichtexteditor.com/

    I've used in a couple of projects and its works quite well. I have not tested all functions yet though. Wether it is w3c valid generated code I do not know (not that I dont care but the projects I used it for were already badly invalid to w3c standards, and to convert it to the standards would just take too much time so... ).

    Anyhow thats for the rte.

    I created my own simple "cms" like system a while ago... basically what I do is have a index.php file , that reads in a directory structure, this contains templates folders, image and other resource folders and of course the navigation structure.

    So one could do something like:

    Mywebsite:
    |-1_Home
    |--index.html
    |-2_Products
    |--1_productOne.html
    |--2_productTwo.html
    |-3_About
    |--index.html
    |-4_Contact
    |--index.html

    Where 1_Home to 4_Contact are directories, if it contains index.html then this is the page to show. Else check for other pages starting with a [0-9]_pagename...

    Anyhow, the php then builds the navigation structure, uses caching (saving the generated html to a temporary file) and parses and outputs everything in the right order (important when using forms in plain html pages that are buried in a subdirectory somewhere).

    Its a simple, fast and effective system ive created to setup website that have around 5 to lets say 30 pages...

    Also when using this with apache you can easily do url redirection so that a user does not see all these weird parameters in the url that defines which page they are about to see... instead they will see something like mysite.tld/2_Products/3_UberBlender/. (if you would want to get rid of the numbers; another way of storing this information would be xml or a mysql db where you could store this, but since my approach is for simple and small sites ... well you get the point).

    Using this system and the RTE has really saved alot of my time, the original development costs were only 2 days but Ive saved much more time by now by implementing it in different projects (also since each project is slightly different I already have alot of things i can put in and will work magically , like a search function etc..).

    Note that all of the above is achieved without any mysql database (it's still fast and effective as long as you use caching).

    *edit* 1010 post , a magical looking number

    Also, since the php file generates strictly xhtml all layout and design is being done with css. This means that its also very easy to apply different templates later on (if the customer asks for this, which is very likely since customers change thoughts about a gazillion time ..... thats where project planning and functional description of websites come in handy)
    Last edited by GanglyLamb; 10-10-2007 at 03:24 PM.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Hmm, sounds interesting . . . I've never had a need to use a Rich Edit text entry dialog, but they do look interesting.

    I'll definitely have to look into some CMSes.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    As for your friend, WYSIWYG editors are unfortunately expensive and not as widespread as one would probably prefer.

    My recommendation would be Dreamweaver CS3. It used to be Macromedia's. Now it's Adobe's.

    On the other end of the wallet there's always Microsoft Word or any other text processing software that can save files as HTML.

    If you can convince your friend to learn a little of HTML (always a good thing), you can direct him towards W3Schools for the best tutorials in the whole web and to a cheap tool like WeBuilder, HomeSite or HotDog, in order of preference, as good tools that guide the wannabe web designer slash developer.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    MS Word generates a horrble html
    I prefer HomeSite for html/css editing
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I thought I might have a look at some of these: http://en.wikipedia.org/wiki/List_of...YSIWYG_editors

    Any suggestions?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help - C code creates dynamic HTML
    By Christie2008 in forum C Programming
    Replies: 19
    Last Post: 04-02-2008, 07:36 PM
  2. Writing an HTML Preprocessor
    By thetinman in forum C++ Programming
    Replies: 1
    Last Post: 09-17-2007, 08:01 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Design + HTML
    By orbitz in forum C Programming
    Replies: 8
    Last Post: 11-21-2002, 06:32 AM