master
David Beltra 4 years ago
commit 22a0d7672c

40
.gitignore vendored

@ -0,0 +1,40 @@
#bower_components
node_modules
# Ignore automatically generated cruft
*.log
.sass-cache
# Operating system files
.Spotlight-V100
.Trashes
.DS_Store
.DS_Store?
ehthumbs.db
Thumbs.db
#PYC
*.pyc
#VIRTUALENV
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# django static (collected by django)
/static
#local db, must run migrations on production to sync
dev.db
#credentials
credentials.sh
#local settings
**/local_settings.py
**/local_urls.py

@ -0,0 +1,43 @@
from copy import deepcopy
from django.contrib import admin
from mezzanine.core.admin import ContentTypedAdmin
from mezzanine.pages.admin import PageAdmin
from apps.components.icon.models import Icon
from apps.components.button.models import Button
from .models import ContentBlock, HomeBlock, AddressBlock
class IconInline(admin.StackedInline):
model = Icon
extra = 0
class ButtonInline(admin.StackedInline):
model = Button
extra = 0
class ContentBlockAdmin(PageAdmin, ContentTypedAdmin):
inlines = [
IconInline,
ButtonInline,
]
admin.site.register(ContentBlock, ContentBlockAdmin)
class HomeBlockAdmin(PageAdmin, ContentTypedAdmin):
inlines = [
ButtonInline,
]
admin.site.register(HomeBlock, HomeBlockAdmin)
class AddressBlockAdmin(PageAdmin, ContentTypedAdmin):
pass
admin.site.register(AddressBlock, AddressBlockAdmin)

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-04 12:53
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import mezzanine.core.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
('pages', '0004_auto_20170411_0504'),
]
operations = [
migrations.CreateModel(
name='ContentBlock',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='pages.Page')),
('content', mezzanine.core.fields.RichTextField(verbose_name='Content')),
('background', models.ImageField(blank=True, upload_to='backgrounds', verbose_name='Background')),
],
options={
'ordering': ('_order',),
},
bases=('pages.page', models.Model),
),
migrations.CreateModel(
name='HomeBlock',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='pages.Page')),
('content', mezzanine.core.fields.RichTextField(verbose_name='Content')),
('image', models.ImageField(blank=True, upload_to='images', verbose_name='Image')),
],
options={
'ordering': ('_order',),
},
bases=('pages.page', models.Model),
),
]

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-06 08:32
from __future__ import unicode_literals
from django.db import migrations, models
import mezzanine.core.fields
class Migration(migrations.Migration):
dependencies = [
('blocks', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='homeblock',
name='button_text_1',
field=mezzanine.core.fields.RichTextField(blank=True, max_length=500, null=True, verbose_name='Button text 1'),
),
migrations.AddField(
model_name='homeblock',
name='button_text_2',
field=mezzanine.core.fields.RichTextField(blank=True, max_length=500, null=True, verbose_name='Button text 2'),
),
migrations.AddField(
model_name='homeblock',
name='header',
field=models.CharField(blank=True, max_length=500, null=True, verbose_name='Header'),
),
migrations.AddField(
model_name='homeblock',
name='providers',
field=mezzanine.core.fields.RichTextField(blank=True, max_length=500, null=True, verbose_name='Providers'),
),
]

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-06 09:00
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('blocks', '0002_auto_20180906_0832'),
]
operations = [
migrations.RemoveField(
model_name='homeblock',
name='content',
),
]

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-06 12:34
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import mezzanine.core.fields
class Migration(migrations.Migration):
dependencies = [
('pages', '0004_auto_20170411_0504'),
('blocks', '0003_remove_homeblock_content'),
]
operations = [
migrations.CreateModel(
name='AddressBlock',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='pages.Page')),
('map_left', models.CharField(blank=True, help_text='https://www.openstreetmap.org/export', max_length=500, null=True, verbose_name='Map left')),
('map_top', models.CharField(blank=True, max_length=500, null=True, verbose_name='Map top')),
('map_right', models.CharField(blank=True, max_length=500, null=True, verbose_name='Map right')),
('map_bottom', models.CharField(blank=True, max_length=500, null=True, verbose_name='Map bottom')),
('marker_lat', models.CharField(blank=True, max_length=500, null=True, verbose_name='Marker Latitude')),
('marker_long', models.CharField(blank=True, max_length=500, null=True, verbose_name='Marker Longitude')),
('image', models.ImageField(blank=True, upload_to='images', verbose_name='Image')),
('company', models.CharField(blank=True, max_length=500, null=True, verbose_name='Company')),
('address', mezzanine.core.fields.RichTextField(blank=True, max_length=500, null=True, verbose_name='Address')),
('text_description', mezzanine.core.fields.RichTextField(blank=True, max_length=500, null=True, verbose_name='Description')),
],
options={
'ordering': ('_order',),
},
bases=('pages.page',),
),
]

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-06 13:02
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('blocks', '0004_addressblock'),
]
operations = [
migrations.RenameField(
model_name='homeblock',
old_name='button_text_1',
new_name='text_1',
),
migrations.RenameField(
model_name='homeblock',
old_name='button_text_2',
new_name='text_2',
),
]

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-06 13:06
from __future__ import unicode_literals
from django.db import migrations
import mezzanine.core.fields
class Migration(migrations.Migration):
dependencies = [
('blocks', '0005_auto_20180906_1302'),
]
operations = [
migrations.RemoveField(
model_name='homeblock',
name='text_1',
),
migrations.RemoveField(
model_name='homeblock',
name='text_2',
),
migrations.AddField(
model_name='homeblock',
name='text_10',
field=mezzanine.core.fields.RichTextField(blank=True, max_length=500, null=True, verbose_name='Text 1'),
),
migrations.AddField(
model_name='homeblock',
name='text_20',
field=mezzanine.core.fields.RichTextField(blank=True, max_length=500, null=True, verbose_name='Text 2'),
),
]

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-06 13:07
from __future__ import unicode_literals
from django.db import migrations
import mezzanine.core.fields
class Migration(migrations.Migration):
dependencies = [
('blocks', '0006_auto_20180906_1306'),
]
operations = [
migrations.RenameField(
model_name='homeblock',
old_name='text_10',
new_name='text_1',
),
migrations.RenameField(
model_name='homeblock',
old_name='text_20',
new_name='text_2',
),
migrations.RemoveField(
model_name='homeblock',
name='providers',
),
migrations.AddField(
model_name='homeblock',
name='text_3',
field=mezzanine.core.fields.RichTextField(blank=True, max_length=500, null=True, verbose_name='Text 3'),
),
]

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-07 08:19
from __future__ import unicode_literals
from django.db import migrations
import mezzanine.core.fields
class Migration(migrations.Migration):
dependencies = [
('blocks', '0007_auto_20180906_1307'),
]
operations = [
migrations.AlterField(
model_name='addressblock',
name='address',
field=mezzanine.core.fields.RichTextField(blank=True, null=True, verbose_name='Address'),
),
migrations.AlterField(
model_name='addressblock',
name='text_description',
field=mezzanine.core.fields.RichTextField(blank=True, null=True, verbose_name='Description'),
),
migrations.AlterField(
model_name='homeblock',
name='text_1',
field=mezzanine.core.fields.RichTextField(blank=True, null=True, verbose_name='Text 1'),
),
migrations.AlterField(
model_name='homeblock',
name='text_2',
field=mezzanine.core.fields.RichTextField(blank=True, null=True, verbose_name='Text 2'),
),
migrations.AlterField(
model_name='homeblock',
name='text_3',
field=mezzanine.core.fields.RichTextField(blank=True, null=True, verbose_name='Text 3'),
),
]

