Skip to content

Commit e4da811

Browse files
HammadYousaf01DawoudSheraz
authored andcommitted
feat: deprecate indigo footer (#181)
* feat: v20.0.1 release (#176) * feat: deprecate indigo footer * feat: migrate from pylint/black to ruff (#180) * feat: migrate from pylint/black to ruff * fix: resolve comments --------- Co-authored-by: Syed Muhammad Dawoud Sheraz Ali <40599381+DawoudSheraz@users.noreply.github.com>
1 parent a5f9cc1 commit e4da811

File tree

6 files changed

+121
-22
lines changed

6 files changed

+121
-22
lines changed

.hatch_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ def update(self, metadata: dict[str, t.Any]) -> None:
1616
def load_about() -> dict[str, str]:
1717
about: dict[str, str] = {}
1818
with open(os.path.join(HERE, "tutorindigo", "__about__.py"), "rt", encoding="utf-8") as f:
19-
exec(f.read(), about) # pylint: disable=exec-used
19+
exec(f.read(), about)
2020
return about

Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
.DEFAULT_GOAL := help
22
.PHONY: docs
33
SRC_DIRS = ./tutorindigo
4-
BLACK_OPTS = --exclude templates ${SRC_DIRS}
54

65
# Warning: These checks are not necessarily run on every PR.
7-
test: test-lint test-types test-format # Run some static checks.
6+
test: test-lint test-types test-format test-pythonpackage # Run some static checks.
87

98
test-format: ## Run code formatting tests
10-
black --check --diff $(BLACK_OPTS)
9+
ruff format --check --diff $(SRC_DIRS)
1110

1211
test-lint: ## Run code linting tests
13-
pylint --errors-only --enable=unused-import,unused-argument --ignore=templates --ignore=docs/_ext ${SRC_DIRS}
12+
ruff check ${SRC_DIRS}
1413

1514
test-types: ## Run type checks.
1615
mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS}
1716

17+
build-pythonpackage: ## Build the "tutor-indigo" python package for upload to pypi
18+
python -m build --sdist
19+
20+
test-pythonpackage: build-pythonpackage ## Test that package can be uploaded to pypi
21+
twine check dist/tutor_indigo-$(shell make version).tar.gz
22+
1823
format: ## Format code automatically
19-
black $(BLACK_OPTS)
24+
ruff format ${SRC_DIRS}
2025

21-
isort: ## Sort imports. This target is not mandatory because the output may be incompatible with black formatting. Provided for convenience purposes.
22-
isort --skip=templates ${SRC_DIRS}
26+
fix-lint: ## Fix lint errors automatically
27+
ruff check --fix ${SRC_DIRS}
2328

2429
changelog-entry: ## Create a new changelog entry.
2530
scriv create
2631

2732
changelog: ## Collect changelog entries in the CHANGELOG.md file.
2833
scriv collect
2934

35+
version: ## Print the current tutor-indigo version
36+
@python -c 'import io, os; about = {}; exec(io.open(os.path.join("tutorindigo", "__about__.py"), "rt", encoding="utf-8").read(), about); print(about["__version__"])'
37+
3038
ESCAPE = 
3139
help: ## Print this help
3240
@grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Improvement] Migrate from pylint and black to ruff. (by @HammadYousaf01)

pyproject.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ dynamic = ["version"]
3232
[project.optional-dependencies]
3333
dev = [
3434
"tutor[dev]>=21.0.0,<22.0.0",
35-
"pylint",
36-
"black"
35+
"ruff",
3736
]
3837

3938
[project.entry-points."tutor.plugin.v1"]
@@ -65,3 +64,19 @@ packages = ["/tutorindigo"]
6564

