Skip to content

Commit

Permalink
Bugfix in URL handling in browser.py, new hashmarks, ..
Browse files Browse the repository at this point in the history
* A bug was fixed in the URL handling when content is coming
from the HTTP gateway, this fixes accessing URLs with fragments
* Bugfix in the IPFSOperator.isPinned coroutine
* Added a quickaccess toolbar
* New hashmarks for some IPFS apps
* Added direct integration with the IPLD explorer /ipns/explore.ipld.io
(from the clipboard menu or just hit Ctrl+I)

revbump to 0.3.0
  • Loading branch information
cipres authored and cipres committed Dec 2, 2018
1 parent f0b4c36 commit db8419c
Show file tree
Hide file tree
Showing 33 changed files with 703 additions and 381 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Main window keybindings:
- **Ctrl+o**: Browse IPFS path from the clipboard
- **Ctrl+e**: Explore IPFS path from the clipboard
- **Ctrl+g**: DAG view of IPFS object from the clipboard
- **Ctrl+i**: Open the IPLD explorer for the IPFS object referenced in the
clipboard

Browser keybindings:
--------------------
Expand Down
2 changes: 1 addition & 1 deletion galacteek/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# ..............................................................................
#

__version__ = '0.2.9'
__version__ = '0.3.0'

from galacteek.core.asynclib import *
from galacteek.core import glogger
Expand Down
2 changes: 1 addition & 1 deletion galacteek/appsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def setDefaultSettings(gApp):
sManager.setDefaultSetting(section, CFG_KEY_DLPATH,
gApp.defaultDownloadsLocation)
sManager.setDefaultTrue(section, CFG_KEY_GOTOHOME)
sManager.setDefaultFalse(section, CFG_KEY_JSAPI)
sManager.setDefaultTrue(section, CFG_KEY_JSAPI)
sManager.setDefaultFalse(section, CFG_KEY_ALLOWHTTPBROWSING)
sManager.setDefaultTrue(section, CFG_KEY_PPAPIPLUGINS)

Expand Down
65 changes: 62 additions & 3 deletions galacteek/core/ipfsmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import collections
import copy
import re
from datetime import datetime

from async_generator import async_generator, yield_, yield_from_
Expand Down Expand Up @@ -46,7 +47,7 @@ def fromJson(data):
@staticmethod
def make(path, title=None, datecreated=None, share=False, tags=[],
description='', comment='', datasize=None, cumulativesize=None,
numlinks=None):
numlinks=None, icon=None):
if datecreated is None:
datecreated = datetime.now().isoformat()

Expand All @@ -64,6 +65,7 @@ def make(path, title=None, datecreated=None, share=False, tags=[],
'datecreated': datecreated,
'tscreated': int(time.time()),
'comment': comment,
'icon': icon,
'share': share,
'tags': tags,
}
Expand Down Expand Up @@ -223,7 +225,46 @@ def getAll(self, share=False):
_all[mpath] = mark
return _all

def search(self, bpath, category=None, tags=[], delete=False):
def searchByMetadata(self, metadata):
if not isinstance(metadata, dict):
raise ValueError('Metadata needs to be a dictionary')

categories = self.getCategories()

title = metadata.get('title', None)
descr = metadata.get('description', None)

def metaMatch(mark, field, regexp):
try:
if mark['metadata'][field] and re.search(
regexp, mark['metadata'][field]):
return True
except:
return False

for cat in categories:
marks = self.getCategoryMarks(cat)
if not marks:
continue

for mPath, mark in marks.items():
if 'metadata' not in mark:
continue
if title and metaMatch(mark, 'title', title):
return mPath, mark

if descr and metaMatch(mark, 'description', descr):
return mPath, mark

return None, None

def search(
self,
bpath,
metadata=None,
category=None,
tags=[],
delete=False):
path = rSlash(bpath)
categories = self.getCategories()

Expand All @@ -235,6 +276,12 @@ def search(self, bpath, category=None, tags=[], delete=False):
if not marks:
continue

if isinstance(metadata, dict):
title = metadata.get('title', None)
for mPath, mark in marks.items():
if title and re.search(title, mark['metadata']['title']):
return mPath, mark

if path in marks.keys():
if delete is True:
del marks[path]
Expand All @@ -261,13 +308,21 @@ def insertMark(self, mark, category):
# Handle IPFSHashMark or tuple
if isinstance(mark, IPFSHashMark):
if mark.path in sec[marksKey]:
eMark = sec[marksKey][mark.path]

if 'icon' in mark.markData:
eMark['icon'] = mark.markData['icon']
return False
sec[marksKey].update(mark)
self.markAdded.emit(mark.path, mark.markData)
else:
try:
mPath, mData = mark
if mPath in sec[marksKey]:
# Patch some fields if already exists
eMark = sec[marksKey][mPath]
if 'icon' in mData:
eMark['icon'] = mData['icon']
return False
sec[marksKey][mPath] = mData
self.markAdded.emit(mPath, mData)
Expand All @@ -277,7 +332,8 @@ def insertMark(self, mark, category):
self.changed.emit()
return True

def add(self, bpath, title=None, category='general', share=False, tags=[]):
def add(self, bpath, title=None, category='general', share=False, tags=[],
description=None, icon=None):
if not bpath:
return None

Expand All @@ -297,6 +353,8 @@ def add(self, bpath, title=None, category='general', share=False, tags=[]):
datecreated=datetime.now().isoformat(),
share=share,
tags=tags,
description=description,
icon=icon
)

sec[marksKey].update(mark)
Expand All @@ -313,6 +371,7 @@ def merge(self, oMarks):
marks = oMarks.getCategoryMarks(cat)
for mark in marks.items():
self.insertMark(mark, cat)
self.changed.emit()

def follow(self, ipnsp, name, active=True, maxentries=4096,
resolveevery=3600, share=False, autoPin=False):
Expand Down
2 changes: 2 additions & 0 deletions galacteek/docs/manual/en/clipboard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ Clipboard keyboard shortcuts
referenced in the clipboard
- **Ctrl+g** will open the DAG viewer for the IPFS resource currently
referenced in the clipboard
- **Ctrl+i** will open the IPLD Explorer for the IPFS resource currently
referenced in the clipboard
Binary file modified galacteek/docs/manual/en/html/_images/add-file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified galacteek/docs/manual/en/html/_images/add-folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified galacteek/docs/manual/en/html/_images/folder-open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions galacteek/docs/manual/en/html/_sources/clipboard.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ Clipboard keyboard shortcuts
referenced in the clipboard
- **Ctrl+g** will open the DAG viewer for the IPFS resource currently
referenced in the clipboard
- **Ctrl+i** will open the IPLD Explorer for the IPFS resource currently
referenced in the clipboard
2 changes: 2 additions & 0 deletions galacteek/docs/manual/en/html/clipboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ <h2>Clipboard keyboard shortcuts<a class="headerlink" href="#clipboard-keyboard-
referenced in the clipboard</li>
<li><strong>Ctrl+g</strong> will open the DAG viewer for the IPFS resource currently
referenced in the clipboard</li>
<li><strong>Ctrl+i</strong> will open the IPLD Explorer for the IPFS resource currently
referenced in the clipboard</li>
</ul>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion galacteek/docs/manual/en/html/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit db8419c

Please sign in to comment.