Compare commits

...

39 Commits

Author SHA1 Message Date
Lionel Dricot 3155585c9e introducing openk 2023-08-04 19:09:48 +02:00
Lionel Dricot 2e02d06b0e we got rid of GeminiItem 2023-08-03 23:17:12 +02:00
Lionel Dricot ed019fa04e nearly got rid of geminiitem 2023-08-03 16:54:29 +02:00
Lionel Dricot 91e8b7aa16 geminiitem got rid of get_body 2023-07-31 19:01:57 +02:00
Lionel Dricot b3051efe72 working on get_body 2023-07-31 18:53:26 +02:00
Lionel Dricot 9609a8d91f moving out the self.url thing 2023-07-31 18:37:30 +02:00
Lionel Dricot 2034821325 debug XDG folders 2023-07-31 17:56:08 +02:00
Lionel Dricot a6fee03d2b next work : reimplementing list and local files 2023-07-31 13:19:28 +02:00
Lionel Dricot 7ba6bac5a4 works at Volvo 2023-07-31 09:34:12 +02:00
Lionel Dricot 26ed1769de get_link now in ansirenderer 2023-07-30 23:35:34 +02:00
Lionel Dricot 9ee95e7a1b pictures are working 2023-07-30 23:12:01 +02:00
Lionel Dricot 7786b91993 continuing work to remove GeminiItem 2023-07-30 16:59:32 +02:00
Lionel Dricot 3051f60253 more certificate management in netcache 2023-07-28 18:31:04 +02:00
Lionel Dricot dade6a3bda migrating certificate management to netcache 2023-07-28 18:08:45 +02:00
Lionel Dricot eed83a7a95 Cleaning up GeminiItem
Work has started to remove GeminiItem completely and switch to an
{url:renderer} dictionnary. Maybe also add a tmpfile.
2023-07-22 23:32:10 +02:00
Lionel Dricot 767ab82f29 Ok, it starts to work.
Offpunk is now able to display pages, pictures and follow links. A lot
of TODO have been clearly identified. I think that the whole
GeminiItem() object will be removed and URL will be accessed directly
with a dict{url, renderer} to avoid redrawing all the time.

Next challenge: remove GeminiItems!
2023-07-22 00:27:43 +02:00
Lionel Dricot 72ea43a59c debugging offpunk 2023-07-21 18:02:05 +02:00
Lionel Dricot d95d4dc5af offpunk starts to work 2023-07-21 17:33:55 +02:00
Lionel Dricot 1a3d839ab3 renderer in ansirenderer 2023-07-21 14:22:09 +02:00
Lionel Dricot 268e50a781 ansirenderer now working both directly or from stdin 2023-07-21 11:52:39 +02:00
Lionel Dricot cd3177ac87 pour le moment incapable de décider si ansirenderer doit prendre le path du fichier ou directement le texte en input 2023-07-21 01:03:40 +02:00
Lionel Dricot ce65850987 starting to adapt offpunk 2023-07-20 01:17:34 +02:00
Lionel Dricot c7734e3a92 default to stdin 2023-07-18 23:43:45 +02:00
Lionel Dricot 0b0fcc3e42 first working pipe between netcache and ansirenderer 2023-07-18 17:40:36 +02:00
Lionel Dricot 0cd988b055 ansirenderer cli 2023-07-18 12:33:30 +02:00
Lionel Dricot 965f8916c2 --offline and --path arguments 2023-07-18 12:16:08 +02:00
Lionel Dricot 4fd8b89f49 monkey patching 2023-07-18 00:45:14 +02:00
Lionel Dricot b745b04f7a netcache now works for gemini 2023-07-18 00:39:06 +02:00
Lionel Dricot a7c8ed33d5 work in progress 2023-07-09 11:35:58 +02:00
Lionel Dricot 6d43b13520 real work has started with porting Gemini code 2023-07-09 11:16:19 +02:00
Lionel Dricot 0a385d5334 gopher,finger and spartan in netcache 2023-07-09 10:56:40 +02:00
Lionel Dricot ef808afe1d netcache now downloads http 2023-07-08 00:43:56 +02:00
Lionel Dricot 3c760c914a netcache CLI 2023-07-07 23:45:52 +02:00
Lionel Dricot 76b00b8c04 working on netcache 2023-07-04 23:20:39 +02:00
Lionel Dricot a6974bb404 first netcache 2023-07-04 16:10:20 +02:00
Lionel Dricot 644e8ba08e to the point where netcache become an evidence 2023-07-04 13:59:16 +02:00
Lionel Dricot 927017d143 introducing offutils.py 2023-07-04 13:55:01 +02:00
Lionel Dricot ea36f45d94 progress toward independance 2023-07-03 23:48:55 +02:00
Lionel Dricot 86a67d47fa experiment 2023-07-03 11:43:06 +02:00
6 changed files with 2870 additions and 2764 deletions

