aboutsummaryrefslogtreecommitdiff
path: root/player
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-04-12 10:32:39 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-04-12 10:32:39 -0400
commitfca71fde0161a59ac650bd690a3413ffd866662d (patch)
tree72b1e6040f0b2401c358d54e1bdec9f0724a7d41 /player
parent025b5d1dcbb30e727afee3307d49328432bae603 (diff)
downloadlevitating-fca71fde0161a59ac650bd690a3413ffd866662d.tar.gz
levitating-fca71fde0161a59ac650bd690a3413ffd866662d.zip
URLs in instructions can now leave out the server implying download and upload from the server itself. Download and upload both work correctly.
Diffstat (limited to 'player')
-rw-r--r--player/levitating-player.prj4
-rw-r--r--player/tasks.f9040
2 files changed, 33 insertions, 11 deletions
diff --git a/player/levitating-player.prj b/player/levitating-player.prj
index 3817ee4..fef15ef 100644
--- a/player/levitating-player.prj
+++ b/player/levitating-player.prj
@@ -32,9 +32,7 @@
"enabled":"1"
},{
"filename":"instructions.f90",
- "enabled":"1",
- "panel":1,
- "open":"1"
+ "enabled":"1"
},{
"filename":"player.F90",
"enabled":"1"
diff --git a/player/tasks.f90 b/player/tasks.f90
index c64cb40..87b7d66 100644
--- a/player/tasks.f90
+++ b/player/tasks.f90
@@ -70,7 +70,7 @@ contains
end function shell
function upload(url, source_filename)
- use config, only: token
+ use config, only: token, captain
use gemini_protocol, only: titan_post_url, STATUS_SUCCESS
implicit none
@@ -81,15 +81,26 @@ contains
character(len=:), allocatable::mod_url
integer(kind=8)::file_size
- integer::unit_number, istatus
+ integer::unit_number, istatus, url_length
inquire(file=source_filename, size=file_size)
open(newunit=unit_number, file=trim(source_filename), status='UNKNOWN', &
access='STREAM', form='UNFORMATTED', iostat=istatus)
-
- allocate(character(len=len_trim(url)) :: mod_url)
- mod_url = url
+
+ if(index(url, "://") > 0) then
+ allocate(character(len=len_trim(url)) :: mod_url)
+ mod_url = url
+ else
+ url_length = len_trim(url) + len_trim(captain) + 16
+ allocate(character(len=url_length) :: mod_url)
+ mod_url = "titan://"//trim(captain)
+ if(url(1:1) == "/") then
+ mod_url = trim(mod_url)//trim(url)
+ else
+ mod_url = trim(mod_url)//"/"//trim(url)
+ end if
+ end if
if(istatus == 0) then
istatus = titan_post_url(mod_url, unit_number, file_size, token)
@@ -105,6 +116,7 @@ contains
function download(url, destination_filename)
use gemini_protocol, only: request_url, STATUS_SUCCESS
+ use config, only: captain
implicit none
logical::download
@@ -114,14 +126,26 @@ contains
character(len=256)::mimetype
character(len=:), allocatable::mod_url
+ integer::url_length
integer::unit_number, istatus
- allocate(character(len=len_trim(url)) :: mod_url)
- mod_url = url
+ if(index(url, "://") > 0) then
+ allocate(character(len=len_trim(url)) :: mod_url)
+ mod_url = url
+ else
+ url_length = len_trim(url) + len_trim(captain) + 16
+ allocate(character(len=url_length) :: mod_url)
+ mod_url = "gemini://"//trim(captain)
+ if(url(1:1) == "/") then
+ mod_url = trim(mod_url)//trim(url)
+ else
+ mod_url = trim(mod_url)//"/"//trim(url)
+ end if
+ end if
open(newunit=unit_number, file=trim(destination_filename), status='UNKNOWN', &
- access='STREAM', form='UNFORMATTED', iostat=istatus)
+ access='STREAM', form='FORMATTED', iostat=istatus)
if(istatus == 0) then
istatus = request_url(mod_url, unit_number, mimetype)