Thread: HTML: everything from generated to WYSIWYG

Threaded View

Previous Post Previous Post   Next Post Next Post
  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.

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