View File

@ -1,5 +1,11 @@
# Offpunk History
## 2.0 - unreleased
This is an an experimental and unstable release. Lot of breakages are expected.
Wait for 2.1 if you are not willing to do testing/bug reporting.
- New command-line tool: "netcache"
- New command-line tool: "ansirenderer"
## 1.10 - unreleased
- IMPORTANT : new optional dependency : python-chardet
- IMPORTANT : Gopher directory index filename changed from "index.txt" to "gophermap". To update the cache to the new format run the `migrate-offpunk-cache` script (Sotiris Papatheodorou)

1388
ansirenderer.py Executable file

File diff suppressed because it is too large Load Diff

1064
netcache.py Executable file

File diff suppressed because it is too large Load Diff

3080
offpunk.py

File diff suppressed because it is too large Load Diff

57
offutils.py Normal file
View File

@ -0,0 +1,57 @@
#!/bin/python
#This file contains some utilities common to offpunk, ansirenderer and netcache.
#Currently, there are the following utilities:
#
# run : run a shell command and get the results with some security
# term_width : get or set the width to display on the terminal
import os
import io
import subprocess
import shutil
import shlex
# In terms of arguments, this can take an input file/string to be passed to
# stdin, a parameter to do (well-escaped) "%" replacement on the command, a
# flag requesting that the output go directly to the stdout, and a list of
# additional environment variables to set.
def run(cmd, *, input=None, parameter=None, direct_output=False, env={}):
#print("running %s"%cmd)
if parameter:
cmd = cmd % shlex.quote(parameter)
#following requires python 3.9 (but is more elegant/explicit):
# env = dict(os.environ) | env
e = os.environ
e.update(env)
if isinstance(input, io.IOBase):
stdin = input
input = None
else:
if input:
input = input.encode()
stdin = None
if not direct_output:
# subprocess.check_output() wouldn't allow us to pass stdin.
result = subprocess.run(cmd, check=True, env=e, input=input,
shell=True, stdin=stdin, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
return result.stdout.decode()
else:
subprocess.run(cmd, env=e, input=input, shell=True, stdin=stdin)
global TERM_WIDTH
TERM_WIDTH = 80
def term_width(new_width=None):
if new_width:
global TERM_WIDTH
TERM_WIDTH = new_width
width = TERM_WIDTH
cur = shutil.get_terminal_size()[0]
if cur < width:
width = cur
return width

39
opnk.py Normal file
View File

@ -0,0 +1,39 @@
#!/bin/python
#opnk stand for "Open like a PuNK".
#It will open any file or URL and display it nicely in less.
#If not possible, it will fallback to xdg-open
#URL are retrieved through netcache
import netcache
import offutils
class opencache():
def __init__(self):
self.temp_files = {}
self.rendererdic = {}
def opnk(inpath,terminal=True):
#if terminal = False, we dont try to open in the terminal,
#we immediately fallback to xdg-open.
#netcache currently provide the path if its a file.
#may this should be migrated here.
path = netcache.get_cache_path(inpath)
#TODO: migrate here ansirenderer display
1. À partir du path, tenter le ansirenderer
2. Sauver le rendu dans self.temp_files[mode] (donc le mode doit être passé à opnk)
3. Sauver le renderer dans self.rendererdic
3. Donner à less
4. sinon, donner à xdg-open
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("content",metavar="INPUT", nargs="*", type=argparse.FileType("r"),
default=sys.stdin, help="Path to the file or URL to open")
args = parser.parse_args()
cache = opencache()
for f in args.content:
cache.opnk(f)
if __name__ == "__main__":
main()