standalone
Simon Caminada 8 years ago
parent 4ba4863a98
commit cc3e58b323

@ -1,6 +0,0 @@
{
"installed-apps": [
"djangocms_file"
],
"package-name": "djangocms-file"
}

@ -1,29 +0,0 @@
# -*- coding: utf-8 -*-
from aldryn_client import forms
def split_and_strip(string):
return [item.strip() for item in string.split(',') if item]
class Form(forms.BaseForm):
templates = forms.CharField(
'List of additional templates (comma separated)',
required=False,
)
def clean(self):
data = super(Form, self).clean()
# prettify
data['templates'] = ', '.join(split_and_strip(data['templates']))
return data
def to_settings(self, data, settings):
if data['templates']:
settings['DJANGOCMS_FILE_TEMPLATES'] = [
(item, item)
for item in split_and_strip(data['templates'])
]
return settings

@ -1,3 +0,0 @@
{
"templates": null
}

@ -1,6 +0,0 @@
{
"installed-apps": [
"djangocms_googlemap"
],
"package-name": "djangocms-googlemap"
}

@ -1,35 +0,0 @@
# -*- coding: utf-8 -*-
from aldryn_client import forms
def split_and_strip(string):
return [item.strip() for item in string.split(',') if item]
class Form(forms.BaseForm):
templates = forms.CharField(
'List of additional templates (comma separated)',
required=False,
)
api_key = forms.CharField(
'You need to provide a valid Google Maps API key '
'https://developers.google.com/maps/documentation/javascript/get-api-key',
required=True,
)
def clean(self):
data = super(Form, self).clean()
# prettify
data['templates'] = ', '.join(split_and_strip(data['templates']))
return data
def to_settings(self, data, settings):
if data['templates']:
settings['DJANGOCMS_GOOGLEMAP_TEMPLATES'] = [
(item, item)
for item in split_and_strip(data['templates'])
]
if data['api_key']:
settings['DJANGOCMS_GOOGLEMAP_API_KEY'] = data['api_key']
return settings

@ -1,4 +0,0 @@
{
"api_key": null,
"templates": null
}

@ -1,6 +0,0 @@
{
"installed-apps": [
"djangocms_snippet"
],
"package-name": "djangocms-snippet"
}

@ -1,27 +0,0 @@
# -*- coding: utf-8 -*-
from aldryn_client import forms
class Form(forms.BaseForm):
editor_theme = forms.CharField(
'Custom editor theme, (e.g. "twilight", default: "github")',
required=False,
)
editor_mode = forms.CharField(
'Custom editor mode (e.g. "javascript", default: "html")',
required=False,
)
enable_search = forms.CheckboxField(
'Enable snippet content to be searchable.',
required=False,
initial=False,
)
def to_settings(self, data, settings):
if data['editor_theme']:
settings['DJANGOCMS_SNIPPET_THEME'] = data['editor_theme']
if data['editor_mode']:
settings['DJANGOCMS_SNIPPET_MODE'] = data['editor_mode']
if data['enable_search']:
settings['DJANGOCMS_SNIPPET_SEARCH'] = data['enable_search']
return settings

@ -1,5 +0,0 @@
{
"editor_mode": null,
"editor_theme": null,
"enable_search": false
}

@ -1,6 +0,0 @@
{
"installed-apps": [
"djangocms_style"
],
"package-name": "djangocms-style"
}

@ -1,43 +0,0 @@
# -*- coding: utf-8 -*-
from aldryn_client import forms
def split_and_strip(string):
return [item.strip() for item in string.split(',') if item]
class Form(forms.BaseForm):
templates = forms.CharField(
'List of additional templates (comma separated)',
required=False,
)
class_names = forms.CharField(
'List of classes (comma separated)',
required=False,
)
tag_types = forms.CharField(
'List of HTML tags (comma separated)',
required=False,
)
def clean(self):
data = super(Form, self).clean()
# prettify
data['templates'] = ', '.join(split_and_strip(data['templates']))
data['class_names'] = ', '.join(split_and_strip(data['class_names']))
data['tag_types'] = ', '.join(split_and_strip(data['tag_types']))
return data
def to_settings(self, data, settings):
if data['templates']:
settings['DJANGOCMS_STYLE_TEMPLATES'] = [
(item, item)
for item in split_and_strip(data['templates'])
]
if data['class_names']:
settings['DJANGOCMS_STYLE_CHOICES'] = split_and_strip(data['class_names'])
if data['tag_types']:
settings['DJANGOCMS_STYLE_TAGS'] = split_and_strip(data['tag_types'])
return settings

