diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-05-24 12:21:49 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-05-24 12:21:49 -0400 |
commit | ce036a72ca597a9dd3b19fb1f9871c01376a5361 (patch) | |
tree | afefa2fcac64ec2bc94fbc3e5cbd47e61024f30c /captain | |
parent | 816f5b4a3e344c3dc80bc7ddaa9b9979b49658d0 (diff) | |
download | levitating-ce036a72ca597a9dd3b19fb1f9871c01376a5361.tar.gz levitating-ce036a72ca597a9dd3b19fb1f9871c01376a5361.zip |
Added links on jobs pages to the instructions and player that were running the job.
Diffstat (limited to 'captain')
-rw-r--r-- | captain/external.f90 | 19 | ||||
-rw-r--r-- | captain/requtils.f90 | 129 | ||||
-rw-r--r-- | captain/web.f90 | 20 |
3 files changed, 159 insertions, 9 deletions
diff --git a/captain/external.f90 b/captain/external.f90 index e691dfb..2a0bc23 100644 --- a/captain/external.f90 +++ b/captain/external.f90 @@ -79,7 +79,8 @@ contains use captain_db use server_response use special_filenames, only: get_task_result_static_filename - use request_utils, only: get_status_utf8 + use request_utils, only: get_status_utf8, get_player_link => player_link, & + get_instruction_link => instruction_link implicit none type(request), intent(in)::req @@ -89,12 +90,12 @@ contains integer::i, j, job_id type(job)::one_job - character(PLAYER_NAME_LENGTH)::player character(1)::nl = new_line(' ') type(task), dimension(:), pointer::tasks character(32)::task_text, job_text character(len=:), pointer::task_results_filename + character(len=:), pointer::player_link, instruction_link res => null() @@ -111,8 +112,18 @@ contains status = get_status_utf8(one_job%status) res = "## Status - "//status - call get_player_name(one_job%player, player) - res = trim(res)//nl//nl//"Running on "//trim(player)//nl//"Last update at: "//one_job%time + player_link => get_player_link(one_job%player, .TRUE.) + + if(associated(player_link)) then + res = trim(res)//nl//nl//"Running on:"//nl//player_link//nl//"Last update at: "//one_job%time + deallocate(player_link) + end if + + instruction_link => get_instruction_link(one_job%instruction, .TRUE.) + if(associated(instruction_link)) then + res = trim(res)//nl//"Executing:"//nl//instruction_link + deallocate(instruction_link) + end if res = trim(res)//nl//nl//"### Task Results" diff --git a/captain/requtils.f90 b/captain/requtils.f90 index a6097d2..df365ff 100644 --- a/captain/requtils.f90 +++ b/captain/requtils.f90 @@ -23,6 +23,16 @@ module request_utils implicit none + interface player_link + module procedure player_link_from_name + module procedure player_link_from_id + end interface + + interface instruction_link + module procedure instruction_link_from_name + module procedure instruction_link_from_id + end interface + contains pure function success_code(req) @@ -232,6 +242,125 @@ contains end function build_link + function element_link_from_name(n, category, gemini_mode, prefix) result(res) + implicit none + + character(*), intent(in)::n, category + logical, intent(in)::gemini_mode + character(*), intent(in), optional::prefix + character(len=:), pointer::res + + character(256)::dest + + if(present(prefix)) then + dest = prefix + if(dest(len_trim(dest):len_trim(dest)) /= '/') then + dest = trim(dest)//"/" + end if + else + dest = "/" + end if + + dest = trim(dest)//trim(category)//"/"//trim(n) + + if(gemini_mode) then + dest = trim(dest)//".gmi" + else + dest = trim(dest)//".html" + end if + + res => build_link(trim(dest), trim(n), gemini_mode) + + end function element_link_from_name + + function player_link_from_name(n, gemini_mode, prefix) result(res) + implicit none + + character(*), intent(in)::n + logical, intent(in)::gemini_mode + character(*), intent(in), optional::prefix + + character(64)::internal_prefix + character(len=:), pointer::res + + if(present(prefix)) then + internal_prefix = prefix + else + internal_prefix = "/" + end if + + res => element_link_from_name(n, "players", gemini_mode, internal_prefix) + + end function player_link_from_name + + function player_link_from_id(id, gemini_mode, prefix) result(res) + use captain_db, only: PLAYER_NAME_LENGTH, get_player_name + implicit none + + integer, intent(in)::id + logical, intent(in)::gemini_mode + character(*), intent(in), optional::prefix + character(len=:), pointer::res + + character(64)::internal_prefix + character(PLAYER_NAME_LENGTH)::name + + if(present(prefix)) then + internal_prefix = prefix + else + internal_prefix = "/" + end if + + name = " " + call get_player_name(id, name) + res => player_link_from_name(name, gemini_mode, internal_prefix) + + end function player_link_from_id + + function instruction_link_from_name(n, gemini_mode, prefix) result(res) + implicit none + + character(*), intent(in)::n + logical, intent(in)::gemini_mode + character(*), intent(in), optional::prefix + + character(64)::internal_prefix + character(len=:), pointer::res + + if(present(prefix)) then + internal_prefix = prefix + else + internal_prefix = "/" + end if + + res => element_link_from_name(n, "instructions", gemini_mode, internal_prefix) + + end function instruction_link_from_name + + function instruction_link_from_id(id, gemini_mode, prefix) result(res) + use captain_db, only: PLAYER_NAME_LENGTH, get_instruction_name + implicit none + + integer, intent(in)::id + logical, intent(in)::gemini_mode + character(*), intent(in), optional::prefix + character(len=:), pointer::res + + character(64)::internal_prefix + character(PLAYER_NAME_LENGTH)::name + + if(present(prefix)) then + internal_prefix = prefix + else + internal_prefix = "/" + end if + + name = " " + call get_instruction_name(id, name) + res => instruction_link_from_name(name, gemini_mode, internal_prefix) + + end function instruction_link_from_id + function generate_simple_pager(startindex, stopindex, step, maxcount, page, gemini_mode) result(res) use logging implicit none diff --git a/captain/web.f90 b/captain/web.f90 index 1b9bb8f..ccd3df0 100644 --- a/captain/web.f90 +++ b/captain/web.f90 @@ -342,7 +342,8 @@ contains use captain_db use server_response use special_filenames, only: get_task_result_static_filename - use request_utils, only: get_status_utf8 + use request_utils, only: get_status_utf8, get_player_link => player_link, & + get_instruction_link => instruction_link implicit none type(request), intent(in)::req @@ -352,12 +353,12 @@ contains integer::i, j, job_id type(job)::one_job - character(PLAYER_NAME_LENGTH)::player character(1)::nl = new_line(' ') type(task), dimension(:), pointer::tasks character(32)::task_text, job_text character(len=:), pointer::task_results_filename, one_link, local_task_results_filename + character(len=:), pointer::player_link, instruction_link logical::file_exists @@ -376,9 +377,18 @@ contains status = get_status_utf8(one_job%status) res = "<h2>Status - "//status//"</h2>" - call get_player_name(one_job%player, player) - res = trim(res)//nl//nl//"<p><em>Running on "//trim(player)//nl// & - "Last update at: "//one_job%time//"</em></p>" + player_link => get_player_link(one_job%player, .FALSE., prefix="..") + if(associated(player_link)) then + res = trim(res)//nl//nl//"<p><em>Running on "//player_link//nl// & + "Last update at: "//one_job%time//"</em></p>" + deallocate(player_link) + end if + + instruction_link => get_instruction_link(one_job%instruction, .FALSE., prefix="..") + if(associated(instruction_link)) then + res = trim(res)//nl//"<p><em>Executing: "//instruction_link//"</em></p>" + deallocate(instruction_link) + end if res = trim(res)//nl//nl//"<h3>Task Results</h3>" |