-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from IvanJelicSF/docker
Added sample data for Docker install from Superdesk master
- Loading branch information
Showing
109 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from superdesk.macros import * # noqa | ||
from . import replace_words # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# -*- coding: utf-8; -*- | ||
# | ||
# This file is part of Superdesk. | ||
# | ||
# Copyright 2013, 2014 Sourcefabric z.u. and contributors. | ||
# | ||
# For the full copyright and license information, please see the | ||
# AUTHORS and LICENSE files distributed with this source code, or | ||
# at https://www.sourcefabric.org/superdesk/license | ||
|
||
import re | ||
|
||
from superdesk import get_resource_service | ||
from superdesk.macros import macro_replacement_fields | ||
|
||
|
||
def find_and_replace(item, **kwargs): | ||
""" | ||
Find and replace words | ||
:param dict item: | ||
:param kwargs: | ||
:return tuple(dict, dict): tuple of modified item and diff of items modified. | ||
""" | ||
diff = {} | ||
|
||
def repl(new, old): | ||
""" | ||
Returns a version of the "new" string that matches the case of the "old" string | ||
:param new: | ||
:param old: | ||
:return: a string which is a version of "new" that matches the case of old. | ||
""" | ||
if old.islower(): | ||
return new.lower() | ||
elif old.isupper(): | ||
return new.upper() | ||
else: | ||
# the old string starts with upper case so we use the title function | ||
if old[:1].isupper(): | ||
return new.title() | ||
# it is more complex so try to match it | ||
else: | ||
result = '' | ||
all_upper = True | ||
for i, c in enumerate(old): | ||
if i >= len(new): | ||
break | ||
if c.isupper(): | ||
result += new[i].upper() | ||
else: | ||
result += new[i].lower() | ||
all_upper = False | ||
# append any remaining characters from new | ||
if all_upper: | ||
result += new[i + 1:].upper() | ||
else: | ||
result += new[i + 1:].lower() | ||
return result | ||
|
||
def do_find_replace(input_string, words_list): | ||
found_list = {} | ||
for word in words_list: | ||
pattern = r'{}'.format(re.escape(word.get('existing', ''))) | ||
|
||
while re.search(pattern, input_string, flags=re.IGNORECASE): | ||
# get the original string from the input | ||
original = re.search(pattern, input_string, flags=re.IGNORECASE).group(0) | ||
replacement = repl(word.get('replacement', ''), original) | ||
if found_list.get(original): | ||
break | ||
diff[original] = replacement | ||
found_list[original] = replacement | ||
input_string = input_string.replace(original, replacement) | ||
|
||
return input_string | ||
|
||
vocab = get_resource_service('vocabularies').find_one(req=None, _id='replace_words') | ||
|
||
if vocab: | ||
replace_words_list = vocab.get('items') or [] | ||
|
||
if not replace_words_list: | ||
return item | ||
|
||
for field in macro_replacement_fields: | ||
if not item.get(field, None): | ||
continue | ||
|
||
item[field] = do_find_replace(item[field], replace_words_list) | ||
|
||
return item | ||
|
||
|
||
name = 'Replace_Words' | ||
label = 'Replace words in the article' | ||
order = 1 | ||
shortcut = 'a' | ||
callback = find_and_replace | ||
access_type = 'frontend' | ||
action_type = 'direct' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% for year, year_group in items|groupby('planning_date.year') %} | ||
{% for month, month_group in year_group|groupby('planning_date.month') %} | ||
{% for day, day_group in month_group|groupby('planning_date.day') %} | ||
{% set weekday = day_group[0].planning_date.strftime('%A') %} | ||
{% if weekday == 'Monday' %}<h2>Monday {{day}}/{{month}}</h2>{% endif %} | ||
{% if weekday == 'Tuesday' %}<h2>Tuesday {{day}}/{{month}}</h2>{% endif %} | ||
{% if weekday == 'Wednesday' %}<h2>Wednesday {{day}}/{{month}}</h2>{% endif %} | ||
{% if weekday == 'Thursday' %}<h2>Thursday {{day}}/{{month}}</h2>{% endif %} | ||
{% if weekday == 'Friday' %}<h2>Friday {{day}}/{{month}}</h2>{% endif %} | ||
{% if weekday == 'Saturday' %}<h2>Saturday {{day}}/{{month}}</h2>{% endif %} | ||
{% if weekday == 'Sunday' %}<h2>Sunday {{day}}/{{month}}</h2>{% endif %} | ||
{% for item in day_group %} | ||
<h2>{{ item.name or item.headline or item.slugline }}</h2> | ||
<p>{{ item.description_text or '' }} | ||
{% if item.get('event', {}).get('location') %} | ||
Location: {{ item.event.location[0].name }}. | ||
{% endif %} | ||
{% if item.get('planning_date', '') != '' | ||
and item.get('planning_date', '') | format_datetime(date_format='%H:%M') != '00:00' %} | ||
Time: {{ item.planning_date | format_datetime(date_format='%H:%M') }}. | ||
{% endif %} | ||
</p> | ||
{% if item.get('ednote', '') != '' %} | ||
<p>Editorial note: {{ item.ednote }}</p> | ||
{% endif %} | ||
{% if item.coverages %} | ||
<p>Coverage(s): {{ item.coverages | join(', ') }}</p> | ||
{% endif %} | ||
<p></p> | ||
{% endfor %} | ||
{% endfor %} | ||
{% endfor %} | ||
{% endfor %} |