@ -1,5 +0,0 @@
{
"class_names": null,
"tag_types": null,
"templates": null
}

@ -1,6 +0,0 @@
{
"installed-apps": [
"djangocms_video"
],
"package-name": "djangocms-video"
}

@ -1,43 +0,0 @@
# -*- coding: utf-8 -*-
from aldryn_client import forms
def split_and_strip(string):
return [item.strip() for item in string.split(',') if item]
class Form(forms.BaseForm):
templates = forms.CharField(
'List of additional templates (comma separated)',
required=False,
)
extensions = forms.CharField(
'List of allowed extensions, default "mp4, webm, ogv" when empty (comma separated)',
required=False,
)
def clean(self):
data = super(Form, self).clean()
# older versions of this addon had a bug where the values would be
# saved to settings.json as a list instead of a string.
if isinstance(data['templates'], list):
data['templates'] = ', '.join(data['templates'])
if isinstance(data['extensions'], list):
data['extensions'] = ', '.join(data['extensions'])
# prettify
data['templates'] = ', '.join(split_and_strip(data['templates']))
data['extensions'] = ', '.join(split_and_strip(data['extensions']))
return data
def to_settings(self, data, settings):
if data['templates']:
settings['DJANGOCMS_VIDEO_TEMPLATES'] = [
(item, item)
for item in split_and_strip(data['templates'])
]
if data['extensions']:
settings['DJANGOCMS_VIDEO_ALLOWED_EXTENSIONS'] = split_and_strip(data['extensions'])
return settings

@ -1,4 +0,0 @@
{
"extensions": null,
"templates": null
}

