Intrepid has asked for the wisdom of the Perl Monks concerning the following question:

Hello variously brilliant brothers and sisters. I am seeking to save myself some work by finding a system (script, app) that will simply list the files in a directory, an index if you will. Naturally every listing will be a hyperlink to that html file. I am doing this on a Debian box I rescued from oblivion. It has Apache2 installed already: 2.4.59-1. The files being served are converted-to-html programs and scripts I've written (not that that is relevant to this question).

The contents of the directory will not change frequently, so a script that builds a good-looking static index would suffice. However, I am keeping my mind open to installing (or writing) a dynamic apache application. I have no experience with apache and such applications, but at one time I was a passable web author and knew my way around the DOM and CSS.

A glance at Google showed that there are an overwhelming number of "Web Frameworks" and so on. I am lost. You would be doing a benevolent deed if you'd point me towards something that's (1) easy to install, and (2) easy to understand.

Dec 18, 2024 at 02:15 UTC

A just machine to make big decisions
Programmed by fellows (and gals) with compassion and vision
We'll be clean when their work is done
We'll be eternally free yes and eternally young
Donald Fagen -> I.G.Y.
(Slightly modified for inclusiveness)

  • Comment on A "landing page" or "microsite" for my LAN - running Apache

Replies are listed 'Best First'.
Re: A "landing page" or "microsite" for my LAN - running Apache
by hippo (Archbishop) on Dec 18, 2024 at 09:46 UTC

    The easiest thing to install is something that's already there. With that in mind, consider mod_autoindex which you already have as part of Apache. Its purpose is exactly as you have stated. The default page is pretty basic but you can style it as you wish using the IndexStyleSheet directive.


    🦛

      I thank you hippo, and all the other fast responders who offered me suggestions.

      I remember when mojolicious was released (I've been a participant in the Monastery for a looong time ;-) and I remember that there was a lot of excitement about it. My curiosity may pull me in that direction!

      I will follow-up in this thread.

      Dec 18, 2024 at 17:48 UTC

      A just machine to make big decisions
      Programmed by fellows (and gals) with compassion and vision
      We'll be clean when their work is done
      We'll be eternally free yes and eternally young
      Donald Fagen -> I.G.Y.
      (Slightly modified for inclusiveness)

Re: A "landing page" or "microsite" for my LAN - running Apache
by Discipulus (Canon) on Dec 18, 2024 at 08:51 UTC
    Hello Intrepid,

    marto is absolutly right about Mojolicious but you can also consider Dancer2.

    For such a simple task you can also go with ( stolen from: here ):

    plackup -p 5000 -MPlack::App::Directory -e 'Plack::App::Directory->new({root => q{.}})->to_app'

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: A "landing page" or "microsite" for my LAN - running Apache
by marto (Cardinal) on Dec 18, 2024 at 08:15 UTC
Re: A "landing page" or "microsite" for my LAN - running Apache
by vincent_veyron (Beadle) on Dec 19, 2024 at 17:08 UTC

    You should not have to do anything, as Apache builds an index of the files present in the directory if a URL maps to a directory, unless mod_autoindex is disabled

    see the documentation, scroll down to Indexes. You can use :

    <Location /path/to/directory> Options +Indexes </Location>

    to fine tune what locations you allow or not (with -Indexes) in your relevant .conf file

    https://compta.libremen.com

    Logiciel libre de comptabilité générale en partie double

Re: A "landing page" or "microsite" for my LAN - running Apache
by Fletch (Bishop) on Dec 18, 2024 at 16:32 UTC

    Haven't used myself but you might look at something off the shelf: https://gethomepage.dev/

    That being said a lite Mojo app might be what you're looking for (just embed everything in a single file).

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: A "landing page" or "microsite" for my LAN - running Apache
by Anonymous Monk on Dec 18, 2024 at 14:11 UTC
Re: A "landing page" or "microsite" for my LAN - running Apache
by InfiniteSilence (Curate) on Dec 20, 2024 at 07:18 UTC

    The whole point of this site is to help you to learn to program in Perl. That means you have to try things out. That being said, you can do something like this:

    # Make a file called linkable.pl with these contents #!/usr/bin/perl -w my $n = $ARGV[0]; $n=~s{^\.\/}{}; my $path = q~http://www.fooberry.com~; print qq~<a href="$path/$n">$n</a>\n~; 1;

    Now you can make a script that does this to make links:

    find . -name "*.txt" -exec ./linkable.pl {} \;

    Redirect the output to a file. If you have a header in one file and a footer in another you can just append them all to make a single html file. You can make a cron job to run this periodically or utilities exist to help you monitor a directory for changes. I would research using Perl's File::Find module to make a single script to better understand the language.

    Celebrate Intellectual Diversity

      Thank you for a thorough and educational reply InfiniteSilence.

      I like the way your suggestion is broken down into readily understandable pieces. I've involved myself with File::Find in the past but I think I need a refresher. And I need patience. I stopped writing programs (in any language) for about 8 years and it is sometimes frustrating to see that I've forgotten so much.

      Dec 22, 2024 at 19:13 UTC

      A just machine to make big decisions
      Programmed by fellows (and gals) with compassion and vision
      We'll be clean when their work is done
      We'll be eternally free yes, and eternally young
      Donald Fagen -> I.G.Y.
      (Slightly modified for inclusiveness)