aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--captain/config.f9019
-rw-r--r--captain/external.f9016
-rw-r--r--captain/template.f9075
-rw-r--r--captain/templates/index.gmi18
4 files changed, 125 insertions, 3 deletions
diff --git a/captain/config.f90 b/captain/config.f90
new file mode 100644
index 0000000..9daee6b
--- /dev/null
+++ b/captain/config.f90
@@ -0,0 +1,19 @@
+module config
+implicit none
+
+ character(1024)::template_directory
+ character(1024)::database_filename
+ character(1024)::description_filename
+
+contains
+
+ subroutine load_configuration(filename)
+ implicit none
+
+ character(*), intent(in)::filename
+
+
+
+ end subroutine load_configuration
+
+end module config
diff --git a/captain/external.f90 b/captain/external.f90
new file mode 100644
index 0000000..56a7317
--- /dev/null
+++ b/captain/external.f90
@@ -0,0 +1,16 @@
+module external_handling
+implicit none
+
+
+contains
+
+ subroutine external_request_gemini(request)
+ implicit none
+
+ character(*), intent(in)::request
+
+
+
+ end subroutine external_request_gemini
+
+end module external_handling \ No newline at end of file
diff --git a/captain/template.f90 b/captain/template.f90
index 3e1f2bc..9543c42 100644
--- a/captain/template.f90
+++ b/captain/template.f90
@@ -38,6 +38,7 @@ implicit none
procedure :: assign_string => template_assign_string
procedure :: render_unit => template_render_unit
procedure :: render_filename => template_render_filename
+ procedure :: evaluate => template_evaluate
generic :: render => render_unit, render_filename
generic :: assign => assign_integer, assign_string
@@ -248,15 +249,83 @@ contains
class(template)::self
integer, intent(in)::unum
- integer::input
-
- open(newunit=input, file=self%base_filename, status="old", form="formatted", action="read")
+ character::this_char, last_char
+ character(256)::brace_internals
+ character(len=:), pointer::replacement
+ integer::input, istat, i
+ open(newunit=input, file=self%base_filename, status="old", form="formatted", action="read")
+ last_char = ' '
+ read(input, '(A1)', iostat=istat) this_char
+ do while(istat == 0)
+ if(this_char /= '{') then
+ if(last_char == '{') then
+ write(unum, '(A1)', advance='no') last_char
+ end if
+ write(unum, '(A1)', advance='no') this_char
+
+ ! Two curly braces
+ else if(last_char == '{') then
+
+ brace_internals = ' '
+
+ read(input, '(A1)', iostat=istat) this_char
+ i = 1
+ do while(istat == 0 .and. .not. (this_char == '}' .and. last_char == '}'))
+ brace_internals(i:i) = this_char
+
+ i = i + 1
+ last_char = this_char
+ read(input, '(A1)', iostat=istat) this_char
+ end do
+ brace_internals(i:i) = ' ' ! Remove trailing bracket
+ brace_internals = adjustl(brace_internals)
+
+ replacement => self%evaluate(brace_internals)
+
+ if(associated(replacement)) then
+ do i=1, len_trim(replacement)
+ write(unum, '(A1)', advance='no') replacement(i:i)
+ end do
+ replacement => null() ! do not free - internal strings
+ end if
+
+ end if
+
+ last_char = this_char
+ read(input, '(A1)', iostat=istat) this_char
+ end do
close(input)
end subroutine template_render_unit
+ function template_evaluate(self, txt) result(res)
+ implicit none
+
+ class(template)::self
+ character(*), intent(in)::txt
+ character(:), pointer::res
+
+ integer::i
+
+ res => null()
+
+ ! Right now, we only support straight-up variables
+ do i = 1, size(self%variables)
+ if(self%variables(i)%vtype == VTYPE_NONE) then
+ exit
+ end if
+
+ if(self%variables(i)%vname == trim(txt) .and. associated(self%variables(i)%vstr)) then
+ res => self%variables(i)%vstr
+ exit
+ end if
+
+ end do
+
+ end function template_evaluate
+
end module page_template \ No newline at end of file
diff --git a/captain/templates/index.gmi b/captain/templates/index.gmi
new file mode 100644
index 0000000..0c260db
--- /dev/null
+++ b/captain/templates/index.gmi
@@ -0,0 +1,18 @@
+
+# {{ title }} - We're Levitating!
+
+The Levitating captain interface for the {{ project }} project.
+
+=> /releases.gmi Releases
+=> /jobs.gmi Jobs
+=> /players.gmi Players
+=> /about.gmi About
+
+{{ content }}
+
+
+```
+-------------------------------------------------------------------------------
+```
+
+Copyright 2021 Approximatrix, LLC