1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
! Copyright (c) 2020 Jeffrey Armstrong <jeff@rainbow-100.com>
!
! Permission is hereby granted, free of charge, to any person obtaining a copy
! of this software and associated documentation files (the "Software"), to deal
! in the Software without restriction, including without limitation the rights
! to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
! copies of the Software, and to permit persons to whom the Software is
! furnished to do so, subject to the following conditions:
!
! The above copyright notice and this permission notice shall be included in
! all copies or substantial portions of the Software.
!
! The Software shall be used for Good, not Evil.
!
! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
! SOFTWARE.
module internal_links
implicit none
private
public::internal_url, handle_internal_url
character(*), parameter::internal_url = "lr87://"
contains
function handle_internal_url(url, unit_number, faves)
use favorite_handling
implicit none
character(*), intent(in)::url
integer, intent(in)::unit_number
type(favorite), dimension(:), pointer, intent(inout)::faves
logical::handle_internal_url
character(80)::requested_operation
handle_internal_url = .false.
requested_operation = url(len(internal_url)+1:len_trim(url))
if(trim(requested_operation) == "menu") then
call handle_menu(unit_number)
handle_internal_url = .true.
else if(trim(requested_operation) == "about") then
call handle_about(unit_number)
handle_internal_url = .true.
else if(index(requested_operation, "favorites") == 1) then
call handle_favorites(unit_number, trim(requested_operation), faves)
handle_internal_url = .true.
#ifdef WINDOWS
else if(index(requested_operation, "home") == 1) then
call handle_home(unit_number)
handle_internal_url = .true.
#endif
end if
end function handle_internal_url
subroutine write_no_space(unit_number, string)
implicit none
character(*), intent(in)::string
integer, intent(in)::unit_number
character(10)::f
integer::string_length
string_length = len_trim(string)
if(string_length < 10) then
write(f, "(A2,I1,A1)") '(A', string_length,')'
else if(string_length < 100) then
write(f, "(A2,I2,A1)") '(A', string_length,')'
else
write(f, "(A2,I3,A1)") '(A', string_length,')'
end if
write(unit_number, f) string
end subroutine write_no_space
subroutine write_nonsense_status(unit_number)
implicit none
integer, intent(in)::unit_number
rewind(unit_number)
write(unit_number, '(I2, 1X, A11)') 20, "text/gemini"
write(unit_number, *)
end subroutine write_nonsense_status
subroutine write_header(unit_number, title)
implicit none
character(*), intent(in)::title
integer, intent(in)::unit_number
call write_nonsense_status(unit_number)
call write_no_space(unit_number, "# "//trim(title))
#ifdef WINDOWS
write(unit_number, *)
call write_no_space(unit_number, "=> lr87://home Start Page")
#endif
write(unit_number, *)
call write_no_space(unit_number, "=> lr87://favorites/date/newest Favorites Sorted by Date (Newest First)")
call write_no_space(unit_number, "=> lr87://favorites/date/oldest Favorites Sorted by Date (Oldest First)")
call write_no_space(unit_number, "=> lr87://favorites/alpha/ascending Favorites Sorted Alphabetically Ascending")
call write_no_space(unit_number, "=> lr87://favorites/alpha/descending Favorites Sorted Alphabetically Descending")
write(unit_number, *)
call write_no_space(unit_number, "=> lr87://about About LR-87")
write(unit_number, *)
end subroutine write_header
subroutine handle_menu(unit_number)
implicit none
integer, intent(in)::unit_number
call write_header(unit_number, "Main Menu")
end subroutine handle_menu
subroutine handle_about(unit_number)
use file_handling, only: end_indicator
implicit none
integer, intent(in)::unit_number
call write_header(unit_number, "About")
call write_no_space(unit_number, "## LR-87 - A Gemini Browser Written in Fortran")
call write_no_space(unit_number, "Copyright 2020, 2021 Jeffrey Armstrong")
call write_no_space(unit_number, "=> http://git.rainbow-100.com/cgit.cgi/LR-87/about/ LR-87 Web Home Page")
call write_no_space(unit_number, "=> gemini://rainbow-100.com/software/lr87.gmi LR-87 Gemini Home Page")
write(unit_number, *)
call write_no_space(unit_number, "LR-87 uses the following technologies:")
write(unit_number, *)
call write_no_space(unit_number, "* OpenSSL from The OpenSSL Project")
call write_no_space(unit_number, "* AppGraphics from Approximatrix, LLC on Windows")
write(unit_number, *)
call write_no_space(unit_number, "### License")
call write_no_space(unit_number, "Permission is hereby granted, free of charge, to any "//&
"person obtaining a copy of this software and associated "//&
'documentation files (the "Software"), to deal in the '//&
"Software without restriction, including without limitation "//&
"the rights to use, copy, modify, merge, publish, distribute, "//&
"sublicense, and/or sell copies of the Software, and to "//&
"permit persons to whom the Software is furnished to do so, "//&
"subject to the following conditions:")
write(unit_number, *)
call write_no_space(unit_number, "The above copyright notice and this permission notice shall "//&
"be included in all copies or substantial portions of the Software.")
write(unit_number, *)
call write_no_space(unit_number, "The Software shall be used for Good, not Evil.")
write(unit_number, *)
call write_no_space(unit_number, 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, '//&
"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES "//&
"OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND "//&
"NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT "//&
"HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, "//&
"WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING "//&
"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR "//&
"OTHER DEALINGS IN THE SOFTWARE. ")
write(unit_number, *)
call write_no_space(unit_number, end_indicator)
end subroutine handle_about
subroutine handle_favorites(unit_number, op, faves)
use favorite_handling
use file_handling, only: end_indicator
implicit none
character(*), intent(in)::op
integer, intent(in)::unit_number
type(favorite), dimension(:), pointer, intent(inout)::faves
call write_header(unit_number, "Favorites")
if(.not. associated(faves)) then
call write_no_space(unit_number, "You currently have no favorites saved.")
! Alpha sort
else
if(index(op, "alpha") > 1) then
call sort_alpha(faves, index(op, "descending") > 1)
! Date sort
else
call sort_added(faves, index(op, "latest") > 1)
end if
call write_favorites(unit_number, faves, skip_heading=.true.)
end if
call write_no_space(unit_number, end_indicator)
end subroutine handle_favorites
subroutine handle_home(unit_number)
implicit none
integer, intent(in)::unit_number
call write_nonsense_status(unit_number)
call write_no_space(unit_number, "# A Gemini Browser Written in Simply Fortran")
write(unit_number, *)
call write_no_space(unit_number, "LR-87 is a browser for the Gemini protocol, which is similar to the World Wide "// &
"Web, only smaller and simpler. This browser implements the much of the Gemini "// &
"protocol, including browsing and user input. On Microsoft Windows, the LR-87 "// &
"browser uses Simply Fortran's AppGraphics package for all rendering.")
write(unit_number, *)
call write_no_space(unit_number, "Simply Fortran is a full-featured integrated development environment for the "// &
"Fortran programming language. It includes a complete, pre-configured Fortran " // &
"compiler and tool suite in addition to the development environment, meaning there "// &
"is nothing else for the user to configure and install. Included with the package "// &
"is the AppGraphics library, which enables the creation of full-featured graphical "// &
"user interfaces written entirely in Fortran. If you'd like to learn more about "// &
"Simply Fortran, click the link below (which will open a web browser):")
write(unit_number, *)
call write_no_space(unit_number, "=> https://simplyfortran.com/?platform=windows Simply Fortran Home Page")
write(unit_number, *)
call write_no_space(unit_number, "## Sites to See in Gemini Space")
write(unit_number, *)
call write_no_space(unit_number, "=> gemini://medusae.space/ medusae.space Directory - "//&
"a categorized directory of Gemini sites")
call write_no_space(unit_number, "=> gemini://geminispace.info/ Gemini Search Engine - search all sites in Gemini")
call write_no_space(unit_number, "=> gemini://rawtext.club:1965/~sloum/spacewalk.gmi Spacewalk - "// &
"a list of recently updated Gemini sites")
call write_no_space(unit_number, "=> gemini://rainbow-100.com/software/lr87.gmi LR-87 Site - "// &
"the primary home of the LR-87 browser")
call write_no_space(unit_number, "=> gemini://gemini.circumlunar.space/ More About the Gemini Protocol")
call write_no_space(unit_number, "=> lr87://about More About the LR-87 Gemini browser")
end subroutine handle_home
end module internal_links
|