Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ Contents
$ make install
$ make install-mathjax-plugin ## optional
$ make install-jquery-plugins ## optional
$ make install-plupload-plugin ## optional
$ make install-ckeditor-plugin ## optional
$ make install-pdfa-helper-files ## optional
$ make install-mediaelement ## optional
Expand Down Expand Up @@ -525,6 +526,14 @@ Contents

Note that `unzip' is needed when installing jquery plugins.

$ make install-plupload-plugin ## optional

This will automatically download and install in the proper
place plupload plugin, which is used in the Photos submission
interface.

Note that `unzip' is needed when installing jquery plugins.

$ make install-ckeditor-plugin ## optional

This will automatically download and install in the proper
Expand Down
66 changes: 66 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,72 @@ uninstall-pdfa-helper-files:
@echo "** The PDF/A helper files were successfully uninstalled. **"
@echo "***********************************************************"

install-plupload-plugin:
@echo "**********************************************************"
@echo "** Installing Uploader and other plugins **"
@echo "**********************************************************"
mkdir -p /tmp/invenio_js_frameworks
(cd /tmp/invenio_js_frameworks && \
wget https://github.com/moxiecode/plupload/archive/v1.5.8.zip && \
unzip v1.5.8.zip && \
mkdir -p ${prefix}/var/www/js/plupload && \
cp -r plupload-1.5.8/js/* ${prefix}/var/www/js/plupload/ && \
cd /tmp && \
rm -rf invenio_js_frameworks)

@echo "***********************************************************"
@echo "** Uploader was successfully installed **"
@echo "***********************************************************"


uninstall-plupload-plugin:
@echo "***********************************************************"
@echo "** Unistalling Uploader **"
@echo "***********************************************************"
rm -rf /tmp/invenio_js_frameworks
rm -rf ${prefix}/var/www/js/plupload
@echo "***********************************************************"
@echo "** Uploader was successfully unistalled **"
@echo "***********************************************************"


install-crop-plugin:
@echo "**********************************************************"
@echo "** Installing Uploader and other plugins **"
@echo "**********************************************************"
rm -rf /tmp/invenio_js_frameworks
mkdir -p /tmp/invenio_js_frameworks
(cd /tmp/invenio_js_frameworks && \
wget https://github.com/dimsemenov/Magnific-Popup/archive/master.zip && \
unzip master.zip && \
mkdir -p ${prefix}/var/www/static/magnific_popup && \
cp -r Magnific-Popup-master/dist/* ${prefix}/var/www/static/magnific_popup && \
wget https://github.com/tapmodo/Jcrop/zipball/v0.9.12 && \
unzip v0.9.12 && \
mkdir -p ${prefix}/var/www/static/crop && \
cp -r tapmodo-Jcrop-1902fbc/js/* ${prefix}/var/www/static/crop && \
cp -r tapmodo-Jcrop-1902fbc/css/* ${prefix}/var/www/static/crop && \
wget -O json.zip https://github.com/douglascrockford/JSON-js/archive/master.zip && \
unzip json.zip && \
cp JSON-js-master/json2.js ${prefix}/var/www/js && \
cd /tmp && \
rm -rf invenio_js_frameworks)

@echo "***********************************************************"
@echo "** Uploader was successfully installed **"
@echo "***********************************************************"

uninstall-crop-plugin:
@echo "***********************************************************"
@echo "** Unistalling Uploader **"
@echo "***********************************************************"
rm -rf /tmp/invenio_js_frameworks
rm -rf ${prefix}/var/www/static/magnific_popup
rm -rf ${prefix}/var/www/static/crop
@echo "***********************************************************"
@echo "** Uploader was successfully unistalled **"
@echo "***********************************************************"

#Solrutils allows automatic installation, running and searching of an external Solr index.
install-solrutils:
@echo "***********************************************************"
Expand Down
11 changes: 7 additions & 4 deletions modules/bibsched/lib/tasklets/bst_create_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,19 @@ def create_icons_for_record(recid, icon_sizes, icon_format_mappings=None,
bibfiles = bibdoc.list_latest_files()
bibdoc_formats = [bibfile.get_format() for bibfile in bibfiles]
for bibfile in bibfiles:
if bibfile.get_subformat():
if bibfile.get_subformat() not in ['', 'crop']:
# this is a subformat, do nothing
continue
filepath = bibfile.get_full_path()
#do not consider the dot in front of the format
superformat = bibfile.get_format()[1:].lower()
if superformat.find(';') > -1:
superformat = superformat[:superformat.index(';')]
bibfile_icon_formats = icon_format_mappings.get(superformat, icon_format_mappings.get('*', [superformat]))
if isinstance(bibfile_icon_formats, str):
bibfile_icon_formats = [bibfile_icon_formats]
bibfile_icon_formats = [bibfile_icon_format for bibfile_icon_format in bibfile_icon_formats \
if bibfile_icon_format in CFG_ALLOWED_FILE_EXTENSIONS]

if add_default_icon and not default_icon_added_p:
# add default icon
try:
Expand All @@ -129,7 +130,9 @@ def create_icons_for_record(recid, icon_sizes, icon_format_mappings=None,
for icon_size in icon_sizes:
washed_icon_size = icon_size.replace('>', '').replace('<', '').replace('^', '').replace('!', '')
for icon_format in bibfile_icon_formats:
new_format = '.%s;%s-%s' % (icon_format, CFG_BIBDOCFILE_DEFAULT_ICON_SUBFORMAT, washed_icon_size)
# change the default subformat if it's crop
prefix = 'crop' if bibfile.get_subformat() == 'crop' else CFG_BIBDOCFILE_DEFAULT_ICON_SUBFORMAT
new_format = '.%s;%s-%s' % (icon_format, prefix, washed_icon_size)
if new_format in bibdoc_formats:
# the subformat already exists, do nothing
continue
Expand Down Expand Up @@ -239,7 +242,7 @@ def bst_create_icons(recid, icon_sizes, icon_format_mappings=None,
else:
write_message("Recid %s DONE." % recid)

task_update_progress("Done %d out of %d." % (i, len(recids)))
task_update_progress("Done %d out of %d." % (i+1, len(recids)))
task_sleep_now_if_required(can_stop_too=True)

if updated:
Expand Down
3 changes: 2 additions & 1 deletion modules/miscutil/lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ pylib_DATA = __init__.py \
hepdatadisplayutils.py \
hepdatautils_unit_tests.py \
filedownloadutils.py \
filedownloadutils_unit_tests.py
filedownloadutils_unit_tests.py \
get_image_size.py

jsdir=$(localstatedir)/www/js

Expand Down
97 changes: 97 additions & 0 deletions modules/miscutil/lib/get_image_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: get_image_size
# Purpose: extract image dimentions given a file path
#
# Author: Paulo Scardine (based on code from Emmanuel VAÏSSE)
#
# Created: 26/09/2013
# Copyright: (c) Paulo Scardine 2013
# Licence: MIT
#-------------------------------------------------------------------------------
#!/usr/bin/env python
import os
import struct

FILE_UNKNOWN = "Sorry, don't know how to get size for this file."

class UnknownImageFormat(Exception):
pass

def get_image_size(file_path):
"""
Return (width, height) for a given img file content - no external
dependencies except the os and struct builtin modules
"""
size = os.path.getsize(file_path)

with open(file_path) as input:
height = -1
width = -1
data = input.read(25)
msg = " raised while trying to decode as JPEG."

if (size >= 10) and data[:6] in ('GIF87a', 'GIF89a'):
# GIFs
w, h = struct.unpack("<HH", data[6:10])
width = int(w)
height = int(h)
elif ((size >= 24) and data.startswith('\211PNG\r\n\032\n')
and (data[12:16] == 'IHDR')):
# PNGs
w, h = struct.unpack(">LL", data[16:24])
width = int(w)
height = int(h)
elif (size >= 16) and data.startswith('\211PNG\r\n\032\n'):
# older PNGs
w, h = struct.unpack(">LL", data[8:16])
width = int(w)
height = int(h)
elif (size >= 2) and data.startswith('\377\330'):
# JPEG
input.seek(0)
input.read(2)
b = input.read(1)
try:
while (b and ord(b) != 0xDA):
while (ord(b) != 0xFF): b = input.read(1)
while (ord(b) == 0xFF): b = input.read(1)
if (ord(b) >= 0xC0 and ord(b) <= 0xC3):
input.read(3)
h, w = struct.unpack(">HH", input.read(4))
break
else:
input.read(int(struct.unpack(">H", input.read(2))[0])-2)
b = input.read(1)
width = int(w)
height = int(h)
except struct.error:
raise UnknownImageFormat("StructError" + msg)
except ValueError:
raise UnknownImageFormat("ValueError" + msg)
except Exception as e:
raise UnknownImageFormat(e.__class__.__name__ + msg)
elif size >= 2:
#see http://en.wikipedia.org/wiki/ICO_(file_format)
input.seek(0)
reserved = input.read(2)
if 0 != struct.unpack("<H", reserved )[0]:
raise UnknownImageFormat(FILE_UNKNOWN)
format = input.read(2)
assert 1 == struct.unpack("<H", format)[0]
num = input.read(2)
num = struct.unpack("<H", num)[0]
if num > 1:
import warnings
warnings.warn("ICO File contains more than one image")
#http://msdn.microsoft.com/en-us/library/ms997538.aspx
w = input.read(1)
h = input.read(1)
width = ord(w)
height = ord(h)
else:
raise UnknownImageFormat(FILE_UNKNOWN)

return width, height

Loading