@ -0,0 +1,45 @@
from django.db import models
from mezzanine.core.models import RichText
from mezzanine.pages.models import Page
from django.utils.translation import ugettext, ugettext_lazy as _
from mezzanine.core.fields import RichTextField
class ContentBlock(Page, RichText):
background = models.ImageField(
_("Background"), upload_to="backgrounds", blank=True)
class HomeBlock(Page):
image = models.ImageField(_("Image"), upload_to="images", blank=True)
header = models.CharField(
_("Header"), max_length=500, blank=True, null=True)
text_1 = RichTextField(_("Text 1"), blank=True, null=True)
text_2 = RichTextField(_("Text 2"), blank=True, null=True)
text_3 = RichTextField(_("Text 3"), blank=True, null=True)
class AddressBlock(Page):
map_left = models.CharField(_("Map left"), max_length=500, blank=True, null=True,
help_text="https://www.openstreetmap.org/export")
map_top = models.CharField(
_("Map top"), max_length=500, blank=True, null=True)
map_right = models.CharField(
_("Map right"), max_length=500, blank=True, null=True)
map_bottom = models.CharField(
_("Map bottom"), max_length=500, blank=True, null=True)
marker_lat = models.CharField(
_("Marker Latitude"), max_length=500, blank=True, null=True)
marker_long = models.CharField(
_("Marker Longitude"), max_length=500, blank=True, null=True)
image = models.ImageField(_("Image"), upload_to="images", blank=True)
company = models.CharField(
_("Company"), max_length=500, blank=True, null=True)
address = RichTextField(_("Address"), blank=True, null=True)
text_description = RichTextField(_("Description"), blank=True, null=True)

