diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-03-27 18:12:44 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-03-27 18:12:44 -0400 |
commit | c7bf38f440c3e1cafd2ddb35d4505e936d4e3e86 (patch) | |
tree | fadb6178fb5be6316c6e71774d3fb6f7f425bf70 | |
parent | fd9077056f7f33c60b218636ead0644d42e75a09 (diff) | |
download | levitating-c7bf38f440c3e1cafd2ddb35d4505e936d4e3e86.tar.gz levitating-c7bf38f440c3e1cafd2ddb35d4505e936d4e3e86.zip |
Starting work towards processing external gemini requests.
-rw-r--r-- | captain/config.f90 | 11 | ||||
-rw-r--r-- | captain/external.f90 | 29 | ||||
-rw-r--r-- | captain/gemini.f90 | 14 | ||||
-rw-r--r-- | captain/templates/index.gmi | 1 | ||||
-rw-r--r-- | player/endpoints.f90 | 8 |
5 files changed, 54 insertions, 9 deletions
diff --git a/captain/config.f90 b/captain/config.f90 index e66d42f..338dc4d 100644 --- a/captain/config.f90 +++ b/captain/config.f90 @@ -118,4 +118,15 @@ contains end subroutine load_configuration + subroutine template_filepath(x, res) + use utilities, only: combine_paths + implicit none + + character(*), intent(in)::x + character(*), intent(out)::res + + call combine_paths(template_directory, x, res) + + end subroutine template_filepath + end module config diff --git a/captain/external.f90 b/captain/external.f90 index 56a7317..d33e13d 100644 --- a/captain/external.f90 +++ b/captain/external.f90 @@ -5,12 +5,39 @@ implicit none contains subroutine external_request_gemini(request) + use page_template implicit none character(*), intent(in)::request + + character(1024)::template_file + type(template)::page + + ! Open the base template + call template_filepath("index.gmi", template_file) + call page%init(template_file) + + if(trim(request) == "/" .or. trim(request) == "/index.gmi") then - + + else if(trim(request) == "/releases.gmi") then + + + + else if(trim(request) == "/jobs.gmi") then + + + + else if(trim(request) == "/players.gmi") then + + + + else if(trim(request) == "/about.gmi") then + + + end if + end subroutine external_request_gemini end module external_handling
\ No newline at end of file diff --git a/captain/gemini.f90 b/captain/gemini.f90 index ce7b984..7f21392 100644 --- a/captain/gemini.f90 +++ b/captain/gemini.f90 @@ -120,11 +120,17 @@ contains call write_log("Request is "//trim(request)) - ! If it ends in a slash, let's manually and silently add "index.gmi" - if(request(len_trim(request):len_trim(request)) == "/") then - request = trim(request)//"index.gmi" + if(len_trim(request) .ge. 4) then + if(request(1:4) == '/api') then + !call handle_api_request(request) + else + call external_request_gemini(request) + end if + else + call external_request_gemini(request) end if - + + end subroutine handle_request diff --git a/captain/templates/index.gmi b/captain/templates/index.gmi index 0c260db..492d25d 100644 --- a/captain/templates/index.gmi +++ b/captain/templates/index.gmi @@ -3,6 +3,7 @@ The Levitating captain interface for the {{ project }} project. +=> /index.gmi Home => /releases.gmi Releases => /jobs.gmi Jobs => /players.gmi Players diff --git a/player/endpoints.f90 b/player/endpoints.f90 index 1a8ca73..8ec339d 100644 --- a/player/endpoints.f90 +++ b/player/endpoints.f90 @@ -1,10 +1,10 @@ module player_endpoints implicit none - character(*), parameter::LOCATION_CHECK_IN = "/player/{name}/checkin.json" - character(*), parameter::LOCATION_STATUS = "/player/{name}/job/{jobid}/task/{step}" - character(*), parameter::LOCATION_JOB_COMPLETE = "/player/{name}/job/{jobid}/complete" - character(*), parameter::LOCATION_JOB_FAILED = "/player/{name}/job/{jobid}/failed" + character(*), parameter::LOCATION_CHECK_IN = "/api/player/{name}/checkin.json" + character(*), parameter::LOCATION_STATUS = "/api/player/{name}/job/{jobid}/task/{step}" + character(*), parameter::LOCATION_JOB_COMPLETE = "/api/player/{name}/job/{jobid}/complete" + character(*), parameter::LOCATION_JOB_FAILED = "/api/player/{name}/job/{jobid}/failed" integer, parameter::STATUS_STARTING=1 integer, parameter::STATUS_COMPLETED=2 |