Skip to content

Commit

Permalink
i18n, ui changes, model directory can be renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
mesemus committed Jan 14, 2024
1 parent b745166 commit 300289f
Show file tree
Hide file tree
Showing 32 changed files with 59 additions and 45 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "nrp-devtools"
version = "0.1.0"
version = "0.1.2"
description = "NRP repository development tools"
readme = "README.md"
authors = [
Expand Down
1 change: 1 addition & 0 deletions src/nrp_devtools/commands/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def initialize_repository(config: OARepoConfig):
"repository_package": config.repository.repository_package,
"repository_human_name": config.repository.repository_human_name,
"ui_package": config.repository.ui_package,
"model_package": config.repository.model_package,
"oarepo_version": config.repository.oarepo_version,
},
)
Expand Down
6 changes: 3 additions & 3 deletions src/nrp_devtools/commands/ui/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def register_model_ui(config: OARepoConfig, *, ui_name: str):

pyproject.add_entry_point(
"invenio_base.blueprints",
ui_config.name,
f"ui_{ui_config.name}",
f"{config.repository.ui_package}.{ui_config.name}:create_blueprint",
)

pyproject.add_entry_point(
"invenio_assets.webpack",
ui_config.name,
f"{config.repository.ui_package}.{ui_config.name}.theme.webpack:theme",
f"ui_{ui_config.name}",
f"{config.repository.ui_package}.{ui_config.name}.webpack:theme",
)

pyproject.save()
2 changes: 1 addition & 1 deletion src/nrp_devtools/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def shared_dir(self):

@property
def models_dir(self):
return self.repository_dir / "models"
return self.repository_dir / self.repository.model_package

@property
def invenio_instance_path(self):
Expand Down
8 changes: 8 additions & 0 deletions src/nrp_devtools/config/repository_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class RepositoryConfig:
ui_package: str
prompts["ui_package"] = "Python package name of the ui code"

model_package: str = "models"
prompts["model_package"] = "Directory containing model yaml files"

@classmethod
def default_shared_package(cls, config: "OARepoConfig", values):
"""Returns the default site package name based on the project directory name"""
Expand All @@ -38,6 +41,11 @@ def default_ui_package(cls, config: "OARepoConfig", values):
"""Returns the default site package name based on the project directory name"""
return f"ui"

@classmethod
def default_model_package(cls, config: "OARepoConfig", values):
"""Returns the default package name based on the project directory name"""
return f"models"

@classmethod
def default_repository_package(cls, config, values):
"""Returns the default repository package name based on the project directory name"""
Expand Down
1 change: 1 addition & 0 deletions src/nrp_devtools/templates/repository/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"use_oarepo_vocabularies": true,
"site_package": "",
"ui_package": "",
"model_package": "",
"oarepo_version": "12"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"devDependencies": {},
"aliases": {
"@translations/i18next": "translations/i18next.js",
},
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ requires-python = ">=3.9,<3.11"

[project.entry-points."invenio_assets.webpack"]
branding = "{{cookiecutter.ui_package}}.branding.webpack:theme"
{{cookiecutter.shared_package}} = "{{cookiecutter.shared_package}}.assets.webpack:theme"
i18n = "i18n.webpack:theme"

[project.entry-points."invenio_base.blueprints"]
branding = "{{cookiecutter.ui_package}}.branding:create_blueprint"
titlepage = "{{cookiecutter.ui_package}}.titlepage:create_blueprint"

[project.entry-points."invenio_i18n.translations"]
translations = "{{cookiecutter.shared_package}}"
translations = "i18n"


[build-system]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@
@item : 'default';
@statistic : 'default';

{% if cookiecutter.use_oarepo_vocabularies == 'yes' %}

@dl_table: 'default';

{% endif %}

@datepicker : 'default';

/* Custom */

@dl_table: 'default';
/* @my_custom_component : 'default'; */

/*******************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,60 @@
/*--------------------
Site Variables
---------------------*/
/*
Just for debugging purposes
.less-debug-info {
themesFolder: @themesFolder;
siteFolder: @siteFolder;
theme: @theme;
}
Sample output:
.less-debug-info {
themesFolder: '~semantic-ui-less/themes';
siteFolder: '../../less';
theme: 'default';
}
*/