@ -0,0 +1,36 @@
from modeltranslation.translator import translator, TranslationOptions
from mezzanine.core.translation import (
TranslatedDisplayable,
TranslatedRichText,
)
from .models import (
ContentBlock,
HomeBlock,
AddressBlock,
)
class TranslatedContent(TranslatedRichText):
fields = ()
class TranslatedHome(TranslationOptions):
fields = (
'header',
'text_1',
'text_2',
'text_3',
)
class TranslatedAddress(TranslationOptions):
fields = (
'company',
'address',
'text_description',
)
translator.register(ContentBlock, TranslatedContent)
translator.register(HomeBlock, TranslatedHome)
translator.register(AddressBlock, TranslatedAddress)

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-04 12:53
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('blocks', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Button',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.CharField(max_length=500, verbose_name='Text')),
('url', models.CharField(max_length=500, verbose_name='URL')),
('block', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='blocks.ContentBlock')),
],
),
]

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-04 13:03
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('blocks', '0001_initial'),
('button', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='button',
name='home_block',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='blocks.HomeBlock'),
),
]

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-04 13:20
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('button', '0002_button_home_block'),
]
operations = [
migrations.AddField(
model_name='button',
name='info_text',
field=models.CharField(blank=True, max_length=500, null=True, verbose_name='Info text'),
),
]

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-04 13:34
from __future__ import unicode_literals
from django.db import migrations
import mezzanine.core.fields
class Migration(migrations.Migration):
dependencies = [
('button', '0003_button_info_text'),
]
operations = [
migrations.AlterField(
model_name='button',
name='text',
field=mezzanine.core.fields.RichTextField(max_length=500, verbose_name='Text'),
),
]

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-04 13:35
from __future__ import unicode_literals
from django.db import migrations, models
import mezzanine.core.fields
class Migration(migrations.Migration):
dependencies = [
('button', '0004_auto_20180904_1334'),
]
operations = [
migrations.AlterField(
model_name='button',
name='info_text',
field=mezzanine.core.fields.RichTextField(blank=True, max_length=500, null=True, verbose_name='Info text'),
),
migrations.AlterField(
model_name='button',
name='text',
field=models.CharField(max_length=500, verbose_name='Text'),
),
]

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-06 08:46
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('button', '0005_auto_20180904_1335'),
]
operations = [
migrations.RemoveField(
model_name='button',
name='info_text',
),
]

@ -0,0 +1,13 @@
from django.db import models
from apps.blocks.models import ContentBlock, HomeBlock
from django.utils.translation import ugettext, ugettext_lazy as _
from mezzanine.core.fields import RichTextField
class Button(models.Model):
block = models.ForeignKey(
ContentBlock, on_delete=models.CASCADE, blank=True, null=True)
home_block = models.ForeignKey(
HomeBlock, on_delete=models.CASCADE, blank=True, null=True)
text = models.CharField(_("Text"), max_length=500)
url = models.CharField(_("URL"), max_length=500)

