JegasAPI - Jegas, LLC - Copyright(c)2016

Unit uj_fileserv

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Handles Serving Files in a webserver role

Overview

Functions and Procedures

Function getfile(p_Context: TCONTEXT; p_saFilename: AnsiString; var p_uHTTPResponse: word): AnsiString;
Function saHtmlRipper(p_Context: TCONTEXT; p_i8Caller: uint64): AnsiString;
Function saGetPage( p_Context: TCONTEXT; p_saArea: AnsiString; p_saPage: AnsiString; p_saSection: AnsiString; p_bSectionOnly: Boolean; p_saCustomSection: AnsiString; p_i8Caller: uint64 ): AnsiString;
Function saGetPage( p_Context: TCONTEXT; p_saArea: AnsiString; p_saPage: AnsiString; p_saSection: AnsiString; p_bSectionOnly: Boolean; p_i8Caller: uint64 ): AnsiString;
procedure JAS_NoteSecure(p_Context: TCONTEXT);
procedure JAS_RenderMindMap(p_Context: TCONTEXT);

Description

Functions and Procedures

Function getfile(p_Context: TCONTEXT; p_saFilename: AnsiString; var p_uHTTPResponse: word): AnsiString;

This is the internal function that serves all the webserver files. It works by simply passing in the filename you are after and you typically pass in a p_iHTTPResponse of 200 (see cnHTTP_RESPONSE_200 defined in uxxg_common.pp for sample response codes.) Upon return, the function returns the complete file as its result with a potentially different value in p_iHTTPResponse.

Function saHtmlRipper(p_Context: TCONTEXT; p_i8Caller: uint64): AnsiString;

HTMLRIPPER is the pet name for the JAS templating system. HTMLRIPPER was originally created as a tool to make creating websites easier by not needing to have repetitive HTML code throughout a website. It has since matured into a pretty powerful templating system. The core of this templating system is "Function saGetPage".

This saHTMLRIPPER function is a wrapper for the basic HTMLRIPPER usage where you can have an AREA (template) and load content from a "PAGE" and selectively display a certain "SECTION" in the page as needed.

NOTE: Caller parameter added so you can track who called the function when debugging. Optimizations could include compiler directives to electively compile without the extra debugging code - then again - its helpful when you're LIVE too!

Function saGetPage( p_Context: TCONTEXT; p_saArea: AnsiString; p_saPage: AnsiString; p_saSection: AnsiString; p_bSectionOnly: Boolean; p_saCustomSection: AnsiString; p_i8Caller: uint64 ): AnsiString;

This Function Call Has become a litle advanced. At least in that its time to Explain how it works. In short - it takes parameters that tell it how to build a HTML page from templates. It does this and returns the compiled HTML.

p_saArea: is the HTMLRIPPER template filename without the file name extension. If nothing is passed then the filename specified in grJASConfig.saDefaultPage is used (This file MUST Exist even if it is not actually used for SECTION ONLY calls Explained below) First this file is searched for in the same directory the JEGAS CGI THIN CLIENT is launched from. Then it looks in the configured JAS HTML directory for it. If an AREA file (Default or otherwise) cannot be located and loaded - an error is returned to the user. (Case Sensitive. Lowercase .html presumed)

p_saPage: This is the HTML file that has the SECTION you wish to load. It first search for this file in the directory the JEGAS CGI THIN CLIENT was launched in. If it is not there, it looks in the configured JAS HTML directory. If the file cannot be loaded, an error is generated. (Case Sensitive. Lowercase .html presumed) (Note: IF ANYTHING AT ALL IS PASSED in the p_saCustomSection parameter, then this PARAMETER is IGNORED!)

p_saSection: This is the NAME of the SECTION you want to RIP out of the p_saPage template. Sections are discerned from HTML comments that look like: <!–SECTION SECTIONNAME BEGIN–> <!–SECTION SECTIONNAME END–>

The above "SECTIONAME" is where you name your section. Do not use spaces, USE ALL UPPERCASE. The parameter you pass to look for the the section does not need to be in uppercase. This is done for you.

If the SECTION cannont be found in the html template file you specified in p_saPage, then the whole p_saPage data is sent. This is usually undesired, so make your HTML templates carefully.

(Note: IF ANYTHING AT ALL IS PASSED in the p_saCustomSection parameter, then this PARAMETER is IGNORED!)

p_bSectionOnly: If this parameter is passed as true, this function only returns the HTML in between the SECTION TAGS explained above or the p_saCustomSection value.

(optional) p_saCustomSection: This parameter allows you to send HTML and have it inserted into the AREA template. Because this overrides the p_saPage and p_saSection parameters, and allows you to pass your own CUSTOM SECTION into an AREA (htmlripper) template, you can get silly results by setting the p_bSectionOnly flag to true. Simply put, if you do that (not likely you should) this function will simply return your passed custom section. NOTE: Caller parameter added so you can track who called the function when debugging. Optimizations could include compiler directives to electively compile without the extra debugging code - then again - its helpful when you're LIVE too!

Function saGetPage( p_Context: TCONTEXT; p_saArea: AnsiString; p_saPage: AnsiString; p_saSection: AnsiString; p_bSectionOnly: Boolean; p_i8Caller: uint64 ): AnsiString;

This is a shorterhand method of using saGetPAge. See the other one for the full description of saGetPage's functionality.

NOTE: Caller parameter added so you can track who called the function when debugging. Optimizations could include compiler directives to electively compile without the extra debugging code - then again - its helpful when you're LIVE too!

procedure JAS_NoteSecure(p_Context: TCONTEXT);

returns Note providing session is valid and JNote_Table_ID points to jsecperm and JNote_Row_ID points to the required permission. If null or zero, no permission required to get it! So pay attention! LOL ;)

example: ?action=????&decodeuri=yes&uid=100

where UID = [JNote_JNote_UID]

Language is taken into consideration!

procedure JAS_RenderMindMap(p_Context: TCONTEXT);
 
http://www.jegas.com
Generated by PasDoc 0.14.0.