Skip to content

Commit

Permalink
global: changes for v3.4
Browse files Browse the repository at this point in the history
- closes #223
- closes #224
  • Loading branch information
ntarocco committed May 15, 2020
1 parent 7ce93c0 commit 8a2580c
Show file tree
Hide file tree
Showing 18 changed files with 188 additions and 97 deletions.
2 changes: 1 addition & 1 deletion {{cookiecutter.project_shortname}}/Pipfile
Expand Up @@ -6,7 +6,7 @@ name = "pypi"
[packages]
Babel = ">=2.4.0"
Flask-BabelEx = ">=0.9.3"
invenio = { version = ">=3.2.0,<3.3.0", extras = ["base", "auth", "metadata", "files", "{{ cookiecutter.database }}", "elasticsearch{{ cookiecutter.elasticsearch }}" ]}
invenio = { version = ">=3.4.0a1,<3.5.0", extras = ["base", "auth", "metadata", "files", "{{ cookiecutter.database }}", "elasticsearch{{ cookiecutter.elasticsearch }}" ]}
lxml = ">=3.5.0,<4.2.6"
marshmallow = ">=3.0.0,<4.0.0"
uwsgi = ">=2.0"
Expand Down
19 changes: 13 additions & 6 deletions {{cookiecutter.project_shortname}}/scripts/bootstrap
Expand Up @@ -6,13 +6,20 @@ set -e
script_path=$(dirname "$0")
pipfile_lock_path="$script_path/../Pipfile.lock"

if [ ! -f $pipfile_lock_path ]; then
echo "'Pipfile.lock' not found. Generating via 'pipenv lock --dev'..."
pipenv lock --dev
fi
# START: PUT ME BACK
# if [ ! -f $pipfile_lock_path ]; then
# echo "'Pipfile.lock' not found. Generating via 'pipenv lock --dev'..."
# pipenv lock --dev
# fi

# # Installs all packages specified in Pipfile.lock
# pipenv sync --dev
# /END: PUT ME BACK

# START: REMOVE ME
pipenv run pip install -e git+https://github.com/inveniosoftware/invenio.git#egg=invenio["base","auth","metadata","files","postgresql","elasticsearch7"]
# /END: REMOVE ME

