aboutsummaryrefslogtreecommitdiff
path: root/captain
diff options
context:
space:
mode:
Diffstat (limited to 'captain')
-rw-r--r--captain/requtils.f902
-rw-r--r--captain/response.f9050
-rw-r--r--captain/template.f902
-rw-r--r--captain/templates/index.html4
-rw-r--r--captain/web.f9013
5 files changed, 64 insertions, 7 deletions
diff --git a/captain/requtils.f90 b/captain/requtils.f90
index 01c4472..04ef6cf 100644
--- a/captain/requtils.f90
+++ b/captain/requtils.f90
@@ -134,7 +134,7 @@ contains
resp%temporary_file = .false.
call req%path_component(1, category)
- call req%path_component(2, filename)
+ call req%path_starting_with_component(2, filename)
resp%body_filename => get_special_full_filename(trim(category), trim(filename))
diff --git a/captain/response.f90 b/captain/response.f90
index 3982f1e..a4fe24e 100644
--- a/captain/response.f90
+++ b/captain/response.f90
@@ -70,6 +70,7 @@ implicit none
procedure :: last_component => request_last_component
procedure :: path_component => request_component
procedure :: path_component_int => request_component_int
+ procedure :: path_starting_with_component => request_component_starting_with
procedure :: component => request_component_func
end type request
@@ -169,6 +170,37 @@ contains
end subroutine request_init
+ function request_component_start_location(self, i_component) result(res)
+ implicit none
+
+ class(request) :: self
+ integer, intent(in)::i_component
+ integer::res
+
+ integer::i, j, i_last, n
+
+ res = -1
+
+ n = len_trim(self%location)
+
+ i_last = 0
+ j = 0
+ i = index(self%location, "/")
+ do while(i /= i_last .and. j < i_component)
+ j = j + 1
+
+ i_last = i
+ i = index(self%location(i_last+1:n), "/")
+ i = i_last + i
+ end do
+
+ ! Found
+ if(j == i_component) then
+ res = i_last + 1
+ end if
+
+ end function request_component_start_location
+
subroutine request_component(self, i_component, res)
use logging
implicit none
@@ -205,6 +237,24 @@ contains
end subroutine request_component
+ subroutine request_component_starting_with(self, i_component, res)
+ implicit none
+
+ class(request) :: self
+ integer, intent(in)::i_component
+ character(*), intent(out)::res
+
+ integer::string_index_component
+
+ string_index_component = request_component_start_location(self, i_component)
+
+ if(string_index_component > 0) then
+ res = self%location(string_index_component:len_trim(self%location))
+ else
+ res = " "
+ end if
+
+ end subroutine request_component_starting_with
function request_component_int(self, i) result(res)
implicit none
diff --git a/captain/template.f90 b/captain/template.f90
index 9ababb2..f3f6db1 100644
--- a/captain/template.f90
+++ b/captain/template.f90
@@ -281,6 +281,8 @@ contains
call self%variables(i)%assign(name, value)
+ call write_log(name//"=|||"//trim(value)//"|||", LOG_INFO)
+
end subroutine template_assign_string
subroutine template_assign_logical(self, name, value)
diff --git a/captain/templates/index.html b/captain/templates/index.html
index 1bbf8f4..6a41d0d 100644
--- a/captain/templates/index.html
+++ b/captain/templates/index.html
@@ -1,5 +1,7 @@
+<!DOCTYPE html>
<html>
<head>
+ <meta charset="utf-8"/>
<title>{{ title }} - I'm Levitating!</title>
<link rel="stylsheet" href="/static/style.css" />
</head>
@@ -22,7 +24,7 @@
<div class="content">
- {{ content }}
+ {{ contents }}
</div>
diff --git a/captain/web.f90 b/captain/web.f90
index ec91d88..e466c63 100644
--- a/captain/web.f90
+++ b/captain/web.f90
@@ -84,6 +84,9 @@ contains
if(.not. associated(req%query_string)) then
public_path = "/releases"
local_path = release_dir
+ else if(len_trim(req%query_string) == 0) then
+ public_path = "/releases"
+ local_path = release_dir
else
call combine_paths("/releases", req%query_string, public_path)
call combine_paths(release_dir, req%query_string, local_path)
@@ -115,9 +118,9 @@ contains
if(trim(public_path) /= "/releases") then
i = index(req%query_string, "/", back=.true.)
if(i > 0) then
- one_link = html_link("/releases.html?"//req%query_string(1:(i-1)), "Up a directory")
+ one_link => html_link("releases.html?"//req%query_string(1:(i-1)), "Up a directory")
else
- one_link = html_link("/releases.html", "Up a directory")
+ one_link => html_link("releases.html", "Up a directory")
end if
res = trim(res)//nl//"<li>"//one_link//"</li>"
deallocate(one_link)
@@ -133,7 +136,7 @@ contains
subpath = trim(directories(i))
end if
- one_link = html_link("/releases.html?"//trim(subpath), folder_icon//" "//trim(directories(i)))
+ one_link => html_link("releases.html?"//trim(subpath), folder_icon//" "//trim(directories(i)))
res = trim(res)//nl//"<li>"//one_link//"</li>"
deallocate(one_link)
@@ -146,8 +149,8 @@ contains
if(associated(files)) then
do i = 1, size(files)
- call combine_paths(public_path, trim(files(i)), subpath)
- one_link = html_link("/releases.html?"//trim(subpath), trim(files(i)))
+ call combine_paths(public_path(2:len_trim(public_path)), trim(files(i)), subpath)
+ one_link => html_link(trim(subpath), trim(files(i)))
res = trim(res)//nl//"<li>"//one_link//"</li>"
deallocate(one_link)
end do