@ -1,308 +0,0 @@
'use strict';
/*
* Copyright https://github.com/divio/djangocms-googlemap
*/
(function () {
var GoogleMap = (function () {
/**
* Helper function that retrieves a data-attribute value.
*
* @function getAttr
* @param {HTMLElement} element single document node
* @param {String} data data-attribute to retrieve
* @return {String} value returns the value from the data-attribute
*/
function getAttr(element, data) {
var value = element.getAttribute('data-' + data);
// true/false values need to be parsed from string to boolean
// from the attributes data
if (value === 'true') {
return true;
} else if (value === 'false') {
return false;
}
return value;
}
/**
* Initiates the GoogleMap plugin inside the ``djangocms-googlemap-container`` container.
*
* <div class="djangocms-googlemap js-djangocms-googlemap">
* <div class="djangocms-googlemap-container js-djangocms-googlemap-container"></div>
* </div>
*
* @class GoogleMap
* @constructor
* @param {HTMLElement} container single document node
*/
function GoogleMapConstructor(container) {
this.container = container;
this.markers = [];
this.bounds = new google.maps.LatLngBounds();
this.settings = {
zoom: parseInt(getAttr(container, 'zoom')),
styles: JSON.parse(getAttr(container, 'style') || false),
zoomControl: getAttr(container, 'zoom-control'),
streetViewControl: getAttr(container, 'street-view-control'),
rotateControl: getAttr(container, 'rotate-control'),
scaleControl: getAttr(container, 'scale-control'),
fullscreenControl: getAttr(container, 'fullscreen-control'),
panControl: getAttr(container, 'pan-control'),
disableDoubleClickZoom: getAttr(container, 'double-click-zoom') === false,
draggable: getAttr(container, 'draggable'),
keyboardShortcuts: getAttr(container, 'keyboard-shortcuts'),
scrollwheel: getAttr(container, 'scrollwheel'),
mapTypeId: google.maps.MapTypeId[getAttr(container, 'map-type-control')],
center: {
lat: parseFloat(getAttr(container, 'lat')) || 0,
lng: parseFloat(getAttr(container, 'lng')) || 0
}
};
var mapContainer = container.getElementsByClassName('js-djangocms-googlemap-container');
var markers = container.getElementsByClassName('js-djangocms-googlemap-marker');
var routes = container.getElementsByClassName('js-djangocms-googlemap-route');
// create iterable arrays
markers = [].slice.call(markers);
routes = [].slice.call(routes);
// init the map
this.map = new google.maps.Map(mapContainer[0], this.settings);
// the markers and routes need to be loaded after the map has been
// initialised as we need to access ``this.map``
if (markers.length) {
this.addMarkers(markers);
}
if (routes.length) {
this.addRoutes(routes);
}
}
// attach methods
GoogleMapConstructor.prototype = {
/**
* Processes a collection of markers and passes to ``addMarker``.
*
* @method addMarkers
* @param {Array} markers collection of marker nodes
*/
addMarkers: function addMarkers(markers) {
var list = markers.map(function (marker) {
return {
admin: getAttr(marker, 'admin'),
title: getAttr(marker, 'title'),
address: getAttr(marker, 'address'),
lat: getAttr(marker, 'lat'),
lng: getAttr(marker, 'lng'),
icon: getAttr(marker, 'icon'),
showContent: getAttr(marker, 'show-content'),
content: marker.innerHTML,
animation: google.maps.Animation.DROP
}
}, this);
list.forEach(function (marker) {
this.addMarker(marker);
}, this);
},
/**
* Processes a single marker and attaches to ``this.map``.
*
* @method addMarker
* @param {HTMLElement} marker single marker node
*/
addMarker: function addMarker(marker) {
var that = this;
var latLng = {
lat: parseFloat(marker.lat),
lng: parseFloat(marker.lng)
};
var geocoder = new google.maps.Geocoder();
var pin;
var coords;
// if there is no manual latlng defined, start geocoder
if (!latLng.lat || !latLng.lng) {
geocoder.geocode({ address: marker.address }, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
coords = results[0].geometry.location;
marker.lat = coords.lat();
marker.lng = coords.lng();
that.addMarker(marker);
}
});
} else {
// marker data is ready, add to map
marker.position = latLng;
marker.map = this.map;
pin = new google.maps.Marker(marker);
// updated related components
pin.setMap(this.map);
this.markers.push(pin);
this.bounds.extend(pin.position);
this._addInfoWindow(pin);
this._addEditing(pin);
}
// call update every time a new marker has been added
if (this.map) {
this.update();
}
},
/**
* Update map position and bounds.
*
* @method update
*/
update: function update() {
google.maps.event.addListenerOnce(this.map, 'bounds_changed',
function () {
if (this.map.getZoom() > this.settings.zoom) {
this.map.setZoom(this.settings.zoom);
}
}.bind(this));
this.map.fitBounds(this.bounds);
},
/**
* Processes a collection of routes and passes to ``addRoute``.
* Only one route can be displayed by the default Google Maps
* interface. Feel free to use this functionality to enhance the
* default UI with more route options.
*
* @method addRoutes
* @param {Array} routes collection of route nodes
*/
addRoutes: function addRoutes(routes) {
routes.forEach(function (route) {
this.addRoute(route);
}, this);
},
/**
* Processes a single route and attaches to ``this.map``.
*
* @method addRoute
* @param {HTMLElement} route single route node
*/
addRoute: function addRoute(route) {
var that = this;
var el = 'js-djangocms-googlemap-direction';
var directions = route.getElementsByClassName(el);
var title = getAttr(route, 'title');
var request = {
origin: getAttr(route, 'origin'),
destination: getAttr(route, 'destination'),
travelMode: getAttr(route, 'travel-mode')
};
this.directionsDisplay = new google.maps.DirectionsRenderer();
this.directionsService = new google.maps.DirectionsService();
this.directionsDisplay.setPanel(directions[0]);
this.directionsDisplay.setMap(this.map);
// if origin is not provided ask for your location
if (!request.origin && 'geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(function(position) {
request.origin = position.coords.latitude + ',' + position.coords.longitude;
that.setDirection(request);
});
} else {
that.setDirection(request);
}
},
/**
* Adds the direction to the ``djangocms-googlemap-direction``dom node.
*
* @method setDirection
* @param {Object} request request to be passed to the ``directionsService``
*/
setDirection: function setDirection(request) {
var that = this;
this.directionsService.route(request, function(result, status) {
if (status === 'OK') {
that.directionsDisplay.setDirections(result);
}
});
},
/**
* Attaches the GoogleMap info window to the marker pin.
*
* @method _addInfoWindow
* @private
* @param {Object} marker google map marker node
*/
_addInfoWindow: function _addInfoWindow(marker) {
if (marker.content.trim() === '') {
return false;
}
var that = this;
var infoWindow = new google.maps.InfoWindow({
disableAutoPan: true,
content: marker.content
});
google.maps.event.addListener(marker, 'click', function () {
infoWindow.open(that.map, marker);
marker.setAnimation(google.maps.Animation.BOUNCE);
// stop animation after a certain timeframe
setTimeout(function () {
marker.setAnimation(null);
}, 750);
});
if (marker.showContent) {
infoWindow.open(this.map, marker);
}
},
/**
* Adds double-clock to edit on the google map pin.
*
* @method _addEditing
* @private
* @param {Object} marker google map marker node
*/
_addEditing: function _addEditing(marker) {
// attach double-click to edit for markers
if (window.CMS && window.CMS.Modal) {
google.maps.event.addListener(marker, 'dblclick', function (e) {
// the native event in google.maps is stored in e.xa
// there's no need to continue if google decides to rename it
if (!e.xa) {
return false;
}
e.xa.stopPropagation();
var modal = new CMS.Modal();
modal.open({
url: marker.admin
});
});
}
}
};
return GoogleMapConstructor;
})();
// make sure google maps is loaded after our dom is ready
window.addEventListener('load', function () {
var elements = document.getElementsByClassName('js-djangocms-googlemap');
elements = [].slice.call(elements);
elements.forEach(function (element) {
new GoogleMap(element);
}, this);
});
})();