# Installs all packages specified in Pipfile.lock
pipenv sync --dev
# Install application code and entrypoints from 'setup.py'
pipenv run pip install -e $script_path/..
# Build assets
Expand Down
1 change: 1 addition & 0 deletions {{cookiecutter.project_shortname}}/setup.py
Expand Up @@ -46,6 +46,7 @@
],
'invenio_assets.webpack': [
'{{ cookiecutter.package_name }}_theme = {{ cookiecutter.package_name }}.theme.webpack:theme',
'{{ cookiecutter.package_name }}_search_app = {{ cookiecutter.package_name }}.records.webpack:search_app',
],
'invenio_config.module': [
'{{ cookiecutter.package_name }} = {{ cookiecutter.package_name }}.config',
Expand Down
Expand Up @@ -51,7 +51,9 @@ def _(x):

# Theme configuration
# ===================
#: Site name
#: The Invenio theme.
APP_THEME = ['semantic-ui']
#: Site name.
THEME_SITENAME = _('{{cookiecutter.project_name}}')
#: Use default frontpage.
THEME_FRONTPAGE = True
Expand Down Expand Up @@ -169,7 +171,6 @@ def _(x):
APP_DEFAULT_SECURE_HEADERS['content_security_policy'] = {
'default-src': ["'self'", "'unsafe-inline'"],
'object-src': ["'none'"],
'style-src': ["'self'", "'unsafe-inline'"],
'font-src': ["'self'", "data:", "https://fonts.gstatic.com",
"https://fonts.googleapis.com"],
'style-src': ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com"],
'font-src': ["'self'", "data:", "https://fonts.gstatic.com"],
}
@@ -0,0 +1,84 @@
{%- include 'misc/header.js' %}{%- raw %}
import React from "react";
import { overrideStore } from "react-overridable";
import { Card, Input, Item, List } from "semantic-ui-react";

const {% endraw -%}{{cookiecutter.datamodel_extension_class}}{%- raw %}ResultsListItem = ({ result, index }) => {
const contributors = result.metadata.contributors || [];
return (
<Item key={index} href={`/records/${result.id}`}>
<Item.Content>
<Item.Header>{result.metadata.title}</Item.Header>
<Item.Description>
{contributors && (
<List horizontal relaxed>
{contributors.map((contributor, idx) => (
<List.Item key={idx}>{contributor.name}</List.Item>
))}
</List>
)}
</Item.Description>
</Item.Content>
</Item>
);
};

overrideStore.add("ResultsList.item", {% endraw -%}{{cookiecutter.datamodel_extension_class}}{%- raw %}ResultsListItem);

const {% endraw -%}{{cookiecutter.datamodel_extension_class}}{%- raw %}ResultsGridItem = ({ result, index }) => {
const contributors = result.metadata.contributors || [];
return (
<Card fluid key={index} href={`/records/${result.id}`}>
<Card.Content>
<Card.Header>{result.metadata.title}</Card.Header>
<Card.Description>
{contributors && (
<List horizontal relaxed>
{contributors.map((contributor, idx) => (
<List.Item key={idx}>{contributor.name}</List.Item>
))}
</List>
)}
</Card.Description>
</Card.Content>
</Card>
);
};

overrideStore.add("ResultsGrid.item", {% endraw -%}{{cookiecutter.datamodel_extension_class}}{%- raw %}ResultsGridItem);

const {% endraw -%}{{cookiecutter.datamodel_extension_class}}{%- raw %}SearchBarElement = ({
placeholder: passedPlaceholder,
queryString,
onInputChange,
executeSearch,
}) => {
const placeholder = passedPlaceholder || "Search";
const onBtnSearchClick = () => {
executeSearch();
};
const onKeyPress = (event) => {
if (event.key === "Enter") {
executeSearch();
}
};
return (
<Input
action={{
icon: "search",
onClick: onBtnSearchClick,
color: "orange",
className: "invenio-theme-search-button",
}}
placeholder={placeholder}
onChange={(event, { value }) => {
onInputChange(value);
}}
value={queryString}
onKeyPress={onKeyPress}
/>
);
};

overrideStore.add("SearchBar.element", {% endraw -%}{{cookiecutter.datamodel_extension_class}}{%- raw %}SearchBarElement);
{% endraw %}
Expand Up @@ -78,8 +78,7 @@ def _(x):
)
"""Records UI for {{cookiecutter.project_shortname}}."""

SEARCH_UI_JSTEMPLATE_RESULTS = 'templates/records/results.html'
"""Result list template."""
SEARCH_UI_SEARCH_TEMPLATE = 'records/search.html'

PIDSTORE_RECID_FIELD = '{{ cookiecutter.datamodel_pid_name }}'