6665
[tool.hatch.metadata.hooks.custom]
6766
path = ".hatch_build.py"
67+
68+
[tool.ruff]
69+
exclude = ["templates", "docs/_ext"]
70+
71+
[tool.ruff.lint]
72+
# E: pycodestyle errors
73+
# I: isort
74+
# N: pep8-naming
75+
select = ["E", "I", "N"]
76+
77+
# F401: unused-import
78+
# F841: unused-variable
79+
# W292: missing-newline-at-end-of-file
80+
extend-select = ["F401", "F841", "W292"]
81+
82+
[tool.ruff.format]
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
if (typeof useIntl === "undefined") {
2+
const intl = await import("@edx/frontend-platform/i18n");
3+
globalThis.useIntl = intl.useIntl;
4+
}
5+
6+
const IndigoFooter = () => {
7+
const intl = useIntl();
8+
const config = getConfig();
9+
10+
const indigoFooterNavLinks = config.INDIGO_FOOTER_NAV_LINKS || [];
11+
12+
const messages = {
13+
"footer.poweredby.text": {
14+
id: "footer.poweredby.text",
15+
defaultMessage: "Powered by",
16+
description: "text for the footer",
17+
},
18+
"footer.tutorlogo.altText": {
19+
id: "footer.tutorlogo.altText",
20+
defaultMessage: "Runs on Tutor",
21+
description: "alt text for the footer tutor logo",
22+
},
23+
"footer.logo.altText": {
24+
id: "footer.logo.altText",
25+
defaultMessage: "Powered by Open edX",
26+
description: "alt text for the footer logo.",
27+
},
28+
"footer.copyright.text": {
29+
id: "footer.copyright.text",
30+
defaultMessage: `Copyrights ©${new Date().getFullYear()}. All Rights Reserved.`,
31+
description: "copyright text for the footer",
32+
},
33+
};
34+
35+
return (
36+
<div className="wrapper wrapper-footer">
37+
<footer id="footer" className="tutor-container">
38+
<div className="footer-top">
39+
<div className="powered-area">
40+
<ul className="logo-list">
41+
<li>{intl.formatMessage(messages["footer.poweredby.text"])}</li>
42+
<li>
43+
<a
44+
href="https://edly.io/tutor/"
45+
rel="noreferrer"
46+
target="_blank"
47+
></a>
48+
<img
49+
src={`${config.LMS_BASE_URL}/theming/asset/images/tutor-logo.png`}
50+
alt={intl.formatMessage(messages["footer.tutorlogo.altText"])}
51+
width="57"
52+
/>
53+
</li>
54+
<li>
55+
<a href="https://open.edx.org" rel="noreferrer" target="_blank">
56+
<img
57+
src={`${config.LMS_BASE_URL}/theming/asset/images/openedx-logo.png`}
58+
alt={intl.formatMessage(messages["footer.logo.altText"])}
59+
width="79"
60+
/>
61+
</a>
62+
</li>
63+
</ul>
64+
</div>
65+
<nav className="nav-colophon">
66+
<ol>
67+
{indigoFooterNavLinks.map((link) => (
68+
<li key={link.url}>
69+
<a href={`${config.LMS_BASE_URL}${link.url}`}>{link.title}</a>
70+
</li>
71+
))}
72+
</ol>
73+
</nav>
74+
</div>
75+
<span className="copyright-site">
76+
{intl.formatMessage(messages["footer.copyright.text"])}
77+
</span>
78+
</footer>
79+
</div>
80+
);
81+
};

tutorindigo/plugin.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
],
5454
)
5555

56-
# Force the rendering of scss files, even though they are included in a "partials" directory
56+
# Force the rendering of scss files, even though they are included in a
57+
# "partials" directory
5758
hooks.Filters.ENV_PATTERNS_INCLUDE.add_items(
5859
[
5960
r"indigo/lms/static/sass/partials/lms/theme/",
@@ -120,17 +121,10 @@ def _override_openedx_docker_image(
120121
(
121122
f"mfe-dockerfile-post-npm-install-{mfe}",
122123
"""
123-
RUN npm install @edly-io/indigo-frontend-component-footer@^3.0.0
124124
RUN npm install '@edx/frontend-component-header@npm:@edly-io/indigo-frontend-component-header@^5.0.0'
125125
RUN npm install '@edx/brand@github:@edly-io/brand-openedx#ulmo/indigo'
126126
127-
""",
128-
),
129-
(
130-
f"mfe-env-config-runtime-definitions-{mfe}",
131-
"""
132-
const { default: IndigoFooter } = await import('@edly-io/indigo-frontend-component-footer');
133-
""",
127+
""", # noqa: E501
134128
),
135129
]
136130
)
@@ -200,7 +194,7 @@ def _override_openedx_docker_image(
200194
PLUGIN_SLOTS.add_item(
201195
(
202196
mfe,
203-
"footer_slot",
197+
"org.openedx.frontend.layout.footer.v1",
204198
"""
205199
{
206200
op: PLUGIN_OPERATIONS.Hide,
@@ -209,10 +203,10 @@ def _override_openedx_docker_image(
209203
{
210204
op: PLUGIN_OPERATIONS.Insert,
211205
widget: {
212-
id: 'default_contents',
206+
id: 'custom_footer',
213207
type: DIRECT_PLUGIN,
214208
priority: 1,
215-
RenderWidget: <IndigoFooter />,
209+
RenderWidget: IndigoFooter,
216210
},
217211
},
218212
{

0 commit comments

Comments
 (0)