mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-11 10:18:45 +02:00
pas2js: compileserver: fall back mime.types
git-svn-id: trunk@41666 -
This commit is contained in:
parent
fa87f8870c
commit
f52ea868dd
@ -6,7 +6,6 @@ program compileserver;
|
|||||||
uses
|
uses
|
||||||
{$IFDEF UNIX}cthreads,{$ENDIF} httpcompiler;
|
{$IFDEF UNIX}cthreads,{$ENDIF} httpcompiler;
|
||||||
|
|
||||||
|
|
||||||
Var
|
Var
|
||||||
Application : THTTPCompilerApplication;
|
Application : THTTPCompilerApplication;
|
||||||
|
|
||||||
|
@ -6,9 +6,8 @@ unit httpcompiler;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
sysutils, classes, fpjson, contnrs, syncobjs, custhttpapp, fpwebfile, httproute,
|
sysutils, classes, fpjson, contnrs, syncobjs, fpmimetypes, custhttpapp,
|
||||||
httpdefs, dirwatch,
|
fpwebfile, httproute, httpdefs, dirwatch, Pas2JSFSCompiler, Pas2JSCompilerCfg;
|
||||||
Pas2JSFSCompiler, Pas2JSCompilerCfg;
|
|
||||||
|
|
||||||
Const
|
Const
|
||||||
nErrTooManyThreads = -1;
|
nErrTooManyThreads = -1;
|
||||||
@ -101,8 +100,10 @@ Type
|
|||||||
procedure DoRecompile(ARequest: TRequest; AResponse: TResponse);
|
procedure DoRecompile(ARequest: TRequest; AResponse: TResponse);
|
||||||
function ScheduleCompile(const aProjectFile: String; Options : TStrings = Nil): Integer;
|
function ScheduleCompile(const aProjectFile: String; Options : TStrings = Nil): Integer;
|
||||||
procedure StartWatch(ADir: String);
|
procedure StartWatch(ADir: String);
|
||||||
procedure Usage(Msg: String);
|
protected
|
||||||
function GetDefaultMimetypes: string;
|
procedure Usage(Msg: String); virtual;
|
||||||
|
function GetDefaultMimeTypesFile: string; virtual;
|
||||||
|
procedure LoadDefaultMimeTypes; virtual;
|
||||||
public
|
public
|
||||||
Constructor Create(AOWner : TComponent); override;
|
Constructor Create(AOWner : TComponent); override;
|
||||||
Destructor Destroy; override;
|
Destructor Destroy; override;
|
||||||
@ -262,13 +263,13 @@ begin
|
|||||||
Writeln('-q --quiet Do not write diagnostic messages');
|
Writeln('-q --quiet Do not write diagnostic messages');
|
||||||
Writeln('-w --watch Watch directory for changes');
|
Writeln('-w --watch Watch directory for changes');
|
||||||
Writeln('-c --compile[=proj] Recompile project if pascal files change. Default project is app.lpr');
|
Writeln('-c --compile[=proj] Recompile project if pascal files change. Default project is app.lpr');
|
||||||
Writeln('-m --mimetypes=file filename of mimetypes. Default is ',GetDefaultMimetypes);
|
Writeln('-m --mimetypes=file filename of mimetypes. Default is ',GetDefaultMimeTypesFile);
|
||||||
Writeln('-s --simpleserver Only serve files, do not enable compilation.');
|
Writeln('-s --simpleserver Only serve files, do not enable compilation.');
|
||||||
Halt(Ord(Msg<>''));
|
Halt(Ord(Msg<>''));
|
||||||
{AllowWriteln-}
|
{AllowWriteln-}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function THTTPCompilerApplication.GetDefaultMimetypes: string;
|
function THTTPCompilerApplication.GetDefaultMimeTypesFile: string;
|
||||||
begin
|
begin
|
||||||
{$ifdef unix}
|
{$ifdef unix}
|
||||||
Result:='/etc/mime.types';
|
Result:='/etc/mime.types';
|
||||||
@ -281,6 +282,22 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure THTTPCompilerApplication.LoadDefaultMimeTypes;
|
||||||
|
begin
|
||||||
|
MimeTypes.AddType('application/xhtml+xml','xhtml;xht');
|
||||||
|
MimeTypes.AddType('text/html','htmll;htm');
|
||||||
|
MimeTypes.AddType('text/plain','txt');
|
||||||
|
MimeTypes.AddType('application/javascript','js');
|
||||||
|
MimeTypes.AddType('text/plain','map');
|
||||||
|
MimeTypes.AddType('application/json','json');
|
||||||
|
MimeTypes.AddType('image/png','png');
|
||||||
|
MimeTypes.AddType('image/jpeg','jpeg;jpg');
|
||||||
|
MimeTypes.AddType('image/gif','gif');
|
||||||
|
MimeTypes.AddType('image/jp2','jp2');
|
||||||
|
MimeTypes.AddType('image/tiff','tiff;tif');
|
||||||
|
MimeTypes.AddType('application/pdf','pdf');
|
||||||
|
end;
|
||||||
|
|
||||||
constructor THTTPCompilerApplication.Create(AOWner: TComponent);
|
constructor THTTPCompilerApplication.Create(AOWner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOWner);
|
inherited Create(AOWner);
|
||||||
@ -547,8 +564,15 @@ begin
|
|||||||
if HasOption('m','mimetypes') then
|
if HasOption('m','mimetypes') then
|
||||||
MimeTypesFile:=GetOptionValue('m','mimetypes');
|
MimeTypesFile:=GetOptionValue('m','mimetypes');
|
||||||
if MimeTypesFile='' then
|
if MimeTypesFile='' then
|
||||||
MimeTypesFile:=GetDefaultMimetypes;
|
begin
|
||||||
if (MimeTypesFile<>'') and not FileExists(MimeTypesFile) then
|
MimeTypesFile:=GetDefaultMimeTypesFile;
|
||||||
|
if not FileExists(MimeTypesFile) then
|
||||||
|
begin
|
||||||
|
MimeTypesFile:='';
|
||||||
|
LoadDefaultMimeTypes;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else if not FileExists(MimeTypesFile) then
|
||||||
Log(etWarning,'mimetypes file not found: '+MimeTypesFile);
|
Log(etWarning,'mimetypes file not found: '+MimeTypesFile);
|
||||||
FBaseDir:=D;
|
FBaseDir:=D;
|
||||||
if not ServeOnly then
|
if not ServeOnly then
|
||||||
|
Loading…
Reference in New Issue
Block a user