summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.tool-versions1
-rw-r--r--Pipfile15
-rw-r--r--Pipfile.lock242
-rwxr-xr-xbrowser.py9
-rw-r--r--gemini.py14
-rw-r--r--requirements.txt0
-rw-r--r--style.css29
8 files changed, 33 insertions, 278 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f7275bb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+venv/
diff --git a/.tool-versions b/.tool-versions
new file mode 100644
index 0000000..86f96f9
--- /dev/null
+++ b/.tool-versions
@@ -0,0 +1 @@
+python 3.9.6
diff --git a/Pipfile b/Pipfile
deleted file mode 100644
index c1178de..0000000
--- a/Pipfile
+++ /dev/null
@@ -1,15 +0,0 @@
-[[source]]
-name = "pypi"
-url = "https://pypi.org/simple"
-verify_ssl = true
-
-[dev-packages]
-pylint = "*"
-pytest = "*"
-mypy = "*"
-
-[packages]
-pyside2 = "*"
-
-[requires]
-python_version = "3.8"
diff --git a/Pipfile.lock b/Pipfile.lock
deleted file mode 100644
index 71b7109..0000000
--- a/Pipfile.lock
+++ /dev/null
@@ -1,242 +0,0 @@
-{
- "_meta": {
- "hash": {
- "sha256": "3218b2f6e241e522a76bfce33f6cea9b42fe7a8127340096e0a20effd637aa6f"
- },
- "pipfile-spec": 6,
- "requires": {
- "python_version": "3.8"
- },
- "sources": [
- {
- "name": "pypi",
- "url": "https://pypi.org/simple",
- "verify_ssl": true
- }
- ]
- },
- "default": {
- "pyside2": {
- "hashes": [
- "sha256:1478ea8a1ab5d8bc021ce41211933fbc238338fe70c02f7bcc2e80ea900dbf9e",
- "sha256:2d72150f63025b9b55097c1a64d09da37ff9191f73f69237500dec7a4a130541",
- "sha256:7ac86f31bc0a4fbf3f0bf00890e849441776be304c7b8bf259d777a7fe5fe913",
- "sha256:7c91a5074f3c60bac7e9336943a1dc9d5c8be8ab88a232dc55018e555dae81b2",
- "sha256:ae8158d611a410c58091aa8baf24005894b4e3f40c63ff2482149481ad5395b4",
- "sha256:de0220cc01a8bfdaa8ccd0fc934a1ead2aedca62b49b5fd4bdcdaba6f4585a03",
- "sha256:f9099e49fb2d3571f5a81eb9ff281ce832ce8c333052e8175e2356b9c3e4a882",
- "sha256:fad5ce781d0774bfad39f54b6c3376909b8d27f2075cbde6f4499df7dbd855f9"
- ],
- "index": "pypi",
- "version": "==5.15.0"
- },
- "shiboken2": {
- "hashes": [
- "sha256:0826ce788fe55bce19a8f8a2c33d720a6ba8f59e1aab1fa9d7a53eceed3f3af5",
- "sha256:19d5f715e5ae8a815a7f148a8614a3225dceee6fd9d5decaa7749657f0f7ccbe",
- "sha256:41a9157fb9cc7e0c0747926b25c23c3f94d59d61736a6ff763ebc7acf6afc5cf",
- "sha256:4b0904e0967356a36e80cde05981faa14c120141856d973ee983eac0b83633c0",
- "sha256:5702e77ad5999ac45498c3cd47f5d078ce7406cf8dc8df74337b0cdc084bf762",
- "sha256:94991848e9ff4d03c2d7feab484113b5b5ad7f9fdfa0b0ff46ce18da47b36b58",
- "sha256:a92c55363d5cd3cfdd6cd28dcf91e81a00a3aa5bb177d712817c09d26bd760db",
- "sha256:e753324a78cbdab1c5917b5600c708a8db7e1336579e7afa20ed90edda15eefa"
- ],
- "version": "==5.15.0"
- }
- },
- "develop": {
- "astroid": {
- "hashes": [
- "sha256:2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703",
- "sha256:bc58d83eb610252fd8de6363e39d4f1d0619c894b0ed24603b881c02e64c7386"
- ],
- "version": "==2.4.2"
- },
- "attrs": {
- "hashes": [
- "sha256:26b54ddbbb9ee1d34d5d3668dd37d6cf74990ab23c828c2888dccdceee395594",
- "sha256:fce7fc47dfc976152e82d53ff92fa0407700c21acd20886a13777a0d20e655dc"
- ],
- "version": "==20.2.0"
- },
- "iniconfig": {
- "hashes": [
- "sha256:80cf40c597eb564e86346103f609d74efce0f6b4d4f30ec8ce9e2c26411ba437",
- "sha256:e5f92f89355a67de0595932a6c6c02ab4afddc6fcdc0bfc5becd0d60884d3f69"
- ],
- "version": "==1.0.1"
- },
- "isort": {
- "hashes": [
- "sha256:92533892058de0306e51c88f22ece002a209dc8e80288aa3cec6d443060d584f",
- "sha256:a200d47b7ee8b7f7d0a9646650160c4a51b6a91a9413fd31b1da2c4de789f5d3"
- ],
- "version": "==5.5.1"
- },
- "lazy-object-proxy": {
- "hashes": [
- "sha256:0c4b206227a8097f05c4dbdd323c50edf81f15db3b8dc064d08c62d37e1a504d",
- "sha256:194d092e6f246b906e8f70884e620e459fc54db3259e60cf69a4d66c3fda3449",
- "sha256:1be7e4c9f96948003609aa6c974ae59830a6baecc5376c25c92d7d697e684c08",
- "sha256:4677f594e474c91da97f489fea5b7daa17b5517190899cf213697e48d3902f5a",
- "sha256:48dab84ebd4831077b150572aec802f303117c8cc5c871e182447281ebf3ac50",
- "sha256:5541cada25cd173702dbd99f8e22434105456314462326f06dba3e180f203dfd",
- "sha256:59f79fef100b09564bc2df42ea2d8d21a64fdcda64979c0fa3db7bdaabaf6239",
- "sha256:8d859b89baf8ef7f8bc6b00aa20316483d67f0b1cbf422f5b4dc56701c8f2ffb",
- "sha256:9254f4358b9b541e3441b007a0ea0764b9d056afdeafc1a5569eee1cc6c1b9ea",
- "sha256:9651375199045a358eb6741df3e02a651e0330be090b3bc79f6d0de31a80ec3e",
- "sha256:97bb5884f6f1cdce0099f86b907aa41c970c3c672ac8b9c8352789e103cf3156",
- "sha256:9b15f3f4c0f35727d3a0fba4b770b3c4ebbb1fa907dbcc046a1d2799f3edd142",
- "sha256:a2238e9d1bb71a56cd710611a1614d1194dc10a175c1e08d75e1a7bcc250d442",
- "sha256:a6ae12d08c0bf9909ce12385803a543bfe99b95fe01e752536a60af2b7797c62",
- "sha256:ca0a928a3ddbc5725be2dd1cf895ec0a254798915fb3a36af0964a0a4149e3db",
- "sha256:cb2c7c57005a6804ab66f106ceb8482da55f5314b7fcb06551db1edae4ad1531",
- "sha256:d74bb8693bf9cf75ac3b47a54d716bbb1a92648d5f781fc799347cfc95952383",
- "sha256:d945239a5639b3ff35b70a88c5f2f491913eb94871780ebfabb2568bd58afc5a",
- "sha256:eba7011090323c1dadf18b3b689845fd96a61ba0a1dfbd7f24b921398affc357",
- "sha256:efa1909120ce98bbb3777e8b6f92237f5d5c8ea6758efea36a473e1d38f7d3e4",
- "sha256:f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0"
- ],
- "version": "==1.4.3"
- },
- "mccabe": {
- "hashes": [
- "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
- "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
- ],
- "version": "==0.6.1"
- },
- "more-itertools": {
- "hashes": [
- "sha256:6f83822ae94818eae2612063a5101a7311e68ae8002005b5e05f03fd74a86a20",
- "sha256:9b30f12df9393f0d28af9210ff8efe48d10c94f73e5daf886f10c4b0b0b4f03c"
- ],
- "version": "==8.5.0"
- },
- "mypy": {
- "hashes": [
- "sha256:2c6cde8aa3426c1682d35190b59b71f661237d74b053822ea3d748e2c9578a7c",
- "sha256:3fdda71c067d3ddfb21da4b80e2686b71e9e5c72cca65fa216d207a358827f86",
- "sha256:5dd13ff1f2a97f94540fd37a49e5d255950ebcdf446fb597463a40d0df3fac8b",
- "sha256:6731603dfe0ce4352c555c6284c6db0dc935b685e9ce2e4cf220abe1e14386fd",
- "sha256:6bb93479caa6619d21d6e7160c552c1193f6952f0668cdda2f851156e85186fc",
- "sha256:81c7908b94239c4010e16642c9102bfc958ab14e36048fa77d0be3289dda76ea",
- "sha256:9c7a9a7ceb2871ba4bac1cf7217a7dd9ccd44c27c2950edbc6dc08530f32ad4e",
- "sha256:a4a2cbcfc4cbf45cd126f531dedda8485671545b43107ded25ce952aac6fb308",
- "sha256:b7fbfabdbcc78c4f6fc4712544b9b0d6bf171069c6e0e3cb82440dd10ced3406",
- "sha256:c05b9e4fb1d8a41d41dec8786c94f3b95d3c5f528298d769eb8e73d293abc48d",
- "sha256:d7df6eddb6054d21ca4d3c6249cae5578cb4602951fd2b6ee2f5510ffb098707",
- "sha256:e0b61738ab504e656d1fe4ff0c0601387a5489ca122d55390ade31f9ca0e252d",
- "sha256:eff7d4a85e9eea55afa34888dfeaccde99e7520b51f867ac28a48492c0b1130c",
- "sha256:f05644db6779387ccdb468cc47a44b4356fc2ffa9287135d05b70a98dc83b89a"
- ],
- "index": "pypi",
- "version": "==0.782"
- },
- "mypy-extensions": {
- "hashes": [
- "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d",
- "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"
- ],
- "version": "==0.4.3"
- },
- "packaging": {
- "hashes": [
- "sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8",
- "sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"
- ],
- "version": "==20.4"
- },
- "pluggy": {
- "hashes": [
- "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0",
- "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"
- ],
- "version": "==0.13.1"
- },
- "py": {
- "hashes": [
- "sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2",
- "sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342"
- ],
- "version": "==1.9.0"
- },
- "pylint": {
- "hashes": [
- "sha256:bb4a908c9dadbc3aac18860550e870f58e1a02c9f2c204fdf5693d73be061210",
- "sha256:bfe68f020f8a0fece830a22dd4d5dddb4ecc6137db04face4c3420a46a52239f"
- ],
- "index": "pypi",
- "version": "==2.6.0"
- },
- "pyparsing": {
- "hashes": [
- "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1",
- "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
- ],
- "version": "==2.4.7"
- },
- "pytest": {
- "hashes": [
- "sha256:85228d75db9f45e06e57ef9bf4429267f81ac7c0d742cc9ed63d09886a9fe6f4",
- "sha256:8b6007800c53fdacd5a5c192203f4e531eb2a1540ad9c752e052ec0f7143dbad"
- ],
- "index": "pypi",
- "version": "==6.0.1"
- },
- "six": {
- "hashes": [
- "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
- "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
- ],
- "version": "==1.15.0"
- },
- "toml": {
- "hashes": [
- "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f",
- "sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88"
- ],
- "version": "==0.10.1"
- },
- "typed-ast": {
- "hashes": [
- "sha256:0666aa36131496aed8f7be0410ff974562ab7eeac11ef351def9ea6fa28f6355",
- "sha256:0c2c07682d61a629b68433afb159376e24e5b2fd4641d35424e462169c0a7919",
- "sha256:249862707802d40f7f29f6e1aad8d84b5aa9e44552d2cc17384b209f091276aa",
- "sha256:24995c843eb0ad11a4527b026b4dde3da70e1f2d8806c99b7b4a7cf491612652",
- "sha256:269151951236b0f9a6f04015a9004084a5ab0d5f19b57de779f908621e7d8b75",
- "sha256:4083861b0aa07990b619bd7ddc365eb7fa4b817e99cf5f8d9cf21a42780f6e01",
- "sha256:498b0f36cc7054c1fead3d7fc59d2150f4d5c6c56ba7fb150c013fbc683a8d2d",
- "sha256:4e3e5da80ccbebfff202a67bf900d081906c358ccc3d5e3c8aea42fdfdfd51c1",
- "sha256:6daac9731f172c2a22ade6ed0c00197ee7cc1221aa84cfdf9c31defeb059a907",
- "sha256:715ff2f2df46121071622063fc7543d9b1fd19ebfc4f5c8895af64a77a8c852c",
- "sha256:73d785a950fc82dd2a25897d525d003f6378d1cb23ab305578394694202a58c3",
- "sha256:8c8aaad94455178e3187ab22c8b01a3837f8ee50e09cf31f1ba129eb293ec30b",
- "sha256:8ce678dbaf790dbdb3eba24056d5364fb45944f33553dd5869b7580cdbb83614",
- "sha256:aaee9905aee35ba5905cfb3c62f3e83b3bec7b39413f0a7f19be4e547ea01ebb",
- "sha256:bcd3b13b56ea479b3650b82cabd6b5343a625b0ced5429e4ccad28a8973f301b",
- "sha256:c9e348e02e4d2b4a8b2eedb48210430658df6951fa484e59de33ff773fbd4b41",
- "sha256:d205b1b46085271b4e15f670058ce182bd1199e56b317bf2ec004b6a44f911f6",
- "sha256:d43943ef777f9a1c42bf4e552ba23ac77a6351de620aa9acf64ad54933ad4d34",
- "sha256:d5d33e9e7af3b34a40dc05f498939f0ebf187f07c385fd58d591c533ad8562fe",
- "sha256:fc0fea399acb12edbf8a628ba8d2312f583bdbdb3335635db062fa98cf71fca4",
- "sha256:fe460b922ec15dd205595c9b5b99e2f056fd98ae8f9f56b888e7a17dc2b757e7"
- ],
- "version": "==1.4.1"
- },
- "typing-extensions": {
- "hashes": [
- "sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918",
- "sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c",
- "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f"
- ],
- "version": "==3.7.4.3"
- },
- "wrapt": {
- "hashes": [
- "sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
- ],
- "version": "==1.12.1"
- }
- }
-}
diff --git a/browser.py b/browser.py
index cda35de..e77b31d 100755
--- a/browser.py
+++ b/browser.py
@@ -2,7 +2,7 @@
import sys
-from PySide2 import QtCore, QtWidgets, QtGui
+from PySide6 import QtCore, QtWidgets, QtGui
import gemini
@@ -31,6 +31,7 @@ class GViewport(QtWidgets.QTextBrowser):
print(gem['body'])
if 'body' in gem:
html = gemini.gem2html(gem['body'])
+ print(html)
else:
html = '<h1>{} {}</h1>'.format(gem['status'], gem['meta'])
self.resourceLoadedStatus.emit(
@@ -61,7 +62,7 @@ class GUrlBar(QtWidgets.QLineEdit):
class GBrowser(QtWidgets.QMainWindow):
- def __init__(self):
+ def __init__(self, initial_url=None):
QtWidgets.QMainWindow.__init__(self)
## Create widgets
@@ -96,7 +97,7 @@ class GBrowser(QtWidgets.QMainWindow):
#
browser.document().setDefaultStyleSheet(open('style.css').read())
- browser.setSource(QtCore.QUrl('gemini://gemini.circumlunar.space/'))
+ browser.setSource(QtCore.QUrl(initial_url or 'gemini://gemini.circumlunar.space/'))
settings = QtCore.QSettings("xcolour.net", "GeminiBrowser")
self.restoreGeometry(settings.value("geometry"))
@@ -117,5 +118,5 @@ class GBrowser(QtWidgets.QMainWindow):
super().closeEvent(event)
app = QtWidgets.QApplication(sys.argv)
-ex = GBrowser()
+ex = GBrowser(sys.argv[1] if len(sys.argv) > 1 else None)
sys.exit(app.exec_())
diff --git a/gemini.py b/gemini.py
index c3ece46..560b01f 100644
--- a/gemini.py
+++ b/gemini.py
@@ -3,12 +3,15 @@ import socket
import ssl
import urllib.parse
+import pyphen
+dic = pyphen.Pyphen(lang='en_US')
+
def htmlescape(text: str) -> str:
return text.replace('<', '&lt;').replace('>', '&gt;')
def gem2html(gem: str) -> str:
html = []
- html.append('<html>\n<body>')
+ html.append('<html>\n<body>\n<div id="root">')
state = 'text'
blanklines = 0
for line in gem.split('\n'):
@@ -62,14 +65,15 @@ def gem2html(gem: str) -> str:
html.append(line)
else:
if line.startswith('###'):
- html.append('<h3>{}</h3>'.format(line[3:].lstrip()))
+ html.append('<p class="h3">{}</p>'.format(line[3:].lstrip()))
elif line.startswith('##'):
- html.append('<h2>{}</h2>'.format(line[2:].lstrip()))
+ html.append('<p class="h2">{}</p>'.format(line[2:].lstrip()))
elif line.startswith('#'):
- html.append('<h1>{}</h1>'.format(line[1:].lstrip()))
+ html.append('<p class="h1">{}</p>'.format(line[1:].lstrip()))
else:
+ ' '.join([dic.inserted(word, "\u00AD") for word in line.split()])
html.append('<p>{}</p>'.format(htmlescape(line)))
- html.append('</body>\n</html>')
+ html.append('</div>\n</body>\n</html>')
return '\n'.join(html)
def urljoin(base: str, url: str) -> str:
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/requirements.txt
diff --git a/style.css b/style.css
index f2d57ba..1189a93 100644
--- a/style.css
+++ b/style.css
@@ -1,26 +1,31 @@
-html { font: 100%/1.5 Arial, sans-serif; }
-h1 { font-size: 2em; /* 2*16 = 32 */ }
-h2 { font-size: 1.5em; /* 1.5*16 = 24 */ }
-h3 { font-size: 1.17em; /* 1.17*16 = 18.72 */ }
-h4 { font-size: 1em; /* 1*16 = 16 */ }
-h5 { font-size: 0.83em; /* 0.83*16 = 13.28 */ }
-h6 { font-size: 0.75em; /* 0.75*16 = 12 */ }
+#root {
+font-size: 20px;
+font-family: Garamond, Georgia, sans-serif;
+}
+p.h1 {
+font-size: 40px;
+}
+p.h2 {
+font-size: 30px;
+}
+p.h3{font-size: 23px; }
p {
line-height: 1.5;
- margin: 0 0 1em;
+ margin: 0 0 20px;
}
a:active { color: tomato; }
a:focus { border: 1px dotted tomato; }
-code,
-pre { font-family: monospace, serif;
-font-size: 1em; }
+pre {
+ font-family: Courier, monospace;
+ font-size: 10%;
+}
blockquote {
font-style: italic;
}
blockquote:before {
content: "\201C";
display: inline-block;
- padding-right: .4em;
+ padding-right: 8px;
}
/*