๐Ÿ A very simple static Gemini server, now with Titan support!
cpp gemini titan gemini-protocol titan-protocol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: can respond to unique indexes

Fuwn 942f4c5c 28891f6a

+22 -5
+22 -5
maple/maple.cc
··· 171 171 172 172 path = path.substr(0, path.size() - 2); // Remove "\r\n" 173 173 path.erase(0, 9); // Remove "gemini://" 174 - path = path.substr( 175 - path.find_first_of('/'), 176 - path.size() - 1 177 - ); // Remove host 174 + 175 + // Try to remove the host, if you cannot; it must be a trailing slash-less 176 + // hostname, so we will respond with the index. 177 + size_t found_first = path.find_first_of('/'); 178 + if (found_first != std::string::npos) { 179 + path = path.substr( 180 + found_first, 181 + path.size() - 1 182 + ); // Remove host 183 + } else { 184 + path = "/index.gmi"; 185 + } 178 186 179 187 // Remove junk, if any 180 188 index_of_junk = path.find_first_of('\n'); ··· 200 208 201 209 response << "20 text/gemini\r\n" << buffer.str(); 202 210 } else { 203 - response << "51 The server (Maple) could not find the specified file.\r\n"; 211 + if (path.empty() || path == "/") { 212 + std::ifstream file(".maple/gmi/index.gmi"); 213 + std::stringstream buffer; 214 + 215 + buffer << file.rdbuf(); 216 + 217 + response << "20 text/gemini\r\n" << buffer.str(); 218 + } else { 219 + response << "51 The server (Maple) could not find the specified file.\r\n"; 220 + } 204 221 } 205 222 206 223 std::cout << "requested " << path << std::endl;