RemiGemini
RemiGemini is an extremely small and lightweight library for interfacing with the Gemini Protocol using the Crystal programming language. It includes classes that aid in the implementation of clients and servers.
Wanna support Remilia? Buy me a coffee on Ko-Fi, or support me through Liberapay.
How do I get set up?
You will need Fossil installed to clone this repo. You will also need Shards v0.17.1 or later. If you have an earlier version of Shards, you will need to to build the latest version manually.
Once you have these requirements, add this to your shard.yml
:
dependencies:
remigemini:
fossil: https://chiselapp.com/user/MistressRemilia/repository/remigemini
Usage
Both of these examples are included in the root of the repository. Example client:
require "./src/remigemini"
RemiGemini::Client.get(ARGV[0], noVerify: true) do |resp|
puts "Response Status: #{resp.status}"
puts "Response message: #{resp.meta}"
puts resp.body
end
Example server:
require "./src/remigemini"
if ARGV.size != 2
abort("Usage: #{File.basename(PROGRAM_NAME)} <tls key> <tls cert>")
end
server = RemiGemini::Server.new do |request|
if request.uri.path == "" || request.uri.path == "/"
resp = RemiGemini::Client::Response.new("Hello, world!")
resp.to_io(request.sock)
else
resp = RemiGemini::Client::Response.new(RemiGemini::StatusCode::NotFound, "Nothing yet :(")
resp.to_io(request.sock)
end
end
address = server.bind("localhost", ARGV[0], ARGV[1], port: 8069)
puts "Listening on gemini://#{address}"
server.listen
Development
Style info
I use a somewhat non-standard style for my code.
- Keep lines 118 characters or shorter. Obviously sometimes you can't, but please try. Use 80 or 115 characters for Markdown files, though.
- Please use pascalCase for variable and method names. Use CamelCase for type names. Use UPPER_SNAKE_CASE for constants.
- Put parentheses around method parameters, except for these methods:
puts
,pp
,p
,raise
,sleep
,spawn
,loop
, andexit
. - Always the full
do |foo|...end
syntax with blocks, except when it's all on one line or an anonymous function, then use { and } or the normaldo |foo|...end
. - The type name for exceptions end with Error. For example,
ExternalProgramError
.
How do I contribute?
- Go to https://chiselapp.com/user/MistressRemilia/repository/remigemini and clone the Fossil repository.
- Create a new branch for your feature.
- Push locally to the new branch.
- Create a bundle with Fossil that contains your changes.
- Get in contact with me.
Contributors
- Remilia Scarlet - creator and maintainer
- Homepage: https://remilia.sdf.org/
- Gemini: gemini://nanako.mooo.com/
- Fediverse: @remilia@nanako-さめ.mooo.com
- Email: zremiliaz@postzeoz.jpz My real address does not contain Z's
Links and Licenses
RemiGemini is under the GNU Affero General Public License version 3.