mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
no buildcache will generate a tags.json file (needs more testing)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
0ba445564e
commit
2d8ce14616
@ -2,7 +2,7 @@
|
||||
#=======================================================================
|
||||
|
||||
__version__ = '''0.0.01'''
|
||||
__sub_version__ = '''20131219053320'''
|
||||
__sub_version__ = '''20131228075624'''
|
||||
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
||||
|
||||
|
||||
@ -62,11 +62,13 @@ CONFIG = {
|
||||
'images': 'images.json',
|
||||
'data': 'data.json',
|
||||
'marked': 'marked.json',
|
||||
'tagscache': 'tags.json',
|
||||
'filelist': 'filelist.json',
|
||||
|
||||
'images-diff': '%(date)s-images-diff.json',
|
||||
'data-diff': '%(date)s-data.json',
|
||||
'marked-diff': '%(date)s-marked.json',
|
||||
'tags-diff': '%(date)s-tags.json',
|
||||
|
||||
'config': 'ImageGrid.cfg',
|
||||
'error': 'error.log',
|
||||
@ -366,6 +368,19 @@ def getmarked(path, config=CONFIG, verbosity=0):
|
||||
verbosity=verbosity)
|
||||
|
||||
|
||||
#-------------------------------------------------------------gettags---
|
||||
def gettags(path, config=CONFIG, verbosity=0):
|
||||
'''
|
||||
'''
|
||||
return loadlatest(
|
||||
pathjoin(path, config['cache-dir']),
|
||||
lambda n: n.endswith(config['tagscache']),
|
||||
lambda n: n == config['tagscache'],
|
||||
lambda path: json.load(open(path)),
|
||||
{},
|
||||
verbosity=verbosity)
|
||||
|
||||
|
||||
#----------------------------------------------------build_cache_dirs---
|
||||
def build_cache_dirs(path, config=CONFIG, dry_run=False, verbosity=0):
|
||||
'''
|
||||
@ -669,12 +684,14 @@ def build_cache(path, config=CONFIG, gid_generator=hash_gid,
|
||||
images_file = pathjoin(cache_dir, config['images'])
|
||||
data_file = pathjoin(cache_dir, config['data'])
|
||||
marked_file = pathjoin(cache_dir, config['marked'])
|
||||
tags_file = pathjoin(cache_dir, config['tagscache'])
|
||||
|
||||
# load the json files if they exist....
|
||||
files = {
|
||||
images_file: getimages(path, config, verbosity=verbosity),
|
||||
data_file: getdata(path, config, verbosity=verbosity),
|
||||
marked_file: getmarked(path, config, verbosity=verbosity),
|
||||
tags_file: gettags(path, config, verbosity=verbosity),
|
||||
}
|
||||
_images = {} if files[images_file] == None else files[images_file]
|
||||
|
||||
@ -735,6 +752,26 @@ def build_cache(path, config=CONFIG, gid_generator=hash_gid,
|
||||
if files[marked_file] != [] and marked != None:
|
||||
marked_file = pathjoin(cache_dir, config['marked-diff'] % {'date': d})
|
||||
|
||||
# buld the tags...
|
||||
# XXX do we need to sort the tags???
|
||||
if images != None and config['tags'] != files[tags_file]:
|
||||
tags = files[tags_file]
|
||||
order = data['order']
|
||||
new_gids = images.keys()
|
||||
new_tags = dict([ (tag, new_gids) for tag in config['tags'] ])
|
||||
for t, l in new_tags.items():
|
||||
if t in tags:
|
||||
# merge the tagged gids...
|
||||
l = tags[t] = list(set(tags[t] + l))
|
||||
else:
|
||||
tags[t] = l
|
||||
# sort...
|
||||
l.sort(lambda a, b: cmp(order.index(a), order.index(b)))
|
||||
if files[tags_file] != {}:
|
||||
tags_file = pathjoin(cache_dir, config['tags-diff'] % {'date': d})
|
||||
else:
|
||||
tags = None
|
||||
|
||||
if verbosity >= 1:
|
||||
print
|
||||
|
||||
@ -747,6 +784,7 @@ def build_cache(path, config=CONFIG, gid_generator=hash_gid,
|
||||
images_file: images,
|
||||
data_file: data,
|
||||
marked_file: marked,
|
||||
tags_file: tags,
|
||||
}
|
||||
# write files...
|
||||
for n, d in files.items():
|
||||
|
||||
18
ui/data.js
18
ui/data.js
@ -1826,15 +1826,17 @@ function _loadImagePreviewURL(image, url){
|
||||
function updateImage(image, gid, size, sync){
|
||||
image = image == null ? getImage() : $(image)
|
||||
sync = sync == null ? CONFIG.load_img_sync : sync
|
||||
var oldgid = getImageGID(image)
|
||||
var old_gid = getImageGID(image)
|
||||
|
||||
if(oldgid == gid || gid == null){
|
||||
gid = oldgid
|
||||
// same image -- update...
|
||||
if(old_gid == gid || gid == null){
|
||||
gid = old_gid
|
||||
|
||||
// reuse for different image -- reconstruct...
|
||||
} else {
|
||||
// remove old marks...
|
||||
if(typeof(oldgid) == typeof('str')){
|
||||
getImageMarks(oldgid).remove()
|
||||
if(typeof(old_gid) == typeof('str')){
|
||||
getImageMarks(old_gid).remove()
|
||||
}
|
||||
// reset gid...
|
||||
image
|
||||
@ -1864,8 +1866,10 @@ function updateImage(image, gid, size, sync){
|
||||
// preview...
|
||||
var p_url = getBestPreview(gid, size).url
|
||||
|
||||
// update the preview only if it's different...
|
||||
if(image.css('background-image').indexOf(encodeURI(p_url)) < 0){
|
||||
// update the preview if it's a new image or...
|
||||
if(old_gid != gid
|
||||
// the new preview (purl) is different to current...
|
||||
|| image.css('background-image').indexOf(encodeURI(p_url)) < 0){
|
||||
// sync load...
|
||||
if(sync){
|
||||
_loadImagePreviewURL(image, p_url)
|
||||
|
||||
@ -242,8 +242,6 @@ var toggleSlideShowMode = createCSSClassToggler(
|
||||
}
|
||||
SLIDESHOW_INTERVAL = isNaN(interval) ? 3000 : interval*M
|
||||
|
||||
console.log('>>>', data, interval)
|
||||
|
||||
showStatus('Slideshow: starting:', SLIDESHOW_INTERVAL/1000 +'sec,', SLIDESHOW_LOOP ? 'looped...' : 'unlooped...')
|
||||
|
||||
// XXX is this the correct way to go???
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user