@ -1,26 +0,0 @@
{% extends "admin/change_form.html" %}
{% load i18n djangocms_forms_tags %}
{% block submit_buttons_bottom %}{% endblock %}
{% block object-tools-items %}
{% endblock %}
{% block field_sets %}
{% if original.form_data %}
<fieldset class="module aligned">
{% for field in original.form_data %}
<div class="form-row required {{ field.name}}">
<div>
<label>
{{ field.label }}:
</label>
<p>{{ field|to_html }}</p>
</div>
</div>
{% endfor %}
</fieldset>
{% endif %}
{{ block.super }}
{% endblock %}

@ -1,15 +0,0 @@
{% extends "admin/change_list.html" %}
{% load i18n admin_urls %}
{% block object-tools %}
{% if has_export_permission %}
<ul class="object-tools">
{% block object-tools-items %}
<li>
{% url cl.opts|admin_urlname:'export' as export_url %}
<a href="{{ export_url }}" class="addlink">{% trans "Export Form Submissions" %}</a>
</li>
{% endblock %}
</ul>
{% endif %}
{% endblock %}

@ -1,22 +0,0 @@
{% extends "admin/change_form.html" %}
{% load i18n admin_urls admin_static admin_modify %}
{% block bodyclass %}{{ block.super }} export-form{% endblock %}
{% if not is_popup %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a>
&rsaquo; {% if has_change_permission %}<a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %}
&rsaquo; {% trans 'Export' %} {{ opts.verbose_name|capfirst }}
</div>
{% endblock %}
{% endif %}
{% block submit_buttons_bottom %}
<div class="submit-row">
<input type="submit" value="{% trans 'Export' %}" class="default" name="export" />
</div>
{% endblock %}
Loading…
Cancel
Save