Skip to content
Permalink
Browse files

migrate from wuy to guy

  • Loading branch information
manatlan committed Nov 16, 2019
1 parent 5a84e4d commit 17ca6f5054f04de88af2ffdf27468f4c48ee9725
Showing with 123 additions and 155 deletions.
  1. +2 −3 README.md
  2. +5 −0 config.json
  3. +48 −31 jbrout.py
  4. +4 −59 jbroutDev.py
  5. +1 −1 requirements.txt
  6. +1 −1 setup.py
  7. 0 {web → static}/README.md
  8. 0 {web → static}/expander.vue
  9. BIN {web → static}/favicon.ico
  10. BIN {web → static}/gfx/basket.png
  11. BIN {web → static}/gfx/calendar.png
  12. BIN {web → static}/gfx/check_disabled.png
  13. BIN {web → static}/gfx/check_false.png
  14. BIN {web → static}/gfx/check_no.png
  15. BIN {web → static}/gfx/check_not.png
  16. BIN {web → static}/gfx/check_true.png
  17. BIN {web → static}/gfx/dir_disabled.png
  18. BIN {web → static}/gfx/dir_false.png
  19. BIN {web → static}/gfx/dir_no.png
  20. BIN {web → static}/gfx/dir_true.png
  21. BIN {web → static}/gfx/folder.png
  22. BIN {web → static}/gfx/imgError.png
  23. BIN {web → static}/gfx/imgNoThumb.png
  24. BIN {web → static}/gfx/imgNotFound.png
  25. BIN {web → static}/gfx/jbrout.ico
  26. BIN {web → static}/gfx/jbrout.png
  27. 0 {web → static}/gfx/new_jbrout.svg
  28. BIN {web → static}/gfx/raw.png
  29. BIN {web → static}/gfx/refresh.png
  30. 0 {web → static}/hbox.vue
  31. +1 −1 {web → static}/index.html
  32. +53 −53 {web → static}/jbrout.js
  33. 0 {web → static}/libs/vue.min.js
  34. 0 {web → static}/libs/vuex.min.js
  35. 0 {web → static}/notify.vue
  36. 0 {web → static}/popmenu.vue
  37. +2 −2 {web → static}/selectFolder.vue
  38. +3 −2 {web → static}/thumb.vue
  39. 0 {web → static}/treeFolders.vue
  40. 0 {web → static}/treeTags.vue
  41. 0 {web → static}/uiApp.vue
  42. 0 {web → static}/uiBottom.vue
  43. 0 {web → static}/uiLeft.vue
  44. 0 {web → static}/uiLeftAlbums.vue
  45. 0 {web → static}/uiLeftSearch.vue
  46. 0 {web → static}/uiLeftTags.vue
  47. 0 {web → static}/uiLeftTime.vue
  48. 0 {web → static}/uiMain.vue
  49. 0 {web → static}/uiTop.vue
  50. 0 {web → static}/vbox.vue
  51. +3 −2 {web → static}/viewer.vue
  52. 0 {web → static}/working.vue