Expand Down
Expand Up @@ -34,8 +34,8 @@ def init_config(self, app):
for k in dir(config):
if k.startswith('{{ cookiecutter.package_name | upper }}_'):
app.config.setdefault(k, getattr(config, k))
elif k == 'SEARCH_UI_JSTEMPLATE_RESULTS':
app.config['SEARCH_UI_JSTEMPLATE_RESULTS'] = getattr(
elif k == 'SEARCH_UI_SEARCH_TEMPLATE':
app.config['SEARCH_UI_SEARCH_TEMPLATE'] = getattr(
config, k)
elif k == 'PIDSTORE_RECID_FIELD':
app.config['PIDSTORE_RECID_FIELD'] = getattr(config, k)
Expand Down

This file was deleted.

@@ -1,7 +1,8 @@
{% include 'misc/header.tpl' -%}{% raw %}
{%- extends config.RECORDS_UI_BASE_TEMPLATE %}
{%- include 'misc/header.tpl' -%}
{%- raw -%}
{% extends config.RECORDS_UI_BASE_TEMPLATE %}

{% from 'invenio_previewer/macros.html' import file_list, preview_file %}
{#{% from 'semantic-ui/invenio_previewer/macros.html' import file_list, preview_file %}#}

{%- macro record_content(data) %}
{% set ignore_list = ['_bucket', '$schema'] %}
Expand Down Expand Up @@ -32,7 +33,7 @@
{% endfor %}
{%- endmacro %}

{% macro preview(files) %}
{#{% macro preview(files) %}}
{% set selected_file = files|select_preview_file %}
{%- if selected_file -%}
<div class="panel" id="preview">
Expand All @@ -48,22 +49,22 @@
</div>
</div>
{%- endif %}
{%- endmacro %}
{%- endmacro %}#}

{%- block page_body %}
<div class="container">
<div class="ui container">
<h2>{{record.title}}</h2>
<div class="panel panel-default">
<ul class="list-group">
{{ record_content(record) }}
</ul>
</div>
{% set files = record._files %}
{#{% set files = record._files %}
{{ preview(files) }}
{%- if files -%}
{{ file_list(files, pid) }}
{%- endif %}
{%- endif %}#}
</div>
{{ webpack['{%- endraw %}{{cookiecutter.project_shortname}}{%- raw %}-preview.js'] }}
{{ webpack['{%- endraw -%}{{cookiecutter.project_shortname}}{%- raw -%}-preview.js'] }}
{%- endblock %}
{% endraw %}
{%- endraw -%}
@@ -0,0 +1,8 @@
{%- include 'misc/header.tpl' -%}
{%- raw -%}
{%- extends "semantic-ui/invenio_search_ui/search.html" %}

{% block javascript_searchapp_customization %}
{{ webpack['{%- endraw -%}{{cookiecutter.project_shortname}}{%- raw -%}-search-app.js'] }}
{% endblock javascript_searchapp_customization %}
{%- endraw -%}
@@ -0,0 +1,23 @@
{% include 'misc/header.py' %}
"""JS/CSS Webpack bundle to override search results template."""

from invenio_assets.webpack import WebpackThemeBundle

search_app = WebpackThemeBundle(
__name__,
'assets',
default='semantic-ui',
themes={
'semantic-ui': dict(
entry={
'{{ cookiecutter.project_shortname }}-search-app': './js/{{ cookiecutter.package_name }}/search_app_customizations.js',
},
dependencies={
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-overridable": "^0.0.2",
"semantic-ui-react": "^0.88.0"
}
)
}
)

This file was deleted.

This file was deleted.

@@ -1,3 +1,5 @@
{% include 'misc/header.js' -%}
{%- raw %}
import $ from "jquery";

$("#files")
Expand All @@ -6,3 +8,4 @@ $("#files")
$("#preview").show();
$("#preview-iframe").attr("src", $(event.target).data("url"));
});
{%- endraw %}
@@ -0,0 +1,15 @@
{%- include 'misc/header.tpl' -%}
{%- raw -%}
{%- extends "semantic-ui/invenio_theme/frontpage.html" %}

{% block page_body %}
<div class="ui container grid">
<div class="row">
<div class="column">
{%- endraw -%}
<h1 class="ui header centered">Welcome to {{cookiecutter.project_name}}.</h1>
{%- raw -%}
</div>
</div>
{% endblock %}
{%- endraw -%}
@@ -1,13 +1,14 @@
{% include 'misc/header.jinja2' %}
{%- raw %}
{%- extends "invenio_theme/page.html" %}
{%- include 'misc/header.tpl' -%}
{%- raw -%}
{%- extends "semantic-ui/invenio_theme/page.html" %}

{%- block css %}
{{ webpack['{%- endraw %}{{cookiecutter.project_shortname}}{%- raw %}-theme.css'] }}
{% block css %}
{{ super() }}
{#{{ webpack['{%- endraw -%}{{cookiecutter.project_shortname}}{%- raw -%}-theme.css'] }}#}
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
{%- endblock %}
{%- endraw %}
{% endblock %}
{%- endraw -%}

This file was deleted.

@@ -1,18 +1,21 @@
{% include 'misc/header.py' %}
"""JS/CSS Webpack bundles for theme."""

from __future__ import absolute_import, print_function
from invenio_assets.webpack import WebpackThemeBundle

from flask_webpackext import WebpackBundle

theme = WebpackBundle(
theme = WebpackThemeBundle(
__name__,
'assets',
entry={
'{{ cookiecutter.project_shortname }}-theme': './scss/{{ cookiecutter.package_name }}/theme.scss',
'{{ cookiecutter.project_shortname }}-preview': './js/{{ cookiecutter.package_name }}/previewer.js',
},
dependencies={
# add any additional npm dependencies here...
default='semantic-ui',
themes={
'semantic-ui': dict(
entry={
# CHANGE ME TO LESS '{{ cookiecutter.project_shortname }}-theme': './less/{{ cookiecutter.package_name }}/theme.less',
'{{ cookiecutter.project_shortname }}-preview': './js/{{ cookiecutter.package_name }}/previewer.js',
},
dependencies={
# add any additional npm dependencies here...
}
)
}
)

0 comments on commit 8a2580c

Please sign in to comment.