@ -0,0 +1,11 @@
from modeltranslation.translator import translator, TranslationOptions
from .models import Button
class TranslatedButton(TranslationOptions):
fields = (
'text',
)
translator.register(Button, TranslatedButton)

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-09-04 12:53
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('blocks', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Icon',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('icon', models.ImageField(upload_to='icons', verbose_name='Icon')),
('text', models.CharField(blank=True, max_length=500, verbose_name='Text')),
('block', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='blocks.ContentBlock')),
],
),
]

@ -0,0 +1,10 @@
from django.db import models
from apps.blocks.models import ContentBlock
from django.utils.translation import ugettext, ugettext_lazy as _
class Icon(models.Model):
block = models.ForeignKey(
ContentBlock, on_delete=models.CASCADE, blank=True, null=True)
icon = models.ImageField(_("Icon"), upload_to="icons")
text = models.CharField(_("Text"), max_length=500, blank=True)

@ -0,0 +1,11 @@
from modeltranslation.translator import translator, TranslationOptions
from .models import Icon
class TranslatedIcon(TranslationOptions):
fields = (
'text',
)
translator.register(Icon, TranslatedIcon)

@ -0,0 +1,104 @@
{% extends "pages/richtextpage.html" %}
{% load i18n mezzanine_tags pages_tags %}
{% block main %}
{% editable page.get_content_model.content %}
{{page.get_content_model.content|safe}}
{% endeditable %}
{% nevercache %}
{% if messages %}
{% for message in messages %}
{% if message.extra_tags == 'general' %}
<p class="alert alert-{{ message.level_tag }}">{{message}}</p>
{% endif %}
{% endfor %}
{% endif %}
{% endnevercache %}
<form id="nominations-form" class="mezzanine-form" method="post" action="/nominierungen/">
{% csrf_token %}
<div class="form-group input_id_nominated charfield">
<label class="control-label" for="id_nominated">{% trans "Nominiert wird" %}</label>
<input type="text" name="nominated" maxlength="2000" required="" id="id_nominated">
<p class="help-block">{% trans "Name, Adresse, Tel. Nr, Webseite etc." %}</p>
{% nevercache %}
{% if messages %}
{% for message in messages %}
{% if message.extra_tags == 'nominated' %}
<p class="alert alert-{{ message.level_tag }}">{{message}}</p>
{% endif %}
{% endfor %}
{% endif %}
{% endnevercache %}
</div>
<div class="form-group input_id_reasons_nomination charfield">
<label class="control-label" for="id_reasons_nomination">{% trans "Grund der Nominierung" %}</label>
<textarea name="reasons_nomination" cols="40" rows="10" maxlength="2000" required="" id="id_reasons_nomination" class="input-xlarge"></textarea>
<p class="help-block">{% trans "Begründung; welcher Personenkreis ist von den Eingriffen/der Kontrolle besonders betroffen; Quellen, Presseartikel, Dokumente, URLs" %}</p>
{% nevercache %}
{% if messages %}
{% for message in messages %}
{% if message.extra_tags == 'reasons_nomination' %}
<p class="alert alert-{{ message.level_tag }}">{{message}}</p>
{% endif %}
{% endfor %}
{% endif %}
{% endnevercache %}
</div>
<div class="form-group input_id_name charfield">
<label class="control-label" for="id_name">{% trans "Ihr Name" %}</label>
<input type="text" name="name" maxlength="2000" id="id_name">
</div>
<div class="form-group input_id_email emailfield">
<label class="control-label" for="id_email">{% trans "Ihre E-Mail-Adresse" %}</label>
<input type="email" name="email" id="id_email">
{% nevercache %}
{% if messages %}
{% for message in messages %}
{% if message.extra_tags == 'email' %}
<p class="alert alert-{{ message.level_tag }}">{{message}}</p>
{% endif %}
{% endfor %}
{% endif %}
{% endnevercache %}
</div>
<p>{% trans "Bitte tragen Sie mich in Ihren Newsletter ein:" %}</p>
<span class="subscriptions">
<div class="form-group input_id_sk booleanfield">
<input type="checkbox" name="sk" id="id_sk">
<label class="control-label" for="id_sk">{% trans "Stiftung für Konsumentenschutz" %}</label>
</div>
<div class="form-group input_id_dg booleanfield">
<input type="checkbox" name="dg" id="id_dg">
<label class="control-label" for="id_dg">{% trans "Digitale Gesellschaft" %}</label>
</div>
<div class="form-group input_id_pep booleanfield">
<input type="checkbox" name="pep" id="id_pep">
<label class="control-label" for="id_pep">{% trans "p≡p Foundation" %}</label>
</div>
<div class="form-group input_id_ccc booleanfield">
<input type="checkbox" name="ccc" id="id_ccc">
<label class="control-label" for="id_ccc">{% trans "Chaos Computer Club Schweiz (CCC-CH)" %}</label>
</div>
</span>
<div class="form-actions">
<input class="btn btn-primary btn-lg" type="submit" value="Nominieren">
</div>
</form>
{% endblock %}

