Commit d315471c authored by Jean-Francois Dockes's avatar Jean-Francois Dockes
Browse files

add "untagged" section

parent 48f3e905
......@@ -27,6 +27,7 @@ import urllib
import uprclfolders
import uprcltags
import uprcluntagged
import uprclsearch
from uprclutils import *
......@@ -77,6 +78,7 @@ def uprcl_init():
g_rcldocs = uprclfolders.inittree(rclconfdir)
uprcltags.recolltosql(g_rcldocs)
uprcluntagged.recoll2untagged(g_rcldocs)
@dispatcher.record('trackuri')
def trackuri(a):
......@@ -102,6 +104,11 @@ def _rootentries():
rootmap[e['id']] = 'tags'
entries += nents
nents = uprcluntagged.rootentries(g_myprefix)
for e in nents:
rootmap[e['id']] = 'untagged'
entries += nents
nents = uprclfolders.rootentries(g_myprefix)
for e in nents:
rootmap[e['id']] = 'folders'
......@@ -118,6 +125,8 @@ def _browsedispatch(objid, bflg, httphp, pathprefix):
return uprclfolders.browse(objid, bflg, httphp, pathprefix)
elif mod == 'tags':
return uprcltags.browse(objid, bflg, httphp, pathprefix)
elif mod == 'untagged':
return uprcluntagged.browse(objid, bflg, httphp, pathprefix)
else:
raise Exception("Browse: dispatch: bad mod " + mod)
raise Exception("Browse: dispatch: bad objid not in rootmap" + objid)
......
......@@ -125,7 +125,7 @@ def _fetchalldocs(confdir):
rclq.execute("mime:*", stemming=0)
uplog("Estimated alldocs query results: %d" % (rclq.rowcount))
maxcnt = 2000
maxcnt = 0
totcnt = 0
while True:
docs = rclq.fetchmany()
......
import os
import shlex
import urllib
import sys
from uprclutils import *
from recoll import recoll
from recoll import rclconfig
g_myprefix = '0$uprcl$untagged'
def recoll2untagged(docs):
global g_utidx, g_rcldocs
g_rcldocs = docs
g_utidx = [-1]
for docidx in range(len(docs)):
doc = docs[docidx]
if doc.mtype == 'inode/directory':
continue
url = doc.getbinurl()
url = url[7:]
try:
decoded = url.decode('utf-8')
except:
decoded = urllib.quote(url).decode('utf-8')
tt = doc.title
if not tt:
g_utidx.append(docidx)
def _objidtoidx(pid):
if not pid.startswith(g_myprefix):
raise Exception("untagged.browse: bad pid %s" % pid)
if len(g_rcldocs) == 0:
raise Exception("untagged:browse: no docs")
idx = pid[len(g_myprefix):]
if not idx:
idx = 0
else:
if idx[1] != 'u':
raise Exception("untagged:browse: called on bad objid %s" % pid)
idx = int(idx[2:])
if idx >= len(g_utidx):
raise Exception("untagged:browse: bad pid %s" % pid)
return idx
def rootentries(pid):
return [rcldirentry(pid + 'untagged', pid, '[untagged]'),]
# Browse method
# objid is like untagged$*u<index>
# flag is meta or children.
def browse(pid, flag, httphp, pathprefix):
idx = _objidtoidx(pid)
entries = []
if idx == 0:
# Browsing root
for i in range(len(g_utidx))[1:]:
doc = g_rcldocs[g_utidx[i]]
id = g_myprefix + '$u' + str(i)
e = rcldoctoentry(id, pid, httphp, pathprefix, doc)
if e:
entries.append(e)
else:
# Non root: only items in there. flag needs to be 'meta'
doc = g_rcldocs[thisdocidx]
id = g_myprefix + '$u' + str(idx)
e = rcldoctoentry(id, pid, httphp, pathprefix, doc)
if e:
entries.append(e)
return sorted(entries, cmp=cmpentries)
from __future__ import print_function
import sys
import posixpath
import urllib
import os
......@@ -110,8 +109,12 @@ def rcldoctoentry(id, pid, httphp, pathprefix, doc):
# parent process to match urls to plugins)
path = doc.getbinurl()
path = path[7:]
if 'tt' not in li:
li['tt'] = os.path.basename(path.decode('UTF-8', errors = 'replace'))
path = pathprefix + path
li['uri'] = "http://%s%s" % (httphp, urllib.quote(path))
uplog("rcldoctoentry: uri: %s" % li['uri'])
return li
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment