django-material-design-icons 0.0.1.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_material_design_icons-0.0.1.dev1/LICENCE +73 -0
- django_material_design_icons-0.0.1.dev1/PKG-INFO +218 -0
- django_material_design_icons-0.0.1.dev1/README.md +190 -0
- django_material_design_icons-0.0.1.dev1/build.py +66 -0
- django_material_design_icons-0.0.1.dev1/pyproject.toml +91 -0
- django_material_design_icons-0.0.1.dev1/setup.py +35 -0
- django_material_design_icons-0.0.1.dev1/src/django_mdi/__init__.py +3 -0
- django_material_design_icons-0.0.1.dev1/src/django_mdi/icons/__init__.py +0 -0
- django_material_design_icons-0.0.1.dev1/src/django_mdi/icons/default.zip +0 -0
- django_material_design_icons-0.0.1.dev1/src/django_mdi/icons/light.zip +0 -0
- django_material_design_icons-0.0.1.dev1/src/django_mdi/lib.py +157 -0
- django_material_design_icons-0.0.1.dev1/src/django_mdi/py.typed +0 -0
- django_material_design_icons-0.0.1.dev1/src/django_mdi/templatetags/__init__.py +0 -0
- django_material_design_icons-0.0.1.dev1/src/django_mdi/templatetags/material_design_icons.py +148 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
|
|
37
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
+
|
|
39
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
+
|
|
41
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
+
|
|
43
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
|
56
|
+
|
|
57
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
58
|
+
|
|
59
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
60
|
+
|
|
61
|
+
Copyright 2026 IndustrialRabbit
|
|
62
|
+
|
|
63
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
64
|
+
you may not use this file except in compliance with the License.
|
|
65
|
+
You may obtain a copy of the License at
|
|
66
|
+
|
|
67
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
68
|
+
|
|
69
|
+
Unless required by applicable law or agreed to in writing, software
|
|
70
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
71
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
72
|
+
See the License for the specific language governing permissions and
|
|
73
|
+
limitations under the License.
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-material-design-icons
|
|
3
|
+
Version: 0.0.1.dev1
|
|
4
|
+
Summary: Material Design Icon python package primarily for Django applications
|
|
5
|
+
License-File: LICENCE
|
|
6
|
+
Keywords: django,icons,material,material-icons,web,svg
|
|
7
|
+
Author: IndustrialRabbit
|
|
8
|
+
Maintainer: IndustrialRabbit
|
|
9
|
+
Requires-Python: >=3.12,<3.17
|
|
10
|
+
Classifier: Development Status :: 1 - Planning
|
|
11
|
+
Classifier: Environment :: Web Environment
|
|
12
|
+
Classifier: Framework :: Django
|
|
13
|
+
Classifier: Framework :: Django :: 5.2
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.16
|
|
19
|
+
Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
|
|
20
|
+
Classifier: Natural Language :: English
|
|
21
|
+
Classifier: Natural Language :: Spanish
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Provides-Extra: all
|
|
24
|
+
Requires-Dist: django-material-design-icons[dev] ; extra == "all"
|
|
25
|
+
Project-URL: Issues, https://codeberg.org/IndustrialRabbit/django-mdi/issues
|
|
26
|
+
Project-URL: Repository, https://codeberg.org/IndustrialRabbit/django-mdi.git
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# Django MDI
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Package of icons from **Material Design Icons +light** for the web framework **Django**.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
> All icons included in this python package is works of the project [Pictogrammers](https://pictogrammers.com/)'s designers & collaborators, than creating and maintain this icons in a way thats is open and accessible to everyone ♥️.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## 📄 Documentation translations
|
|
39
|
+
|
|
40
|
+
- [Spanish - Español 🇪🇸](./README.es-ES.md)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## 📦 Installation
|
|
44
|
+
|
|
45
|
+
### 🐍 From PyPI
|
|
46
|
+
|
|
47
|
+
This is the common form to install this package:
|
|
48
|
+
|
|
49
|
+
```shell
|
|
50
|
+
pip install django-mdi
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
In case that the PyPI have problems or you need to work offline you can use the next method.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### 🏠 From the repository
|
|
57
|
+
|
|
58
|
+
To install the package from a published version you can execute the next command.
|
|
59
|
+
|
|
60
|
+
```shell
|
|
61
|
+
# Change the 'main' word to the published version that want to install
|
|
62
|
+
$ pip install https://codeberg.org/IndustrialRabbit/django-mdi/archive/main.tar.gz
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
> [!TIP] Council
|
|
67
|
+
> If you can not install online the package you can download first the .tar.gz archive and next execute the pip command without needed internet connection.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
Yo can also installed it using a git-branch name or commit but (_it is not recommended_ 🫣)
|
|
72
|
+
|
|
73
|
+
```shell
|
|
74
|
+
# Change the 'main' word to the branch name or commit that want to install
|
|
75
|
+
pip install git+https://codeberg.org/IndustrialRabbit/django-mdi.git@main
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 📘 Usage manual
|
|
79
|
+
|
|
80
|
+
To usage it you was need to have a Django application created. Next need to go in the Django settings and where you have the `INSTALLED_APPS` add the package key name `"django_mdi"`.
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
INSTALLED_APPS = [
|
|
84
|
+
...
|
|
85
|
+
"django_mdi",
|
|
86
|
+
...
|
|
87
|
+
]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
After registered the python package as Django application, in the same place, you must go to `TEMPLATES` setting and within the `OPTIONS` part add a `builtins` key with the value `"django_mdi.templatetags.material_design_icons"`.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
TEMPLATES = [
|
|
95
|
+
{
|
|
96
|
+
...
|
|
97
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
98
|
+
...
|
|
99
|
+
"OPTIONS": {
|
|
100
|
+
...
|
|
101
|
+
"builtins": [
|
|
102
|
+
...
|
|
103
|
+
"django_mdi.templatetags.material_design_icons",
|
|
104
|
+
...
|
|
105
|
+
],
|
|
106
|
+
...
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
> [!NOTE]
|
|
113
|
+
> It has been tested with the official Django template engine `"django.template.backends.django.DjangoTemplates"`. If you change it ensure that you do not break the functionality.
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
With the previous done you can starting to using it. For that go to (.hml/.html/.j2) file and add on the header `{% load material_design_icons %}`.
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
```jinja
|
|
121
|
+
... <!--Other resources to load before -->
|
|
122
|
+
{% load material_design_icons %}
|
|
123
|
+
|
|
124
|
+
<!DOCTYPE html>
|
|
125
|
+
... <!-- you HTML web page document -->
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This ony is necessary to declared once since in the common file `base.html` or when you see is better place to use it.
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## ✏️ Syntax
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
The syntax is the next:
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
```abnf
|
|
139
|
+
; ------------------------ TAG ------------------------
|
|
140
|
+
; The tag that ever this package use 'mdi'
|
|
141
|
+
tag = "{% mdi" 1*WSP icon-name *(1*WSP options) 1*WSP "%}"
|
|
142
|
+
; read the README.md#-Icons
|
|
143
|
+
icon-name = STRING
|
|
144
|
+
|
|
145
|
+
; --------------------- OPTIONS ----------------------
|
|
146
|
+
; The options can been in any order one prefers, provided that none are repeated
|
|
147
|
+
options = size / theme-flag / kwargs
|
|
148
|
+
|
|
149
|
+
; The size will be used for both `hight` and `width`
|
|
150
|
+
size = "size=" 1*DIGIT ; unsigned int | >=0
|
|
151
|
+
|
|
152
|
+
; The theme-flag mark specifies which icon theme are going to search for and load.
|
|
153
|
+
; By default it selects the 'default' theme or the `light` version if `MDI_DEFAULT_LIGHT=True` is set.
|
|
154
|
+
theme-flag = default / light ; for the moment is light or default
|
|
155
|
+
|
|
156
|
+
; The rest of key-values that will loading inside of the icon <svg> tag for example: `class="align-middle"` to add the style `vertical-aligment: middle` from bootstrap ~v5 in the icon.
|
|
157
|
+
kwargs = key "=" value
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### Examples
|
|
162
|
+
|
|
163
|
+
```html
|
|
164
|
+
{% mdi carrot size=24 style="color: orange;" %}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
<svg xmlns="http://www.w3.org/2000/svg" id="mdi-carrot" height=24 width=24 style="color: orange;" viewBox="0 0 24 24"><path d="M16,10L15.8,11H13.5A0.5,0.5 0 0,0 13,11.5A0.5,0.5 0 0,0 13.5,12H15.6L14.6,17H12.5A0.5,0.5 0 0,0 12,17.5A0.5,0.5 0 0,0 12.5,18H14.4L14,20A2,2 0 0,1 12,22A2,2 0 0,1 10,20L9,15H10.5A0.5,0.5 0 0,0 11,14.5A0.5,0.5 0 0,0 10.5,14H8.8L8,10C8,8.8 8.93,7.77 10.29,7.29L8.9,5.28C8.59,4.82 8.7,4.2 9.16,3.89C9.61,3.57 10.23,3.69 10.55,4.14L11,4.8V3A1,1 0 0,1 12,2A1,1 0 0,1 13,3V5.28L14.5,3.54C14.83,3.12 15.47,3.07 15.89,3.43C16.31,3.78 16.36,4.41 16,4.84L13.87,7.35C15.14,7.85 16,8.85 16,10Z" /></svg>
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
## ⚙️ Configuration
|
|
171
|
+
|
|
172
|
+
To configure the package '_same as the rest of apps_' you need yo go to ever in the settings path of you project, when you will be able to modifies the following aspects.
|
|
173
|
+
|
|
174
|
+
### Set all icons light by default
|
|
175
|
+
|
|
176
|
+
To set `Material Design Icons Light` as the default theme wiouth need to set `light` in any icon (see [syntax](README.md#️-syntax)). You must add the key `MDI_DEFAULT_LIGHT`.
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
...
|
|
180
|
+
MDI_DEFAULT_LIGHT=True # by default is False, you can set it as string like "true".
|
|
181
|
+
...
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
## 🖼️ Icons
|
|
186
|
+
|
|
187
|
+
> [!NOTE]
|
|
188
|
+
> It's possible that some `default` icons are bot exist in the `light` theme.
|
|
189
|
+
|
|
190
|
+
The list of icons that the package including currently are the next:
|
|
191
|
+
|
|
192
|
+
- **Default v7.4.47** : https://pictogrammers.com/library/mdi/version/7.4.47
|
|
193
|
+
- **Light v0.2.63** : https://pictogrammers.com/library/mdil/version/0.2.63
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
## 🛠️ Maintenance Status
|
|
198
|
+
|
|
199
|
+
Due to the limited time I have, this package will receive updates **every 3 months** for maintenance and security reasons as well as synchronizing the catalog.
|
|
200
|
+
|
|
201
|
+
For the moment my approach is divided into thre parts:
|
|
202
|
+
|
|
203
|
+
- **Priority**: Compatibility with the minimal LTS version supported of Django.
|
|
204
|
+
- **Priority**: Compatibility with the minimal version of Python.
|
|
205
|
+
- Secondary: Update to the las version available of the icons.
|
|
206
|
+
|
|
207
|
+
In short 🎯: the priority is to assure that the package works ever in the stable environments and take advantage of each maintenance cycle you carry out to incorporate the new icons that may be released.
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
## ⚖️ Apache 2.0
|
|
212
|
+
|
|
213
|
+
This package is distributed under the [Apache License 2.0](LICENCE), allowing free use and open distribution of the icons.
|
|
214
|
+
|
|
215
|
+
About the icons:
|
|
216
|
+
|
|
217
|
+
- **Licence** Distributed under the [Apache License 2.0](https://apache.org) (_Pictogrammers Free License_). <!-- the url is being kept in case the technical team decides to change it on the future -->
|
|
218
|
+
- **Maintenance** This package solely bundles the existing icons; all design, distribution, addition, or modification decisions regarding the original library rest exclusively with the [Pictogrammers team](https://pictogrammers.com).
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Django MDI
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Package of icons from **Material Design Icons +light** for the web framework **Django**.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
> All icons included in this python package is works of the project [Pictogrammers](https://pictogrammers.com/)'s designers & collaborators, than creating and maintain this icons in a way thats is open and accessible to everyone ♥️.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 📄 Documentation translations
|
|
11
|
+
|
|
12
|
+
- [Spanish - Español 🇪🇸](./README.es-ES.md)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
### 🐍 From PyPI
|
|
18
|
+
|
|
19
|
+
This is the common form to install this package:
|
|
20
|
+
|
|
21
|
+
```shell
|
|
22
|
+
pip install django-mdi
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
In case that the PyPI have problems or you need to work offline you can use the next method.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### 🏠 From the repository
|
|
29
|
+
|
|
30
|
+
To install the package from a published version you can execute the next command.
|
|
31
|
+
|
|
32
|
+
```shell
|
|
33
|
+
# Change the 'main' word to the published version that want to install
|
|
34
|
+
$ pip install https://codeberg.org/IndustrialRabbit/django-mdi/archive/main.tar.gz
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
> [!TIP] Council
|
|
39
|
+
> If you can not install online the package you can download first the .tar.gz archive and next execute the pip command without needed internet connection.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
Yo can also installed it using a git-branch name or commit but (_it is not recommended_ 🫣)
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
# Change the 'main' word to the branch name or commit that want to install
|
|
47
|
+
pip install git+https://codeberg.org/IndustrialRabbit/django-mdi.git@main
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 📘 Usage manual
|
|
51
|
+
|
|
52
|
+
To usage it you was need to have a Django application created. Next need to go in the Django settings and where you have the `INSTALLED_APPS` add the package key name `"django_mdi"`.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
INSTALLED_APPS = [
|
|
56
|
+
...
|
|
57
|
+
"django_mdi",
|
|
58
|
+
...
|
|
59
|
+
]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
After registered the python package as Django application, in the same place, you must go to `TEMPLATES` setting and within the `OPTIONS` part add a `builtins` key with the value `"django_mdi.templatetags.material_design_icons"`.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
TEMPLATES = [
|
|
67
|
+
{
|
|
68
|
+
...
|
|
69
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
70
|
+
...
|
|
71
|
+
"OPTIONS": {
|
|
72
|
+
...
|
|
73
|
+
"builtins": [
|
|
74
|
+
...
|
|
75
|
+
"django_mdi.templatetags.material_design_icons",
|
|
76
|
+
...
|
|
77
|
+
],
|
|
78
|
+
...
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> [!NOTE]
|
|
85
|
+
> It has been tested with the official Django template engine `"django.template.backends.django.DjangoTemplates"`. If you change it ensure that you do not break the functionality.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
With the previous done you can starting to using it. For that go to (.hml/.html/.j2) file and add on the header `{% load material_design_icons %}`.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
```jinja
|
|
93
|
+
... <!--Other resources to load before -->
|
|
94
|
+
{% load material_design_icons %}
|
|
95
|
+
|
|
96
|
+
<!DOCTYPE html>
|
|
97
|
+
... <!-- you HTML web page document -->
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This ony is necessary to declared once since in the common file `base.html` or when you see is better place to use it.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## ✏️ Syntax
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
The syntax is the next:
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
```abnf
|
|
111
|
+
; ------------------------ TAG ------------------------
|
|
112
|
+
; The tag that ever this package use 'mdi'
|
|
113
|
+
tag = "{% mdi" 1*WSP icon-name *(1*WSP options) 1*WSP "%}"
|
|
114
|
+
; read the README.md#-Icons
|
|
115
|
+
icon-name = STRING
|
|
116
|
+
|
|
117
|
+
; --------------------- OPTIONS ----------------------
|
|
118
|
+
; The options can been in any order one prefers, provided that none are repeated
|
|
119
|
+
options = size / theme-flag / kwargs
|
|
120
|
+
|
|
121
|
+
; The size will be used for both `hight` and `width`
|
|
122
|
+
size = "size=" 1*DIGIT ; unsigned int | >=0
|
|
123
|
+
|
|
124
|
+
; The theme-flag mark specifies which icon theme are going to search for and load.
|
|
125
|
+
; By default it selects the 'default' theme or the `light` version if `MDI_DEFAULT_LIGHT=True` is set.
|
|
126
|
+
theme-flag = default / light ; for the moment is light or default
|
|
127
|
+
|
|
128
|
+
; The rest of key-values that will loading inside of the icon <svg> tag for example: `class="align-middle"` to add the style `vertical-aligment: middle` from bootstrap ~v5 in the icon.
|
|
129
|
+
kwargs = key "=" value
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
### Examples
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
{% mdi carrot size=24 style="color: orange;" %}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
<svg xmlns="http://www.w3.org/2000/svg" id="mdi-carrot" height=24 width=24 style="color: orange;" viewBox="0 0 24 24"><path d="M16,10L15.8,11H13.5A0.5,0.5 0 0,0 13,11.5A0.5,0.5 0 0,0 13.5,12H15.6L14.6,17H12.5A0.5,0.5 0 0,0 12,17.5A0.5,0.5 0 0,0 12.5,18H14.4L14,20A2,2 0 0,1 12,22A2,2 0 0,1 10,20L9,15H10.5A0.5,0.5 0 0,0 11,14.5A0.5,0.5 0 0,0 10.5,14H8.8L8,10C8,8.8 8.93,7.77 10.29,7.29L8.9,5.28C8.59,4.82 8.7,4.2 9.16,3.89C9.61,3.57 10.23,3.69 10.55,4.14L11,4.8V3A1,1 0 0,1 12,2A1,1 0 0,1 13,3V5.28L14.5,3.54C14.83,3.12 15.47,3.07 15.89,3.43C16.31,3.78 16.36,4.41 16,4.84L13.87,7.35C15.14,7.85 16,8.85 16,10Z" /></svg>
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
## ⚙️ Configuration
|
|
143
|
+
|
|
144
|
+
To configure the package '_same as the rest of apps_' you need yo go to ever in the settings path of you project, when you will be able to modifies the following aspects.
|
|
145
|
+
|
|
146
|
+
### Set all icons light by default
|
|
147
|
+
|
|
148
|
+
To set `Material Design Icons Light` as the default theme wiouth need to set `light` in any icon (see [syntax](README.md#️-syntax)). You must add the key `MDI_DEFAULT_LIGHT`.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
...
|
|
152
|
+
MDI_DEFAULT_LIGHT=True # by default is False, you can set it as string like "true".
|
|
153
|
+
...
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## 🖼️ Icons
|
|
158
|
+
|
|
159
|
+
> [!NOTE]
|
|
160
|
+
> It's possible that some `default` icons are bot exist in the `light` theme.
|
|
161
|
+
|
|
162
|
+
The list of icons that the package including currently are the next:
|
|
163
|
+
|
|
164
|
+
- **Default v7.4.47** : https://pictogrammers.com/library/mdi/version/7.4.47
|
|
165
|
+
- **Light v0.2.63** : https://pictogrammers.com/library/mdil/version/0.2.63
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
## 🛠️ Maintenance Status
|
|
170
|
+
|
|
171
|
+
Due to the limited time I have, this package will receive updates **every 3 months** for maintenance and security reasons as well as synchronizing the catalog.
|
|
172
|
+
|
|
173
|
+
For the moment my approach is divided into thre parts:
|
|
174
|
+
|
|
175
|
+
- **Priority**: Compatibility with the minimal LTS version supported of Django.
|
|
176
|
+
- **Priority**: Compatibility with the minimal version of Python.
|
|
177
|
+
- Secondary: Update to the las version available of the icons.
|
|
178
|
+
|
|
179
|
+
In short 🎯: the priority is to assure that the package works ever in the stable environments and take advantage of each maintenance cycle you carry out to incorporate the new icons that may be released.
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
## ⚖️ Apache 2.0
|
|
184
|
+
|
|
185
|
+
This package is distributed under the [Apache License 2.0](LICENCE), allowing free use and open distribution of the icons.
|
|
186
|
+
|
|
187
|
+
About the icons:
|
|
188
|
+
|
|
189
|
+
- **Licence** Distributed under the [Apache License 2.0](https://apache.org) (_Pictogrammers Free License_). <!-- the url is being kept in case the technical team decides to change it on the future -->
|
|
190
|
+
- **Maintenance** This package solely bundles the existing icons; all design, distribution, addition, or modification decisions regarding the original library rest exclusively with the [Pictogrammers team](https://pictogrammers.com).
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""The django-mdi build script
|
|
2
|
+
|
|
3
|
+
Contain the `new_theme` function to build the themes, you can use it to build you own or
|
|
4
|
+
personal mdi theme if you want.
|
|
5
|
+
|
|
6
|
+
The `build` function is a required function of poetry to create the package bundle
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
import sys
|
|
11
|
+
import zipfile
|
|
12
|
+
from multiprocessing.pool import ThreadPool
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Final
|
|
15
|
+
|
|
16
|
+
logger: logging.Logger = logging.getLogger(__name__)
|
|
17
|
+
logger.addHandler(logging.StreamHandler(sys.stdout))
|
|
18
|
+
logger.setLevel(logging.INFO)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
THEME_DIR: Final[Path] = Path("src/django_mdi/icons")
|
|
22
|
+
THEME_DIR.mkdir(parents=True, exist_ok=True)
|
|
23
|
+
|
|
24
|
+
MDI_NODE_MODULES: Final[Path] = Path("node_modules/@mdi")
|
|
25
|
+
"""the 'node_modules/@mdi' Path for development distribution"""
|
|
26
|
+
|
|
27
|
+
THEMES: Final[dict[str, Path]] = {
|
|
28
|
+
"default": MDI_NODE_MODULES / "svg/svg",
|
|
29
|
+
"light": MDI_NODE_MODULES / "svg/light-svg",
|
|
30
|
+
}
|
|
31
|
+
"""The MDI themes that the pip package contain"""
|
|
32
|
+
|
|
33
|
+
def new_theme(theme_path:Path, archive_path: Path) -> None:
|
|
34
|
+
"""Create a new MDI theme bundle .zip
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
theme_path : Path
|
|
39
|
+
the from dir where we will search and copy the resources
|
|
40
|
+
archive_path : Path
|
|
41
|
+
the to dir where the wheel (zip archive) will store the .svg
|
|
42
|
+
"""
|
|
43
|
+
logger.info("Building the %s from %s", archive_path, theme_path)
|
|
44
|
+
with zipfile.ZipFile(archive_path, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zf:
|
|
45
|
+
for svg_file in theme_path.glob("*.svg"):
|
|
46
|
+
logger.debug(" - Adding the icon: %s", svg_file)
|
|
47
|
+
zf.writestr(svg_file.name, svg_file.read_text(encoding="utf-8"))
|
|
48
|
+
logger.info("Terminating to build the %s", archive_path.name)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def build(setup_kwargs) -> None:
|
|
53
|
+
pool = ThreadPool(2)
|
|
54
|
+
try:
|
|
55
|
+
pool.starmap(
|
|
56
|
+
new_theme, [
|
|
57
|
+
(path, THEME_DIR / f"{name}.zip")
|
|
58
|
+
for name, path in THEMES.items()
|
|
59
|
+
]
|
|
60
|
+
)
|
|
61
|
+
finally:
|
|
62
|
+
pool.close()
|
|
63
|
+
pool.join()
|
|
64
|
+
|
|
65
|
+
if "__main__" == __name__:
|
|
66
|
+
build({}) # type: ignore
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
# PyPI does not support similar names
|
|
3
|
+
#name = "django-mdi"
|
|
4
|
+
name = "django-material-design-icons"
|
|
5
|
+
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
description = "Material Design Icon python package primarily for Django applications"
|
|
8
|
+
keywords = ["django", "icons", "material", "material-icons", "web", "svg"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 1 - Planning",
|
|
11
|
+
|
|
12
|
+
"Environment :: Web Environment",
|
|
13
|
+
|
|
14
|
+
"Framework :: Django",
|
|
15
|
+
"Framework :: Django :: 5.2",
|
|
16
|
+
# "Framework :: Django :: 6.2",
|
|
17
|
+
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
21
|
+
"Programming Language :: Python :: 3.15",
|
|
22
|
+
"Programming Language :: Python :: 3.16",
|
|
23
|
+
|
|
24
|
+
"Programming Language :: Python :: Free Threading :: 3 - Stable",
|
|
25
|
+
|
|
26
|
+
"Natural Language :: English",
|
|
27
|
+
"Natural Language :: Spanish",
|
|
28
|
+
|
|
29
|
+
"Typing :: Typed",
|
|
30
|
+
]
|
|
31
|
+
license-files = ["LICENCE", ]
|
|
32
|
+
authors = [
|
|
33
|
+
{ name = "IndustrialRabbit"}
|
|
34
|
+
]
|
|
35
|
+
maintainers = [
|
|
36
|
+
{ name = "IndustrialRabbit"}
|
|
37
|
+
]
|
|
38
|
+
dynamic = []
|
|
39
|
+
|
|
40
|
+
requires-python = ">=3.12,<3.17"
|
|
41
|
+
version = "0.0.1.dev1"
|
|
42
|
+
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
dev = [
|
|
45
|
+
"poethepoet>=0.49.0",
|
|
46
|
+
"ruff>=0.17.6",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.optional-dependencies]
|
|
50
|
+
all = ["django-material-design-icons[dev]"]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
[project.urls]
|
|
54
|
+
Repository = "https://codeberg.org/IndustrialRabbit/django-mdi.git"
|
|
55
|
+
Issues = "https://codeberg.org/IndustrialRabbit/django-mdi/issues"
|
|
56
|
+
|
|
57
|
+
[build-system]
|
|
58
|
+
requires = ["poetry-core", "poetry-dynamic-versioning", "setuptools"]
|
|
59
|
+
build-backend = "poetry_dynamic_versioning.backend"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
[tool.poetry-dynamic-versioning]
|
|
63
|
+
enable = false
|
|
64
|
+
vcs = "git"
|
|
65
|
+
|
|
66
|
+
[tool.poe.executor]
|
|
67
|
+
type = "uv"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
[tool.poetry]
|
|
71
|
+
packages = [
|
|
72
|
+
{ include = "django_mdi", from = "src" },
|
|
73
|
+
# { include = "icons", from = "src/django_mdi" }
|
|
74
|
+
]
|
|
75
|
+
include = [
|
|
76
|
+
{ path = "src/django_mdi/icons/*.whl", format = ["sdist", "wheel"] }
|
|
77
|
+
]
|
|
78
|
+
readme = ["README.md", "README.es-ES.md"]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
[tool.poetry.build]
|
|
82
|
+
script = "build.py"
|
|
83
|
+
generate-setup-file = true
|
|
84
|
+
|
|
85
|
+
[tool.uv.build-backend]
|
|
86
|
+
module-name = "django_mdi"
|
|
87
|
+
module-root = "src"
|
|
88
|
+
|
|
89
|
+
[tool.poetry.dependencies]
|
|
90
|
+
python = ">=3.12,<3.17"
|
|
91
|
+
django = ">=5.2.17,!=6.0.*,!=6.1.*"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
|
|
4
|
+
package_dir = \
|
|
5
|
+
{'': 'src'}
|
|
6
|
+
|
|
7
|
+
packages = \
|
|
8
|
+
['django_mdi', 'django_mdi.icons', 'django_mdi.templatetags']
|
|
9
|
+
|
|
10
|
+
package_data = \
|
|
11
|
+
{'': ['*']}
|
|
12
|
+
|
|
13
|
+
extras_require = \
|
|
14
|
+
{'all': ['django-material-design-icons[dev]']}
|
|
15
|
+
|
|
16
|
+
setup_kwargs = {
|
|
17
|
+
'name': 'django-material-design-icons',
|
|
18
|
+
'version': '0.0.1.dev1',
|
|
19
|
+
'description': 'Material Design Icon python package primarily for Django applications',
|
|
20
|
+
'long_description': '# Django MDI\n\n\nPackage of icons from **Material Design Icons +light** for the web framework **Django**.\n\n\n> All icons included in this python package is works of the project [Pictogrammers](https://pictogrammers.com/)\'s designers & collaborators, than creating and maintain this icons in a way thats is open and accessible to everyone ♥️.\n\n\n## 📄 Documentation translations\n\n- [Spanish - Español 🇪🇸](./README.es-ES.md)\n\n\n## 📦 Installation\n\n### 🐍 From PyPI\n\nThis is the common form to install this package:\n\n```shell\npip install django-mdi\n```\n\nIn case that the PyPI have problems or you need to work offline you can use the next method.\n\n\n### 🏠 From the repository\n\nTo install the package from a published version you can execute the next command.\n\n```shell\n# Change the \'main\' word to the published version that want to install\n$ pip install https://codeberg.org/IndustrialRabbit/django-mdi/archive/main.tar.gz\n```\n\n\n> [!TIP] Council\n> If you can not install online the package you can download first the .tar.gz archive and next execute the pip command without needed internet connection.\n\n---\n\nYo can also installed it using a git-branch name or commit but (_it is not recommended_ 🫣)\n\n```shell\n# Change the \'main\' word to the branch name or commit that want to install\npip install git+https://codeberg.org/IndustrialRabbit/django-mdi.git@main\n```\n\n## 📘 Usage manual\n\nTo usage it you was need to have a Django application created. Next need to go in the Django settings and where you have the `INSTALLED_APPS` add the package key name `"django_mdi"`.\n\n```python\nINSTALLED_APPS = [\n ...\n "django_mdi",\n ...\n]\n```\n\nAfter registered the python package as Django application, in the same place, you must go to `TEMPLATES` setting and within the `OPTIONS` part add a `builtins` key with the value `"django_mdi.templatetags.material_design_icons"`.\n\n\n```python\nTEMPLATES = [\n {\n ...\n "BACKEND": "django.template.backends.django.DjangoTemplates",\n ...\n "OPTIONS": {\n ...\n "builtins": [\n ...\n "django_mdi.templatetags.material_design_icons",\n ...\n ],\n ...\n },\n },\n]\n```\n\n> [!NOTE]\n> It has been tested with the official Django template engine `"django.template.backends.django.DjangoTemplates"`. If you change it ensure that you do not break the functionality.\n\n\nWith the previous done you can starting to using it. For that go to (.hml/.html/.j2) file and add on the header `{% load material_design_icons %}`.\n\n\n\n```jinja\n... <!--Other resources to load before -->\n{% load material_design_icons %}\n\n<!DOCTYPE html>\n... <!-- you HTML web page document -->\n```\n\nThis ony is necessary to declared once since in the common file `base.html` or when you see is better place to use it.\n\n\n\n## ✏️ Syntax\n\n\nThe syntax is the next:\n\n\n```abnf\n; ------------------------ TAG ------------------------\n; The tag that ever this package use \'mdi\'\ntag = "{% mdi" 1*WSP icon-name *(1*WSP options) 1*WSP "%}"\n; read the README.md#-Icons\nicon-name = STRING\n\n; --------------------- OPTIONS ----------------------\n; The options can been in any order one prefers, provided that none are repeated\noptions = size / theme-flag / kwargs\n\n; The size will be used for both `hight` and `width`\nsize = "size=" 1*DIGIT ; unsigned int | >=0\n\n; The theme-flag mark specifies which icon theme are going to search for and load.\n; By default it selects the \'default\' theme or the `light` version if `MDI_DEFAULT_LIGHT=True` is set.\ntheme-flag = default / light ; for the moment is light or default\n\n; The rest of key-values that will loading inside of the icon <svg> tag for example: `class="align-middle"` to add the style `vertical-aligment: middle` from bootstrap ~v5 in the icon.\nkwargs = key "=" value\n```\n\n\n### Examples\n\n```html\n{% mdi carrot size=24 style="color: orange;" %}\n```\n\n<svg xmlns="http://www.w3.org/2000/svg" id="mdi-carrot" height=24 width=24 style="color: orange;" viewBox="0 0 24 24"><path d="M16,10L15.8,11H13.5A0.5,0.5 0 0,0 13,11.5A0.5,0.5 0 0,0 13.5,12H15.6L14.6,17H12.5A0.5,0.5 0 0,0 12,17.5A0.5,0.5 0 0,0 12.5,18H14.4L14,20A2,2 0 0,1 12,22A2,2 0 0,1 10,20L9,15H10.5A0.5,0.5 0 0,0 11,14.5A0.5,0.5 0 0,0 10.5,14H8.8L8,10C8,8.8 8.93,7.77 10.29,7.29L8.9,5.28C8.59,4.82 8.7,4.2 9.16,3.89C9.61,3.57 10.23,3.69 10.55,4.14L11,4.8V3A1,1 0 0,1 12,2A1,1 0 0,1 13,3V5.28L14.5,3.54C14.83,3.12 15.47,3.07 15.89,3.43C16.31,3.78 16.36,4.41 16,4.84L13.87,7.35C15.14,7.85 16,8.85 16,10Z" /></svg>\n\n\n## ⚙️ Configuration\n\nTo configure the package \'_same as the rest of apps_\' you need yo go to ever in the settings path of you project, when you will be able to modifies the following aspects.\n\n### Set all icons light by default\n\nTo set `Material Design Icons Light` as the default theme wiouth need to set `light` in any icon (see [syntax](README.md#️-syntax)). You must add the key `MDI_DEFAULT_LIGHT`.\n\n```python\n...\nMDI_DEFAULT_LIGHT=True # by default is False, you can set it as string like "true".\n...\n```\n\n\n## 🖼️ Icons\n\n> [!NOTE]\n> It\'s possible that some `default` icons are bot exist in the `light` theme.\n\nThe list of icons that the package including currently are the next:\n\n- **Default v7.4.47** : https://pictogrammers.com/library/mdi/version/7.4.47\n- **Light v0.2.63** : https://pictogrammers.com/library/mdil/version/0.2.63\n\n\n\n## 🛠️ Maintenance Status\n\nDue to the limited time I have, this package will receive updates **every 3 months** for maintenance and security reasons as well as synchronizing the catalog.\n\nFor the moment my approach is divided into thre parts:\n\n- **Priority**: Compatibility with the minimal LTS version supported of Django.\n- **Priority**: Compatibility with the minimal version of Python.\n- Secondary: Update to the las version available of the icons.\n\nIn short 🎯: the priority is to assure that the package works ever in the stable environments and take advantage of each maintenance cycle you carry out to incorporate the new icons that may be released.\n\n\n\n## ⚖️ Apache 2.0\n\nThis package is distributed under the [Apache License 2.0](LICENCE), allowing free use and open distribution of the icons.\n\nAbout the icons:\n\n- **Licence** Distributed under the [Apache License 2.0](https://apache.org) (_Pictogrammers Free License_). <!-- the url is being kept in case the technical team decides to change it on the future -->\n- **Maintenance** This package solely bundles the existing icons; all design, distribution, addition, or modification decisions regarding the original library rest exclusively with the [Pictogrammers team](https://pictogrammers.com).',
|
|
21
|
+
'author': 'IndustrialRabbit',
|
|
22
|
+
'author_email': 'None',
|
|
23
|
+
'maintainer': 'IndustrialRabbit',
|
|
24
|
+
'maintainer_email': 'None',
|
|
25
|
+
'url': 'https://codeberg.org/IndustrialRabbit/django-mdi.git',
|
|
26
|
+
'package_dir': package_dir,
|
|
27
|
+
'packages': packages,
|
|
28
|
+
'package_data': package_data,
|
|
29
|
+
'extras_require': extras_require,
|
|
30
|
+
'python_requires': '>=3.12,<3.17',
|
|
31
|
+
}
|
|
32
|
+
from build import *
|
|
33
|
+
build(setup_kwargs)
|
|
34
|
+
|
|
35
|
+
setup(**setup_kwargs)
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""the django-mdi library api
|
|
2
|
+
|
|
3
|
+
here are all the functions that the package execute to show the icon
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import re
|
|
7
|
+
import zipfile
|
|
8
|
+
from _thread import LockType
|
|
9
|
+
from enum import StrEnum
|
|
10
|
+
from functools import cache, lru_cache
|
|
11
|
+
from importlib.resources import files
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from threading import Lock
|
|
14
|
+
from typing import Any, Final, Literal, LiteralString
|
|
15
|
+
|
|
16
|
+
from django.conf import settings
|
|
17
|
+
from django.utils.html import escape
|
|
18
|
+
from django.utils.safestring import SafeString, mark_safe
|
|
19
|
+
|
|
20
|
+
BASE_PATH: Final[Path] = Path(__file__).resolve().parent
|
|
21
|
+
"""The project base path '/src/django_mdi' it is"""
|
|
22
|
+
|
|
23
|
+
_ZIP_LOCK: LockType = Lock()
|
|
24
|
+
"""Zip locker instance, for security reasons with the multi thread or ASGI like applications"""
|
|
25
|
+
|
|
26
|
+
VALID_NAMES_REGEX: Final[re.Pattern[str]] = re.compile(r"^[a-z0-9-]+$")
|
|
27
|
+
"""The valid icon name regex"""
|
|
28
|
+
|
|
29
|
+
MDI_ICON_SETS_NAMES = Literal['default', 'light']
|
|
30
|
+
"""types of options that can one select"""
|
|
31
|
+
|
|
32
|
+
MDI_ICON_SETS: Final[dict[MDI_ICON_SETS_NAMES, Path]] = {
|
|
33
|
+
"default": BASE_PATH/Path("icons/default.zip"),
|
|
34
|
+
"light": BASE_PATH/Path("icons/light.zip"),
|
|
35
|
+
}
|
|
36
|
+
"""The icon sets available for the moment"""
|
|
37
|
+
|
|
38
|
+
MDI_CURRENT_ICON_SET: MDI_ICON_SETS_NAMES = \
|
|
39
|
+
'light' if getattr(settings, "MDI_DEFAULT_LIGHT", "false").lower() == "true" else 'default'
|
|
40
|
+
"""The current icon set name selected for all icons by default"""
|
|
41
|
+
|
|
42
|
+
@lru_cache(maxsize=2)
|
|
43
|
+
def is_default_light() -> bool:
|
|
44
|
+
"""Allow to know if is the default icon set the 'light'"""
|
|
45
|
+
return MDI_CURRENT_ICON_SET == 'light'
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@lru_cache(maxsize=2)
|
|
49
|
+
def _get_archive(icon_set: MDI_ICON_SETS_NAMES = 'default') -> zipfile.ZipFile | None:
|
|
50
|
+
"""return the icon set file descriptor
|
|
51
|
+
|
|
52
|
+
Its open and return the `ZipFile` instance of the .zip file where the icons
|
|
53
|
+
are compressed.
|
|
54
|
+
|
|
55
|
+
Parameters
|
|
56
|
+
----------
|
|
57
|
+
icon_set : MDI_ICON_SETS_NAMES, default='default'
|
|
58
|
+
The name of the icon set that you want to get
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
zipfile.ZipFile | None
|
|
63
|
+
return the Zip archive where the icon set selected are stored,
|
|
64
|
+
if not exist them it will return `None` value
|
|
65
|
+
"""
|
|
66
|
+
archive: Path | None = MDI_ICON_SETS.get(icon_set)
|
|
67
|
+
if not archive:
|
|
68
|
+
return None
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
return zipfile.ZipFile(files("django_mdi").joinpath(archive).open("rb"), mode="r")
|
|
72
|
+
except (FileNotFoundError, zipfile.BadZipFile):
|
|
73
|
+
return None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@cache
|
|
78
|
+
def _load_icon_content(
|
|
79
|
+
name: StrEnum | LiteralString | str,
|
|
80
|
+
light:bool = is_default_light(),
|
|
81
|
+
) -> bytes | None:
|
|
82
|
+
"""Load the icon svg content
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
name : StrEnum | LiteralString | str
|
|
87
|
+
The icon name that you want to read his content
|
|
88
|
+
light : bool, default=is_default_light()
|
|
89
|
+
Allow to select the light theme or not.
|
|
90
|
+
by default the function is_default_light() depend of your django settings value
|
|
91
|
+
`MDI_DEFAULT_LIGHT`, is False byt default selecting the 'default' theme for all
|
|
92
|
+
icons.
|
|
93
|
+
|
|
94
|
+
Returns
|
|
95
|
+
-------
|
|
96
|
+
bytes | None
|
|
97
|
+
load the selected icon .svg content, or return None if does not exist
|
|
98
|
+
"""
|
|
99
|
+
if isinstance(name, StrEnum):
|
|
100
|
+
name = name.value
|
|
101
|
+
|
|
102
|
+
# for security reasons we only validate the names that are on the `VALID_NAMES_REGEX`
|
|
103
|
+
if not VALID_NAMES_REGEX.match(name):
|
|
104
|
+
return None
|
|
105
|
+
|
|
106
|
+
archive: zipfile.ZipFile | None = _get_archive('light' if light else 'default')
|
|
107
|
+
if not archive:
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
try:
|
|
111
|
+
with _ZIP_LOCK and archive.open(f"{name}.svg") as svg_stream:
|
|
112
|
+
return svg_stream.read()
|
|
113
|
+
except KeyError:
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def build_icon(
|
|
118
|
+
name: StrEnum | LiteralString | str,
|
|
119
|
+
light:bool = is_default_light(),
|
|
120
|
+
*,
|
|
121
|
+
size: int = 24,
|
|
122
|
+
**kwargs: dict[str, Any]
|
|
123
|
+
) -> SafeString | None :
|
|
124
|
+
r"""gets and build the .svg content safely with the params
|
|
125
|
+
|
|
126
|
+
Parameters
|
|
127
|
+
----------
|
|
128
|
+
name : StrEnum | LiteralString | str
|
|
129
|
+
The icon name to load
|
|
130
|
+
light : bool, default=is_default_light()
|
|
131
|
+
Allow to select the light theme or not.
|
|
132
|
+
by default the function is_default_light() depend of your django settings value
|
|
133
|
+
`MDI_DEFAULT_LIGHT`, is False byt default selecting the 'default' theme for all
|
|
134
|
+
size : int, default=24
|
|
135
|
+
The size of the icon (x=\<size>, y=\<size>)
|
|
136
|
+
|
|
137
|
+
Returns
|
|
138
|
+
-------
|
|
139
|
+
SafeString | None
|
|
140
|
+
The salinatize .svg icon content to render on the current Django template engine
|
|
141
|
+
that support and use `SafeString`.
|
|
142
|
+
"""
|
|
143
|
+
content: bytes | None = _load_icon_content(name, light)
|
|
144
|
+
if not content:
|
|
145
|
+
return None
|
|
146
|
+
|
|
147
|
+
attrs: list[str] = [
|
|
148
|
+
f'width="{escape(size)}"',
|
|
149
|
+
f'height="{escape(size)}"',
|
|
150
|
+
'fill="currentColor"',
|
|
151
|
+
]
|
|
152
|
+
if css_class := kwargs.pop("class", None):
|
|
153
|
+
attrs.append(f'class="{escape(css_class)}"')
|
|
154
|
+
for key, value in kwargs.items():
|
|
155
|
+
attrs.append(f'{escape(key.replace("_", "-"))}="{escape(value)}"')
|
|
156
|
+
|
|
157
|
+
return mark_safe(content.decode().replace("<svg ", f"<svg {" ".join(attrs)} ", 1))
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Any, final
|
|
3
|
+
|
|
4
|
+
from django import template
|
|
5
|
+
from django.template import Context, Template, TemplateSyntaxError
|
|
6
|
+
from django.template.base import FilterExpression, Parser, Token
|
|
7
|
+
from django.utils.safestring import SafeString
|
|
8
|
+
|
|
9
|
+
from django_mdi.lib import build_icon, is_default_light
|
|
10
|
+
|
|
11
|
+
register = template.Library()
|
|
12
|
+
|
|
13
|
+
@final
|
|
14
|
+
@dataclass(slots=True)
|
|
15
|
+
class __MdiNode(template.Node):
|
|
16
|
+
|
|
17
|
+
icon: FilterExpression
|
|
18
|
+
"""The icon name selected"""
|
|
19
|
+
|
|
20
|
+
size: int = 34
|
|
21
|
+
"""The icon size"""
|
|
22
|
+
|
|
23
|
+
is_light: bool = is_default_light()
|
|
24
|
+
"""If is the 'light' theme selected"""
|
|
25
|
+
|
|
26
|
+
_kwargs: dict[str, FilterExpression] | None = None
|
|
27
|
+
"""Others key-words args to add in the <svg> html/xml tag"""
|
|
28
|
+
|
|
29
|
+
def render(self, context: Context) -> str:
|
|
30
|
+
kwargs: dict[str, SafeString | str] = \
|
|
31
|
+
self._resolve_kwargs(context, **self._kwargs) if self._kwargs else {}
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
icon: str = str(self.icon.resolve(context)).strip('"') # type: ignore
|
|
35
|
+
except template.VariableDoesNotExist as ex:
|
|
36
|
+
raise template.TemplateSyntaxError("invalid icon name") from ex
|
|
37
|
+
|
|
38
|
+
if svg_icon := build_icon(icon, self.is_light, size=self.size, kwargs=kwargs):
|
|
39
|
+
return svg_icon
|
|
40
|
+
|
|
41
|
+
if self.is_light:
|
|
42
|
+
raise template.TemplateSyntaxError(
|
|
43
|
+
f"MDI icon '{self.icon}' not found in the light theme set format"
|
|
44
|
+
)
|
|
45
|
+
raise template.TemplateSyntaxError(f"MDI icon '{self.icon}' not found")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def _resolve_kwargs(
|
|
50
|
+
context: Context,
|
|
51
|
+
**kwargs: FilterExpression,
|
|
52
|
+
) -> dict[str, SafeString | str]:
|
|
53
|
+
"""Resolve the kwargs values to parse safety in the get_icon function
|
|
54
|
+
|
|
55
|
+
Parameters
|
|
56
|
+
----------
|
|
57
|
+
context : Context
|
|
58
|
+
The render context to render the Django kwargs values template
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
dict[str, SafeString | str]
|
|
63
|
+
kwargs copy with the values resolved or render
|
|
64
|
+
"""
|
|
65
|
+
resolved_kwargs: dict[str, SafeString | str] = {}
|
|
66
|
+
for key, value in kwargs.items():
|
|
67
|
+
value = value.resolve(context, ignore_failures=True) # type: ignore
|
|
68
|
+
if not value: # not resolved them discard
|
|
69
|
+
continue
|
|
70
|
+
|
|
71
|
+
value: str | Any = value + "" if isinstance(value, SafeString) else value
|
|
72
|
+
if (
|
|
73
|
+
isinstance(value, str) and \
|
|
74
|
+
# contain a Django template syntax them try to render his content
|
|
75
|
+
("{"in value and
|
|
76
|
+
("{{"in value or "{%"in value))
|
|
77
|
+
):
|
|
78
|
+
try:
|
|
79
|
+
value = Template(value).render(context)
|
|
80
|
+
except TemplateSyntaxError:
|
|
81
|
+
...
|
|
82
|
+
# The value expected here to be a SafeString from a rendered template
|
|
83
|
+
# in any other case it must filtered `FilterExpression` doing this safe to
|
|
84
|
+
# add in the svg html preventing xss
|
|
85
|
+
resolved_kwargs[key] = value
|
|
86
|
+
return resolved_kwargs
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@register.tag("mdi")
|
|
90
|
+
def render_md_icon(parser:Parser, token:Token) -> __MdiNode:
|
|
91
|
+
r"""The django-mid main template tag
|
|
92
|
+
|
|
93
|
+
The sintaxis expected is
|
|
94
|
+
```
|
|
95
|
+
{% mid <name> <? size=value> <? light> <? **kwargs> %}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
__MdiNode
|
|
101
|
+
The Material Design Icon template node
|
|
102
|
+
|
|
103
|
+
"""
|
|
104
|
+
contents: list[str] = token.split_contents()
|
|
105
|
+
if len(contents) < 2:
|
|
106
|
+
raise template.TemplateSyntaxError("the tag 'mid' required a icon name to be used")
|
|
107
|
+
|
|
108
|
+
contents = contents[1:]
|
|
109
|
+
|
|
110
|
+
# get ever the first that is the icon name
|
|
111
|
+
icon_name: FilterExpression = parser.compile_filter(contents[0])
|
|
112
|
+
|
|
113
|
+
# get the others parameters
|
|
114
|
+
size: int = 24
|
|
115
|
+
light:bool = False
|
|
116
|
+
kwargs : dict[str, FilterExpression] = {}
|
|
117
|
+
for content in contents[1:]:
|
|
118
|
+
|
|
119
|
+
# ------------------ args- -----------------
|
|
120
|
+
if content.lower() == "light":
|
|
121
|
+
if light:
|
|
122
|
+
raise template.TemplateSyntaxError(
|
|
123
|
+
"'light' attribute repeated more than 1"
|
|
124
|
+
)
|
|
125
|
+
light = True
|
|
126
|
+
continue
|
|
127
|
+
|
|
128
|
+
# ------------- key=value args -------------
|
|
129
|
+
key, value = content.split("=", 1)
|
|
130
|
+
|
|
131
|
+
if key.lower() == "size":
|
|
132
|
+
if not str.isnumeric(value):
|
|
133
|
+
raise template.TemplateSyntaxError(
|
|
134
|
+
f"invalid size '{value}' value, "
|
|
135
|
+
"expected a number"
|
|
136
|
+
)
|
|
137
|
+
if size < 0:
|
|
138
|
+
raise template.TemplateSyntaxError(
|
|
139
|
+
f"invalid size '{value}' value, "
|
|
140
|
+
"expected a number 'unsigned int' type not negative"
|
|
141
|
+
)
|
|
142
|
+
size = int(value)
|
|
143
|
+
continue
|
|
144
|
+
|
|
145
|
+
kwargs[key] = parser.compile_filter(value)
|
|
146
|
+
|
|
147
|
+
return __MdiNode(icon_name,size,light,kwargs)
|
|
148
|
+
|