• Couple of JS Questions

    From Apam@VERT/POSITRON to All on Monday, May 23, 2022 19:34:28
    Hi

    I'm mucking around in JS, and am creating a gemini service for synchronet. It serves files in /sbbs/text/gemini/ (not exactly hard coded, i'm using system.text_dir + "gemini".)

    First question, is it possible in synchronet javascript to determine the mime-type of a file?

    At present I'm just using a switch statement based on the extension - is this the best way to do things?

    The second question, I'd like to add cgi type interface, which would load javascript files from the gemini root. I'm unsure how to execute another javascript file from within a service javascript file (or at all).

    Andrew

    ---
    ■ Synchronet ■ The Positronic Brain
  • From poindexter FORTRAN@VERT/REALITY to Apam on Monday, May 23, 2022 06:36:00
    Apam wrote to All <=-

    I'm mucking around in JS, and am creating a gemini service for
    synchronet. It serves files in /sbbs/text/gemini/ (not exactly hard
    coded, i'm using system.text_dir + "gemini".)

    <ears perked in Apam's direction>




    ... Are there sections? Consider transitions
    --- MultiMail/DOS v0.52
    ■ Synchronet ■ .: realitycheckbbs.org :: scientia potentia est :.
  • From Digital Man@VERT to Apam on Monday, May 23, 2022 11:49:04
    Re: Couple of JS Questions
    By: Apam to All on Mon May 23 2022 07:34 pm

    Hi

    I'm mucking around in JS, and am creating a gemini service for synchronet. It serves files in /sbbs/text/gemini/ (not exactly hard coded, i'm using system.text_dir + "gemini".)

    First question, is it possible in synchronet javascript to determine the mime-type of a file?

    You could load ctrl/mime_types.ini using the File class and compare the extension.

    At present I'm just using a switch statement based on the extension - is this the best way to do things?

    Ideally, you'd use the same mime_types.ini file used by the web server.

    The second question, I'd like to add cgi type interface, which would load javascript files from the gemini root. I'm unsure how to execute another javascript file from within a service javascript file (or at all).

    load(), require() and js.exec() are used to execute a JS file from a JS file. --
    digital man (rob)

    Synchronet/BBS Terminology Definition #90:
    UTF-8 = 8-bit Unicode Transformation Format
    Norco, CA WX: 66.8°F, 69.0% humidity, 8 mph SSE wind, 0.00 inches rain/24hrs ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Apam@VERT/POSITRON to Digital Man on Tuesday, May 24, 2022 09:54:00
    On Mon May 23 11:49:00 2022, Digital Man wrote to Apam <=-

    First question, is it possible in synchronet javascript to determine the mime-type of a file?

    You could load ctrl/mime_types.ini using the File class and compare the extension.

    Great. That's what I'm now doing.

    The second question, I'd like to add cgi type interface, which would load javascript files from the gemini root. I'm unsure how to execute another javascript file from within a service javascript file (or at all).

    load(), require() and js.exec() are used to execute a JS file from a JS file.

    Thanks! I've not done this yet, but will soon.

    If anyone is interested in looking at it, I put it up here:

    https://github.com/apamment/geminiserv

    Andrew

    --
    Andrew Pamment (apam)

    === TitanMail/linux v1.1.5

    ---
    ■ Synchronet ■ The Positronic Brain
  • From Apam@VERT/POSITRON to Digital Man on Tuesday, May 24, 2022 10:18:00
    On Mon May 23 11:49:00 2022, Digital Man wrote to Apam <=-

    load(), require() and js.exec() are used to execute a JS file from a JS file.

    I think I need to use js.exec.apply() so I can pass the query argument.. but can't seem to find any information on it..

    I see it's used in install-xtrn

    var result = js.exec.apply(null
    ,[js_file, item.startup_dir, {}].concat(js_args));

    but unsure what that first null is.

    Andrew

    --
    Andrew Pamment (apam)

    === TitanMail/linux v1.1.5

    ---
    ■ Synchronet ■ The Positronic Brain
  • From Digital Man@VERT to Apam on Monday, May 23, 2022 22:00:05
    Re: Couple of JS Questions
    By: Apam to Digital Man on Tue May 24 2022 10:18 am

    On Mon May 23 11:49:00 2022, Digital Man wrote to Apam <=-

    load(), require() and js.exec() are used to execute a JS file from a JS file.

    I think I need to use js.exec.apply() so I can pass the query argument.. but can't seem to find any information on it..

    I see it's used in install-xtrn

    var result = js.exec.apply(null
    ,[js_file, item.startup_dir, {}].concat(js_args));

    but unsure what that first null is.

    js.exec() is a function, so: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
    --
    digital man (rob)

    Rush quote #19:
    Rebel without a conscience, martyr without a cause
    Norco, CA WX: 57.6°F, 87.0% humidity, 2 mph SE wind, 0.00 inches rain/24hrs
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Apam@VERT/POSITRON to Digital Man on Wednesday, May 25, 2022 08:16:36
    Re: Couple of JS Questions
    By: Digital Man to Apam on Mon May 23 2022 10:00 pm

    js.exec() is a function, so: https://developer.mozilla.org/en-US/docs/Web/JavaS

    Thanks! I feel like such a newbie lol I had assumed it was a synchronet command and was going through the synchronet javascript stuff on the wiki.

    Andrew

    ---
    ■ Synchronet ■ The Positronic Brain