@ -0,0 +1,15 @@
from __future__ import unicode_literals
from django.conf import settings
from django.conf.urls import url, include
from . import views
# Trailing slahes for urlpatterns based on setup.
_slash = "/" if settings.APPEND_SLASH else ""
# Blog patterns.
urlpatterns = [
# url(r"^$", views.sendNomination, name="send-nomination"),
]

@ -0,0 +1,72 @@
from django.http import HttpResponseRedirect
from django.contrib import messages
from django.core.mail import send_mail, EmailMessage
from django.utils.translation import ugettext, ugettext_lazy as _
from mezzanine.pages.page_processors import processor_for
from mezzanine.pages.models import Page
import re
EMAIL_REGEX = re.compile(r"[^@]+@[^@]+\.[^@]+")
@processor_for("nominierungen")
def sendNomination(request, page=None):
print('HOLA')
if request.method == 'POST':
print(request.POST)
page = Page.objects.get(slug="nominierungen")
form_valid = True
email = request.POST.get('email')
nominated = request.POST.get('nominated')
reasons_nomination = request.POST.get('reasons_nomination')
# if email != "" and not EMAIL_REGEX.match(email):
if not EMAIL_REGEX.match(email):
form_valid = False
messages.error(request, str(_('Ungültige E-Mail')), extra_tags='email')
if nominated == '':
form_valid = False
messages.error(request, str(_('Pflichtfeld')), extra_tags='nominated')
if reasons_nomination == '':
form_valid = False
messages.error(request, str(_('Pflichtfeld')), extra_tags='reasons_nomination')
if form_valid:
is_valid = True
try:
subject = 'Nomination sumbitted'
message = 'Nominated: ' + nominated + ' Reasons: ' + reasons_nomination
from_email = email
recipient_list = ['dbe@pep.security']
email = EmailMessage(subject, message, from_email, recipient_list)
email.send()
except Exception:
messages.error(request, str(_('Fehler beim Senden des Formulars')), extra_tags='general')
is_valid = False
if request.POST.get('sk') == 'on':
print('email Stiftung für Konsumentenschutz')
if request.POST.get('dg') == 'on':
print('email Digitale Gesellschaft')
if request.POST.get('pep') == 'on':
print('email pEp')
if request.POST.get('ccc') == 'on':
print('email CCC')
if is_valid:
return HttpResponseRedirect('/danke/')
print('MESSAGES:')
print(messages)

@ -0,0 +1,49 @@
from django.contrib.auth.models import Group
def user_readonly(request):
if Group.objects.filter(name="readonly").count() > 0:
readonly_group = Group.objects.get(name="readonly")
if readonly_group in request.user.groups.all():
return True
else:
return False
else:
return False
class ReadOnlyMixin(object):
def get_readonly_fields(self, request, obj=None):
if user_readonly(request):
if obj != None:
print(obj)
all_fields = obj._meta.get_fields(
include_parents=False, include_hidden=False)
all_field_names = []
for field in all_fields:
if field.concrete:
all_field_names.append(field.name)
return all_field_names
else:
return []
def has_add_permission(self, request):
if user_readonly(request):
return False
else:
return True
def has_delete_permission(self, request, obj=None):
if user_readonly(request):
return False
else:
return True
def get_actions(self, request):
actions = super().get_actions(request)
if user_readonly(request):
actions = None
return actions
def __init__(self, *args, **kwargs):
super(ReadOnlyMixin, self).__init__(*args, **kwargs)

