Lang parameters

Sean Conner sean at conman.org
Mon Aug 31 05:42:09 BST 2020


It was thus said that the Great Sandra Snan once stated:
> Right, thank you all for your answers so far!♥
> 
> I guess what I should've asked is to what extent servers already can do
> this. Sean mentioned GLV-1.12556 but it's not in sample-conf.lua as far
> as I can see. I guess with gig writing a custom router is also an
> option.

  Ah, I see I failed to give some good examples of this in sample-conf.lua.
You can certainly do this in GLV-1.12556 on a server-wide, host-wide, or
directory-wise or file-wise manner.  For example, if you have Swedish
material in a given directory, you can do:

hosts =
{
  ['example.com'] =
  {
    handlers =
    {
      {
        path      = "^(/Swedish-stuff/)(.*)",
        module    = "GLV-1.handlers.filesystem",
        directory = "/path/to/contents",
        index     = "index.gmi", -- GLV-1.12556 defaults to .gemini
        extension = ".gmi",
        mime =
        {
          gmi = "text/gemini; lang=se_NO", -- <<<< important bit
          txt = "text/plain; lang=se_NO",
        }
      }
    }
  }
}

  If you don't include the mime section, the server will (at least on Linux,
or any POSIX system with GNU's libmagic installed) return whatever it deems
is the MIME type for a given file (it uses magic values and huristics to
determine the MIME type).

  The sample-conf.lua file has several mime blocks scattered throughout to
show where it can be included.  

> I just don't wanna be reinventing any existing wheels.
> 
> I have a collection of texts in a mix of languages. Each file is written
> in a single language.
> 
> I'm OK with a sidecar per file, a sidecar per directory, one big sidecar
> for the entire site, or with renaming the files: for example the server
> gets the request for foo.gmi, it finds foo.en.gmi and serves that up as
> foo.gmi in English. (Or a similar convention, foo.gmi-en, foo-en.gmi,
> foo.en, I can adapt my data to fit what the server wants.) For the
> sidecar solutions, I obv don't want to serve up those sidecars via
> Gemini requests, they're for the server's eyes only.

  Hmmm ... good point.
  
> Any server so far do any one of those four things (with an already
> existing module, plugin, configuration, or out of the box)?
> 
> I understand that Gig or GLV-1.12556 can do it with scripting; does
> those scripts already exist?

  While the configuration file for GLV-1.12556 is a Lua script, you can
think of it more as a configuration file.  So in this case, GLV-1.12556 can
be configured to do this out of the box.

  On the downside, installing GLV-1.12556 might not be that easy, as it
relies upon LibreSSL instead of OpenSSL.  And GNU libmagic, which somes
stock on Linux, not sure about other systems.

  -spc


More information about the Gemini mailing list