@@ -1,10 +1,9 @@
My attempt to port the good old [jbrout/py2/gtk](https://manatlan.com/jbrout/) to python3/wuy's web app.
My attempt to port the good old [jbrout/py2/gtk](https://manatlan.com/jbrout/) to python3/guy's web app.

(will use [Guy](https://github.com/manatlan/guy) soon, in place of wuy)

Currently, it's in pre-alpha stage : USE AT YOUR OWN RISK ;-)

The idea : The old jbrout used gtk with python2 (there are a lot of works to port it to python3, with gobject changes). This version use [wuy](https://github.com/manatlan/wuy), which will make it completly independant of the OS. It will reuse your chrome installation, to run a windowed version of jbrout. The frontend is full html/js/css, using vuejs + vuex. It communicates with the serverside thru a websocket. The serverside use the good olds python apis.
The idea : The old jbrout used gtk with python2 (there are a lot of works to port it to python3, with gobject changes). This version use [guy](https://github.com/manatlan/guy), which will make it completly independant of the OS. It will reuse your chrome installation, to run a windowed version of jbrout. The frontend is full html/js/css, using vuejs + vuex. It communicates with the serverside thru a websocket. The serverside use the good olds python apis.

BTW, it will be possible to use [cefpython3](https://github.com/cztomczak/cefpython), to make a standalone version. And it will be possible to run jbrout headless (server mode), and use it thru any browsers (but we will need to handle session/multi-users).

@@ -0,0 +1,5 @@
{
"displayType": "tags",
"lastpath": "/home/manatlan/Bureau/CAL2016",
"orderReverse": false
}
@@ -16,13 +16,13 @@
# ###########################################################################

import os,sys,asyncio
import wuy,vbuild
import guy,vbuild
from jbapi import JBrout

__version__="0.2.2"

class jbrout:
""" RPC methods exposed in the front, see wuy.<method>() in js """
""" RPC methods exposed in the front, see self.<method>() in js """

def getFolders(self):
return self.api.getFolders()
@@ -199,54 +199,71 @@ def dir(self,path):
pass
return ll

class index(wuy.Window,jbrout):
""" wuy tech class (with tech stuff) """
class index(guy.Guy,jbrout):
""" guy tech class (with tech stuff) """
size=(1024,780)

def __init__(self,api):
self.api=api
guy.Guy.__init__(self)

def _render(self,path): #here is the magic
# load your template (from web folder)
with open( os.path.join(path,"web","index.html") ) as fid:
with open( os.path.join(path,"static","index.html") ) as fid:
content=fid.read()

# load all vue/sfc components
v=vbuild.render( os.path.join(path,"web/*.vue") )
v=vbuild.render( os.path.join(path,"static/*.vue") )

# and inject them in your template
return content.replace("<!-- HERE -->",str(v))

def request(self,req): #override to hook others web requests

def getPic(path,idx):
i=self.api.selectPhotoNode(path)
if idx is not None:
info=dict(
tags=i.tags,
comment=i.comment,
rating=i.rating,
resolution=i.resolution,
real=i.real
)
self.emit("set-info",idx,path,info)
return i

idx=req.query.get("idx",None)
if req.path.startswith("/thumb/"):
return getPic(req.path[7:],idx).getThumb()
elif req.path.startswith("/image/"):
return getPic(req.path[7:],idx).getImage()


async def getPic(web,path,idx):
i=web.instance.api.selectPhotoNode(path)
if idx is not None:
info=dict(
tags=i.tags,
comment=i.comment,
rating=i.rating,
resolution=i.resolution,
real=i.real
)
await web.instance.emit("set-info",idx,path,info)
return i

@guy.http("/h")
def t(web):
print("====")
web.write("hello")


@guy.http("/thumb/(.+)")
async def requestThumb(web,path): #override to hook others web requests
path=path.replace(":",".") # see patchUrl() is js
idx=web.get_argument('idx', None)
i=await getPic(web,path,idx)
web.write( i.getThumb() )

@guy.http("/image/(.+)")
async def requestImage(web,path): #override to hook others web requests
path=path.replace(":",".") # see patchUrl() is js
idx=web.get_argument('idx', None)
i=await getPic(web,path,idx)
web.write( i.getImage() )

def main():
cwd = os.path.dirname(__file__)
wuy.PATH = cwd

## wuy.ChromeApp=wuy.ChromeAppCef # to test with cefpython3

#~ with JBrout(os.path.expanduser("~/.local/share/jbrout")) as api: #copy of the original jbrout
#~ index(api=api)
#~ w=index(api=api)
#~ w.run()
#~ quit()

with JBrout(os.path.join(cwd,"tempconf")) as api:
index(api=api)
w=index(api=api)
w.run()

if __name__=="__main__":
main()
@@ -21,72 +21,17 @@
it will disappear in the future (when 1.0)
"""
import os,sys
import wuy,vbuild
import guy,vbuild
from jbapi import JBrout
from jbrout import jbrout

class index(wuy.Server,jbrout):
"""
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
"""

def _render(self,path): #here is the magic
# load your template (from web folder)

with open( os.path.join(path,"web","index.html") ) as fid:
content=fid.read()

# load all vue/sfc components
v=vbuild.render( os.path.join(path,"web/*.vue") )

# and inject them in your template
return content.replace("<!-- HERE -->",str(v))

"""
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
"""

def request(self,req): #override to hook others web requests

def getPic(path,idx):
i=self.api.selectPhotoNode(path)
if idx is not None:
info=dict(
tags=i.tags,
comment=i.comment,
rating=i.rating,
resolution=i.resolution,
real=i.real
)
self.emit("set-info",idx,path,info)
return i

idx=req.query.get("idx",None)
if req.path.startswith("/thumb/"):
return getPic(req.path[7:],idx).getThumb()
elif req.path.startswith("/image/"):
return getPic(req.path[7:],idx).getImage()

"""
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
IF YOU CHANGE THINGS HERE, DONT FORGET TO REPORT TO jbrout.py:index !
"""
from jbrout import jbrout,index

def main():
cwd = os.path.dirname(__file__)
wuy.PATH = cwd

#~ with api.init(os.path.expanduser("~/.local/share/jbrout")): #copy of the original jbrout
with JBrout(os.path.join(cwd,"tempconf")) as api:
index(api=api)
w=index(api=api)
w.serve()

if __name__=="__main__":
main()
@@ -1,4 +1,4 @@
wuy>=0.9.20
guy
vbuild
lxml
py3exiv2
@@ -38,5 +38,5 @@ def read(fname):
"Topic :: Multimedia :: Graphics :: Viewers",
"Topic :: Multimedia :: Graphics :: Capture :: Digital Camera",
],
install_requires=['py3exiv2', 'lxml', 'wuy', 'vbuild',"Pillow"],
install_requires=['py3exiv2', 'lxml', 'guy', 'vbuild',"Pillow"],
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -2,7 +2,7 @@
<html>
<head>
<meta charset="UTF-8"/>
<script src="wuy.js"></script>
<script src="guy.js"></script>
<script src="libs/vue.min.js"></script>
<script src="libs/vuex.min.js"></script>

0 comments on commit 17ca6f5

Please sign in to comment.
You can’t perform that action at this time.