@ -0,0 +1,9 @@
from mezzanine.pages.models import Page
def footer(request):
footer_page = Page.objects.get(id=13)
return {'footer_page': footer_page}
def navbar(request):
navbar_page = Page.objects.get(id=11)
return {'navbar_page': navbar_page}

@ -0,0 +1,27 @@
{
"name": "pep",
"description": "",
"main": "index.html",
"authors": [
"jakubwrycza.pl"
],
"license": "ISC",
"homepage": "",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"swiper": "^4.2.2",
"jquery": "^3.3.1",
"masonry-layout": "^4.2.1",
"jquery-i18n": "^1.1.2"
},
"devDependencies": {
"masonry-layout": "^4.2.1",
"jquery-i18n": "^1.1.2"
}
}

@ -0,0 +1,37 @@
{
"name": "jquery-i18n",
"version": "1.1.2",
"homepage": "https://github.com/recurser/jquery-i18n",
"authors": [
"Dave Perrett <hello@daveperrett.com>"
],
"description": "A jQuery plugin for doing client-side translations in javascript.",
"main": "jquery.i18n.js",
"keywords": [
"jquery",
"i18n",
"translation"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"_release": "1.1.2",
"_resolution": {
"type": "version",
"tag": "v1.1.2",
"commit": "401f28b4ed9165689551eac123131b39a0845a37"
},
"_source": "https://github.com/recurser/jquery-i18n.git",
"_target": "^1.1.2",
<<<<<<< HEAD
"_originalSource": "jquery-i18n",
"_direct": true
=======
"_originalSource": "jquery-i18n"
>>>>>>> 067c97801de6912e5313a5f84b465ec9231a0bfb
}

@ -0,0 +1,35 @@
module.exports = function(grunt) {
grunt.initConfig({
meta: {
date: (new Date()).toUTCString()
},
pkg: grunt.file.readJSON('package.json'),
uglify: {
dist: {
src: 'jquery.i18n.js',
dest: 'jquery.i18n.min.js'
}
}
});
grunt.registerTask('build', function() {
var content = grunt.file.read('src/jquery.i18n.js', 'utf-8');
var output = grunt.template.process(content);
grunt.file.write('jquery.i18n.js', output);
grunt.log.ok('File jquery.i18n.js created.');
});
// update bower version
grunt.registerTask('bower', function() {
var pkg = grunt.file.readJSON('package.json');
var bower = grunt.file.readJSON('bower.json');
bower.version = pkg.version;
grunt.file.write('bower.json', JSON.stringify(bower, null, 2));
});
grunt.registerTask('default', ['build', 'uglify']);
grunt.loadNpmTasks('grunt-contrib-uglify');
};

@ -0,0 +1,19 @@
Copyright (c) 2010 Dave Perrett, http://recursive-design.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@ -0,0 +1,159 @@
About
-----
_jQuery-i18n_ is a jQuery plugin for doing client-side translations in javascript. It is based heavily on [javascript i18n that almost doesn't suck](http://markos.gaivo.net/blog/?p=100) by Marko Samastur, and is licensed under the [MIT license](http://www.opensource.org/licenses/mit-license.php).
Installation
------------
You'll need to download the [jQuery library](http://docs.jquery.com/Downloading_jQuery#Current_Release), and include it before _jquery.i18n.js_ in your HTML source. See the _examples_ folder for examples.
This library is also available as a [bower](http://bower.io/) component under the name *jquery-i18n*.
Usage
-----
Before you can do any translation you have to initialise the plugin with a 'dictionary' (basically a property list mapping keys to their translations).
```javascript
var myDictionary = {
"some text": "a translation",
"some more text": "another translation"
}
$.i18n.load(myDictionary);
```
Once you've initialised it with a dictionary, you can translate strings using the $.i18n._() function, for example:
```javascript
$('div#example').text($.i18n._('some text'));
```
or using $('selector')._t() function
```javascript
$('div#example')._t('some text');
```
If you'd like to switch languages, you can unload the current dictionary and load a new one:
```javascript
$.i18n.load('en');
$.i18n.unload();
$.i18n.load('ja');
```
Wildcards
---------
It's straightforward to pass dynamic data into your translations. First, add _%s_ in the translation for each variable you want to swap in :
```javascript
var myDictionary = {
"wildcard example": "We have been passed two values : %s and %s."
}
$.i18n.load(myDictionary);
```
Next, pass values in sequence after the dictionary key when you perform the translation :
```javascript
$('div#example').text($.i18n._('wildcard example', 100, 200));
```
or
```javascript
$('div#example')._t('wildcard example', 100, 200);
```
This will output _We have been passed two values : 100 and 200._
Because some languages will need to order arguments differently to english, you can also specify the order in which the variables appear :
```javascript
var myDictionary = {
"wildcard example": "We have been passed two values : %2$s and %1$s."
}
$.i18n.load(myDictionary);
$('div#example').text($.i18n._('wildcard example', 100, 200));
```
This will output: _We have been passed two values: 200 and 100._
If you need to explicitly output the string _%s_ in your translation, use _%%s_ :
```javascript
var myDictionary = {
"wildcard example": "I have %s literal %%s character."
}
$.i18n.load(myDictionary);
$('div#example').text($.i18n._('wildcard example', 1));
```
This will output: _I have 1 literal %%s character._
Identifying missing translations
---------
When loading the dictionary, you can pass a second `missingPattern` parameter, which will be used to format any missing translations.
```javascript
$.i18n.load({ a_key: 'translated string' }, "{{ %s }}");
// The following line will output '{{ another_key }}'
$.i18n._('another_key')
```
This allows you scan for the given pattern to identify missing translations.
Building From Scratch
---------------------
Use `npm install` to install the dependencies, and `grunt` to run the build.
Change history
-----------
* **Version 1.1.2 (2017-08-11)** : Add an `unload()` method to clear the dictionary, support passing a `missingPattern` when loading the dictionary (thanks to [briantani](https://github.com/briantani)).
* **Version 1.1.1 (2014-01-05)** : Use `html()` instead of `text()` when rendering translations.
* **Version 1.1.0 (2013-12-31)** : Use grunt, update `printf` implementation, `setDictionary` is now `load` (thanks to [ktmud](https://github.com/ktmud)).
* **Version 1.0.1 (2013-10-11)** : Add bower support.
* **Version 1.0.0 (2012-10-14)** : 1.0 release - addition of a test suite (huge thanks to [alexaitken](https://github.com/alexaitken)), plus a major cleanup.
Bug Reports
-----------
If you come across any problems, please [create a ticket](https://github.com/recurser/jquery-i18n/issues) and we'll try to get it fixed as soon as possible.
Contributing
------------
Once you've made your commits:
1. [Fork](http://help.github.com/fork-a-repo/) jquery-i18n
2. Create a topic branch - `git checkout -b my_branch`
3. Push to your branch - `git push origin my_branch`
4. Create a [Pull Request](http://help.github.com/pull-requests/) from your branch
5. That's it!
Author
------
Dave Perrett :: hello@daveperrett.com :: [@daveperrett](http://twitter.com/daveperrett)
Copyright
---------
Copyright (c) 2010 Dave Perrett. See [License](https://github.com/recurser/jquery-i18n/blob/master/LICENSE) for details.

@ -0,0 +1,23 @@
<!doctype html>
<html>
<head>
<title>jasmine-sinon specs</title>
<link rel="stylesheet" href="lib/jasmine-1.2.0/jasmine.css">
<script src="lib/jasmine-1.2.0/jasmine.js"></script>
<script src="lib/jasmine-1.2.0/jasmine-html.js"></script>
<script src="examples/jquery-1.4.2.js"></script>
<script src="src/jquery.i18n.js"></script>
<script src="specs/jquery.i18n.spec.js"></script>
</head>
<body>
<script type="text/javascript">
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
jasmine.getEnv().execute();
</script>
</body>
</html>

@ -0,0 +1,23 @@
{
"name": "jquery-i18n",
"version": "1.1.2",
"homepage": "https://github.com/recurser/jquery-i18n",
"authors": [
"Dave Perrett <hello@daveperrett.com>"
],
"description": "A jQuery plugin for doing client-side translations in javascript.",
"main": "jquery.i18n.js",
"keywords": [
"jquery",
"i18n",
"translation"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

@ -0,0 +1,81 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>jQuery i18n Plugin</title>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="../jquery.i18n.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
i18n_dict = {
"Example 1" : "teiän veen",
"Example 2" : "tei'än ve'en",
"Example 3" : "teiä vede",
"Example 4" : "teirän veren",
"Example 5" : "teilän velen",
"Example 6" : "teijjän vejen",
"Example 7" : "teidän veden",
"Example 8" : "teitän veten",
"Example 9" : "teiðän veðen",
"Example 10" : "teidhän vethen",
"Dynamic Content" : "Your browser window is %s x %s",
"Ordered Dynamic Content" : "%2$s is the height of your browser window, and %1$s is the width.",
"HTML Content" : "Your browser window is <b><i>%s</i></b> x <b><i>%s</i></b>"
};
$.i18n.load(i18n_dict);
$('input#translate_button').click( function(event) {
$('div#example1')._t('Example 1');
$('div#example2')._t('Example 2');
$('div#example3')._t('Example 3');
$('div#example4')._t('Example 4');
$('div#example5')._t('Example 5');
$('div#example6')._t('Example 6');
$('div#example7')._t('Example 7');
$('div#example8')._t('Example 8');
$('div#example9')._t('Example 9');
$('div#example10')._t('Example 10');
$('div#dynamic')._t('Dynamic Content', $(document).width(), $(document).height());
$('div#orderedDynamic')._t('Ordered Dynamic Content', $(document).width(), $(document).height());
$('div#html')._t('HTML Content', $(document).width(), $(document).height());
});
});
</script>
<style type="text/css">
body {
font-size: 30px;
text-align: center;
}
input {
font-size: 30px;
}
p {
font-size: 17px;
}
</style>
<body>
<p>
Click the button to translate the following text into some random Finnish from the
<a href='http://en.wikipedia.org/wiki/Finnish_phonology'>Wikipedia Finnish Phonology Article</a>
</p>
<div id='example1'>Example 1</div>
<div id='example2'>Example 2</div>
<div id='example3'>Example 3</div>
<div id='example4'>Example 4</div>
<div id='example5'>Example 5</div>
<div id='example6'>Example 6</div>
<div id='example7'>Example 7</div>
<div id='example8'>Example 8</div>
<div id='example9'>Example 9</div>
<div id='example10'>Example 10</div>
<div id='dynamic'>Dynamic Content</div>
<div id='orderedDynamic'>Ordered Dynamic Content</div>
<div id='html'>HTML Content</div>
<input type='button' id='translate_button' value='Internationalize!' />
</body>
</html>

@ -0,0 +1,120 @@
/*!
* jQuery i18n plugin
* @requires jQuery v1.1 or later
*
* See https://github.com/recurser/jquery-i18n
*
* Licensed under the MIT license.
*
* Version: 1.1.2 (Fri, 11 Aug 2017 03:52:21 GMT)
*/
(function($) {
/**
* i18n provides a mechanism for translating strings using a jscript dictionary.
*
*/
var __slice = Array.prototype.slice;
/*
* i18n property list
*/
var i18n = {
dict: null,
missingPattern: null,
/**
* load()
*
* Load translations.
*
* @param property_list i18nDict : The dictionary to use for translation.
*/
load: function(i18nDict, missingPattern) {
if (this.dict !== null) {
$.extend(this.dict, i18nDict);
} else {
this.dict = i18nDict;
}
if (missingPattern) {
this.missingPattern = missingPattern;
}
},
/**
* unload()
*
* Unloads translations and clears the dictionary.
*/
unload: function() {
this.dict = null;
this.missingPattern = null;
},
/**
* _()
*
* Looks the given string up in the dictionary and returns the translation if
* one exists. If a translation is not found, returns the original word.
*
* @param string str : The string to translate.
* @param property_list params.. : params for using printf() on the string.
*
* @return string : Translated word.
*/
_: function (str) {
dict = this.dict;
if (dict && dict.hasOwnProperty(str)) {
str = dict[str];
} else if (this.missingPattern !== null) {