Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffroy-noel-ddh committed Jan 20, 2022
2 parents 4b416ed + 4d82965 commit 7b4b321
Show file tree
Hide file tree
Showing 17 changed files with 155 additions and 135 deletions.
3 changes: 2 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ RUN mkdir /home/digipal
WORKDIR /home/digipal

# (inc. the number in echo to force docker build to fetch new version of the code)
RUN echo "19" && git clone -b develop https://github.com/kcl-ddh/digipal.git /home/digipal
RUN echo "2.8" && git clone -b develop https://github.com/kcl-ddh/digipal.git /home/digipal


COPY * build/
COPY archetype/* build/archetype/
Expand Down
2 changes: 1 addition & 1 deletion build/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# What version of Archetype is the latest image on dockerhub
# See digipal/__init__.py
__version__ = '2.7'
__version__ = '2.8'
2 changes: 1 addition & 1 deletion digipal/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.7'
__version__ = '2.8'
10 changes: 6 additions & 4 deletions digipal/management/commands/dpim.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,10 @@ def transform_image(self, image_info, operations):

path_src = os.path.join(settings.IMAGE_SERVER_ROOT, image_info['path'])
path_original = path_src
pid = os.getpid()
for i, op in enumerate(operations):
op[0] = op[0].replace('%s', '{}')
ret = '/tmp/dpim-{}.{}'.format(i, op[1])
ret = '/tmp/dpim-{}-{}.{}'.format(pid, i, op[1])
if os.path.exists(ret): os.remove(ret)
command = op[0].format(path_src, ret)
ret_shell = self.run_shell_command(command)
Expand Down Expand Up @@ -1144,11 +1145,13 @@ def jp2tif(self):
'errors': 0,
}

from time import time

for info in files:
if self.is_filtered_in(info) and info.get('disk', False) and info['image']:
if self.is_filtered_in(info) and info.get('disk', False) and info['image'] and getattr(info['image'], 'pk') > 0:
if not info['path'].endswith(settings.IMAGE_SERVER_EXT):
stats['total'] += 1
print(stats['total'], info['image'].pk, info['path'])
print(int(time()), stats['total'], info['image'].pk, info['path'])

operations = [
['opj_decompress -quiet -i {} -OutFor TIF -o {}', 'png'],
Expand All @@ -1166,4 +1169,3 @@ def jp2tif(self):
stats['converted'],
stats['errors'],
))

12 changes: 10 additions & 2 deletions digipal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ def filter(self, record):
# Lower value for smaller increments (OL default = 2)
ANNOTATOR_ZOOM_FACTOR = 1.4

ANNOTATOR_UNDESCRIBED_GRAPH_HTML = '<li class="component">This graph has no description.</li>'

# Show ms date on annotator?
PAGE_IMAGE_SHOW_MSDATE = False
# Show MS summary on annotator?
Expand Down Expand Up @@ -753,11 +755,11 @@ def filter(self, record):

TEXT_EDITOR_OPTIONS = {
'buttons': {
'psclause': 'Address,Disposition,Witnesses',
'psclause': 'Address,Disposition,Witnesses,Dating',
'psClauseSecondary': 'Arenga,Boundaries,Holding,Injunction,Malediction,Narration,Notification,Prohibition,Salutation,Sealing,Subscription,Intitulatio,Warrandice'
},
'toolbars': {
'default': 'psclear undo redo pssave | psconvert | psclause | psClauseSecondary | psperson | pslocation | psex pssupplied psdel | code ',
'default': 'psclear undo redo pssave | psconvert | psclause | psClauseSecondary | psperson | psplace | pslocation | psex pssupplied psdel | code ',
},
'panels': {
'north': {
Expand All @@ -769,6 +771,12 @@ def filter(self, record):
}
}

'''Which type of XML elements in the texts will receive an id.
The id is needed to allow search indexing and image-text annotations.
e.g. <span data-dpt='clause' data-dpt-type='disposition'>my clause here</span>
'''
TEXT_ELEMENTS_WITH_IDS = ['clause', 'location', 'person', 'place']

##################
# LOCAL SETTINGS #
##################
Expand Down
11 changes: 10 additions & 1 deletion digipal/static/css/dpbase.less
Original file line number Diff line number Diff line change
Expand Up @@ -892,4 +892,13 @@ a[data-toggle="pill"]{
p, div {
display: inline-block;
}
}
}

.annotator-fullscreen nav.primary-nav.navbar {
display: none;
}

// hide this btn as Google URL shortener service is closed
#long_url {
display: none;
}
7 changes: 5 additions & 2 deletions digipal/static/digipal/scripts/annotator-digipal.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ function DigipalAnnotator(mediaUrl, imageUrl, imageWidth, imageHeight, imageServ
events: function(dialog_instance, selectedFeature) {
var url_allograph_button = dialog_instance.parent().find('.url_allograph');

url_allograph_button.on('click', function() {
url_allograph_button.off('click').on('click', function() {
show_url_allograph(dialog_instance, selectedFeature, $(this));
});
if (!window.digipal_settings.ARCHETYPE_GOOGLE_SHORTENER_CLIENTID) {
Expand Down Expand Up @@ -1883,6 +1883,7 @@ function DigipalAnnotator(mediaUrl, imageUrl, imageWidth, imageHeight, imageServ
var map_size;
var input_toolbar_position = $("input[name='toolbar_position']:checked");
if (!(this.fullScreen.active)) {
$('body').addClass('annotator-fullscreen')
$('html, body').animate({
scrollTop: map.position().top
}, 0);
Expand All @@ -1892,6 +1893,7 @@ function DigipalAnnotator(mediaUrl, imageUrl, imageWidth, imageHeight, imageServ

$(document).keyup(function(e) {
if (e.keyCode == 27) {
$('body').removeClass('annotator-fullscreen')
map.removeClass('fullScreenMap');
panel.removeClass('fullScreenPanel');
toolbar.removeClass('mapHorizontalFullscreen');
Expand All @@ -1912,6 +1914,7 @@ function DigipalAnnotator(mediaUrl, imageUrl, imageWidth, imageHeight, imageServ
}
} else {
this.fullScreen.deactivate();
$('body').removeClass('annotator-fullscreen')
map.removeClass('fullScreenMap');

$('.olControlFullScreenFeatureItemInactive').attr('title', 'Activate Full Screen');
Expand Down Expand Up @@ -2518,7 +2521,7 @@ function refresh_features_dialog(data, dialog) {
components.push(component);
}
} else if (data.hasOwnProperty('features') && $.isEmptyObject(features)) {
s += "<li class='component'>This graph has not yet been described.</li>";
s += window.ANNOTATOR_UNDESCRIBED_GRAPH_HTML;
//dialog.css('height', '100px');
}

Expand Down
4 changes: 4 additions & 0 deletions digipal/static/digipal/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
* callback(short_url)
*/
gapi_shorten_url: function(long_url, callback) {
// this Google service is no longer available, return long_url
callback(long_url);
return;

window.dputils.gapi_call(function(google_api_client) {

google_api_client.load('urlshortener', 'v1', function() {
Expand Down
11 changes: 7 additions & 4 deletions digipal/static/js/search_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,20 @@ function init_search_page(options) {

var page_url = dputils.get_page_url($(location).attr('href'));
// ! we use this.href instead of $element.attr('href') as the first one returns the absolute URL
$form = $element.parents('form');
var $form = $element.parents('form');
//var url = this.hasAttribute('href') ? this.href : page_url + '?' + $form.serialize();
var url = this.hasAttribute('href') ? this.href : page_url;
var $focus_selector = $element.data('focus');

// check if the href is for this page
// leave if the href points to another page
if (page_url !== dputils.get_page_url(url)) return true;
// check if control-click
// leave if control-click (reload in new tab)
if (ev.ctrlKey) return true;

window.dputils.fragment_refreshing("#search-ajax-fragment");

var url_on_success = this.href ? url : page_url + '?' + $form.serialize().replace(/[^?&]+=(&|$)/g, '');

// See http://stackoverflow.com/questions/9956255.
// This tricks prevents caching of the fragment by the browser.
// Without this if you move away from the page and then click back
Expand All @@ -317,7 +319,8 @@ function init_search_page(options) {
// insert the new HTML content
$fragment.html($data.html());

if (!is_post) dputils.update_address_bar(url, false, true);
if (!is_post) dputils.update_address_bar(url_on_success, false, true);
// if (!is_post) dputils.update_address_bar(url, false, true);

$fragment.stop().animate({
'background-color': 'white',
Expand Down
1 change: 1 addition & 0 deletions digipal/templates/digipal/image_annotation.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ <h2 class='header1' id="annotator_heading">

<script>
var img_url = "{{ url }}";
var ANNOTATOR_UNDESCRIBED_GRAPH_HTML = {{ ANNOTATOR_UNDESCRIBED_GRAPH_HTML|json }};
</script>

{% if show_image %}
Expand Down
24 changes: 24 additions & 0 deletions digipal/templates/digipal/recent_posts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="col-md-4 col-sm-12 recentPosts">
<h1 class='header1'><a href="/blog/category/{{ posts_category }}/">{{ posts_title }}</a></h1>
{% load blog_tags keyword_tags i18n %}
{% blog_recent_posts 4 category=posts_category as recent_posts %}
{% if recent_posts %}
<ul>
{% for recent_post in recent_posts %}
<li>
<a href="{{ recent_post.get_absolute_url }}">
{{ recent_post.title }}
</a>
<br/>
<span class="legend">
{{ recent_post.publish_date|timesince }}
ago, by {{ recent_post.user.first_name }} {{ recent_post.user.last_name }}
</span>
</li>
{% endfor %}
</ul>
<p>
<a class='btn btn-default' href="/blog/category/news">{{ posts_more }} &raquo;</a>
</p>
{% endif %}
</div>
109 changes: 1 addition & 108 deletions digipal/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,110 +1,3 @@
{% extends "base.html" %}
{% extends "index_default.html" %}
{% load i18n %}
{% load blog_tags keyword_tags i18n html_escape %}

{% block meta_title_site %}{{ settings.SITE_TITLE }}{% endblock %}

{% block meta_title %}{% endblock %}

{% block title %}
{% trans "Home" %}
{% endblock %}

{% block breadcrumb_menu %}
<li class="active">{% trans "Home" %}</li>
{% endblock %}

{% block main %}
{% block top %}
<div class='row'>

{% block top_left %}
{% include "digipal/home_carousel.html" %}
{% endblock %}

{% block top_middle %}
{% endblock %}

{% block top_right %}
<div class="col-md-4 smaller justified">
{% include "digipal/home_intro.html" %}
</div>
{% endblock %}

</div>
{% endblock %}

{% block bottom %}

<div id="homeSection" class="row home-page-listings">

{% block bottom_left %}
<div class="col-md-4 col-sm-12 recentPosts">

<h1 class='header1'><a href="/blog/category/blog">Blog</a></h1>
{% load blog_tags keyword_tags i18n %}
{% blog_recent_posts 4 category="blog" as recent_posts %}
{% if recent_posts %}
<ul>
{% for recent_post in recent_posts %}
<li>
<a href="{{ recent_post.get_absolute_url }}">
{{ recent_post.title }}
</a>
<br/>
<span class="legend">
{{ recent_post.publish_date|timesince }}
ago, by {{ recent_post.user.first_name }} {{ recent_post.user.last_name }}
</span>
</li>
{% endfor %}
</ul>
<p>
<a class='btn btn-default' href="/blog/category/blog">More blog entries &raquo;</a>
</p>
{% endif %}
</div>
{% endblock %}

{% block bottom_middle %}

<div class="col-md-4 col-sm-12 recentPosts">

<h1 class='header1'><a href="/blog/category/news">News</a></h1>
{% load blog_tags keyword_tags i18n %}
{% blog_recent_posts 4 category="news" as recent_posts %}
{% if recent_posts %}
<ul>
{% for recent_post in recent_posts %}
<li>
<a href="{{ recent_post.get_absolute_url }}">
{{ recent_post.title }}
</a>
<br/>
<span class="legend">
{{ recent_post.publish_date|timesince }}
ago, by {{ recent_post.user.first_name }} {{ recent_post.user.last_name }}
</span>
</li>
{% endfor %}
</ul>
<p>
<a class='btn btn-default' href="/blog/category/news">More news &raquo;</a>
</p>
{% endif %}
</div>
{% endblock %}

{% block bottom-right %}
<div class="col-md-4 col-sm-12">

{% render_mezzanine_page 'home.glossary' %}

</div>
{% endblock %}

</div>

{% endblock %}

{% endblock %}
59 changes: 59 additions & 0 deletions digipal/templates/index_default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% extends "base.html" %}
{% load i18n %}
{% load blog_tags keyword_tags i18n html_escape %}

{% block meta_title_site %}{{ settings.SITE_TITLE }}{% endblock %}

{% block meta_title %}{% endblock %}

{% block title %}
{% trans "Home" %}
{% endblock %}

{% block breadcrumb_menu %}
<li class="active">{% trans "Home" %}</li>
{% endblock %}

{% block main %}
{% block top %}
<div class='row'>

{% block top_left %}
{% include "digipal/home_carousel.html" %}
{% endblock %}

{% block top_middle %}
{% endblock %}

{% block top_right %}
<div class="col-md-4 smaller justified">
{% include "digipal/home_intro.html" %}
</div>
{% endblock %}

</div>
{% endblock %}

{% block bottom %}

<div id="homeSection" class="row home-page-listings">

{% block bottom_left %}
{% include 'digipal/recent_posts.html' with posts_title='Blog' posts_category='blog' posts_more='More entries' %}
{% endblock %}

{% block bottom_middle %}
{% include 'digipal/recent_posts.html' with posts_title='News' posts_category='news' posts_more='More news' %}
{% endblock %}

{% block bottom-right %}
<div class="col-md-4 col-sm-12">
{% render_mezzanine_page 'home.glossary' %}
</div>
{% endblock %}

</div>

{% endblock %}

{% endblock %}
Loading

0 comments on commit 7b4b321

Please sign in to comment.