/* the variables defined later in this file take precedence over the ones defined earlier */

/* Default site.variables */
@import '@{themesFolder}/default/globals/site.variables';

/* Packaged site.variables */
@import '@{themesFolder}/@{siteFolder}/globals/site.variables';

/* Component's site.variables */
@import (optional) '@{themesFolder}/@{theme}/globals/site.variables';

/* invenio-theme site.variables */
@import (optional) 'themes/invenio/globals/site.variables';

/* oarepo theme global site.variables */
@import (optional) 'themes/oarepo/globals/site.variables';

/* Site theme site.variables */
/* Site's global site.variables override just global variables */
@import (optional) '@{siteFolder}/globals/site.variables';


/*-------------------
Component Variables
---------------------*/

/* Default */
/* Default theme for a component */
@import (optional) '@{themesFolder}/default/@{type}s/@{element}.variables';

/* Packaged Theme */
/* Packaged Theme for a component */
@import (optional, multiple)
'@{themesFolder}/@{theme}/@{type}s/@{element}.variables';

/* Your components
@import (optional, multiple)
'<libraryName>/${theme}/@{type}s/@{element}.variables';
*/

@import (optional, multiple) '{{cookiecutter.repository_package}}/theme/@{type}s/@{element}.variables';

/* Invenio-theme Theme */
/* Invenio-theme Theme for a component */
@import (optional, multiple) 'themes/invenio/@{type}s/@{element}.variables';

/* oarepo theme */
@import (optional, multiple) 'themes/oarepo/@{type}s/@{element}.variables';
/* Site default theme for a component */
@import (optional, multiple) '@{siteFolder}/default/@{type}s/@{element}.variables';

/* Site packaged theme for a component */
@import (optional, multiple) '@{siteFolder}/@{theme}/@{type}s/@{element}.variables';

/* Site Theme */
@import (optional, multiple) '@{siteFolder}/@{type}s/@{element}.variables';


/*******************************
Expand All @@ -76,18 +85,13 @@
-------------------*/

.loadUIOverrides() {
/* semantic-ui-less css styles for component */
@import (optional, multiple)
'@{themesFolder}/@{theme}/@{type}s/@{element}.overrides';

/* Your components
@import (optional, multiple)
'<libraryName>/theme/@{type}s/@{element}.overrides';
*/

@import (optional, multiple) 'oarepo_ui/theme/@{type}s/@{element}.overrides';
@import (optional, multiple) '{{cookiecutter.repository_package}}/theme/@{type}s/@{element}.overrides';

/* invenio global css styles */
@import (optional, multiple) 'themes/invenio/@{type}s/@{element}.overrides';
@import (optional, multiple) 'themes/oarepo/@{type}s/@{element}.overrides';
@import (optional, multiple) '@{siteFolder}/@{type}s/@{element}.overrides';

/* site theme css style */
@import (optional, multiple) '@{siteFolder}/@{theme}/@{type}s/@{element}.overrides';
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Add your own jinja base templates here (for example, base page template goes here).
Then you can reference them in your templates like this:

{% raw %}
```
{% extends "base.html" %}
```
{% endraw %}

Note: to override the base template within the whole repository (both user and admin apps),
set the `BASE_TEMPLATE="base.html"` variable inside the invenio.cfg file.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"../../less/site": "less/site",
"../../less": "less",
"@less": "less",
"@translations/i18next": "translations/i18next.js",
},
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class {{cookiecutter.resource_config}}(RecordsUIResourceConfig):
template_folder = "../templates"
template_folder = "templates"
url_prefix = "{{cookiecutter.endpoint}}"
blueprint_name = "{{cookiecutter.name}}"
ui_serializer_class = "{{cookiecutter.ui_serializer_class}}"
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

theme = WebpackThemeBundle(
__name__,
"assets",
".",
default="semantic-ui",
themes={
"semantic-ui": dict(
Expand Down

0 comments on commit 300289f

Please sign in to comment.