Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-instagram-to-social-media
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyboar committed Mar 1, 2024
2 parents a83c93d + 6692a86 commit 46c7ec8
Show file tree
Hide file tree
Showing 60 changed files with 4,011 additions and 18,695 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.git
.nx
.cache
node_modules
dist
**/secrets.py
**/settings_local.py

# ignore local CMS media folder
apps/tup-cms/src/media/
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- uses: nrwl/nx-set-shas@v3

# Check linting/formatting of workspace files.
- run: npx nx workspace-lint
- run: npx nx format:check

# Lint/test/build any apps and libs that have been impacted by the diff.
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ testem.log
# System Files
.DS_Store
Thumbs.db

.nx/cache
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ apps/tup-cms/**/templates/**/*
# do not format stylesheets until `nx format` ignores multiple blank lines
# https://prettier.io/docs/en/rationale.html#empty-lines
*.css

/.nx/cache
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@ This project was generated using [Nx](https://nx.dev).
Local dev setup:

1. `npm install` to install Javascript dependencies and the Nx build tool.
2. `npx nx build tup-css` to build the styles.
3. `npx nx build tup-ui` to build the TUP UI.
4. `npx nx build tup-cms` to build the CMS container.
5. `npx nx serve tup-cms` to serve the CMS backend.
6. `npx nx serve tup-ui` in another terminal tab to serve the React frontend.
7. Run Django migrations:
2. `npx nx build tup-ui` to build the TUP UI.
3. `npx nx build tup-cms` to build the CMS container.
4. `npx nx serve tup-cms` to serve the CMS backend.
5. `npx nx serve tup-ui` in another terminal tab to serve the React frontend.
6. Run Django migrations:

- a) `docker exec -it tup_cms /bin/bash`
- b) `python manage.py migrate`

8. (if CMS assets change) Collect updated CMS assets:

- a) `docker exec -it tup_cms /bin/bash`
- b) `python manage.py collectstatic --ignore assets/*/font*.css`

The TUP dashboard is accessed at http://localhost:8000/portal.
To bring containers down after development, run `npx nx down tup-cms`.

<!--
Other useful commands:
- `npx nx build core-components` to create a distributable library for the core components.
-->

<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="450"></p>

🔎 **Smart, Fast and Extensible Build System**
Expand Down
9 changes: 3 additions & 6 deletions apps/tup-cms-react/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,15 @@
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["coverage/apps/tup-cms-react"],
"outputs": ["{workspaceRoot}/coverage/apps/tup-cms-react"],
"options": {
"passWithNoTests": true,
"reportsDirectory": "../../coverage/apps/tup-cms-react"
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/tup-cms-react/**/*.{ts,tsx,js,jsx}"]
}
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
}
},
"tags": []
Expand Down
9 changes: 9 additions & 0 deletions apps/tup-cms-react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import viteTsConfigPaths from 'vite-tsconfig-paths';
import path from 'path';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/tup-cms-react',

server: {
Expand All @@ -28,6 +29,9 @@ export default defineConfig({
],

build: {
outDir: '../../dist/apps/tup-cms-react',
reportCompressedSize: true,
commonjsOptions: { transformMixedEsModules: true },
rollupOptions: {
input: {
imports: path.resolve(__dirname, 'imports.html'),
Expand All @@ -45,6 +49,11 @@ export default defineConfig({
// },

test: {
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/apps/tup-cms-react',
provider: 'v8',
},
globals: true,
cache: {
dir: '../../node_modules/.vitest',
Expand Down
3 changes: 2 additions & 1 deletion apps/tup-cms/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ nohup.out

/portal/.docs/build/

#ignore local static and media folders
# ignore local static and media folders
src/media/
server/static
server/portal/static/vendor/lib/node_modules
server/media
Expand Down
23 changes: 17 additions & 6 deletions apps/tup-cms/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# TACC/Core-CMS#v4.3.0
FROM taccwma/core-cms:7dabc2e
FROM node:20 as node_build
COPY package.json package-lock.json /code/
WORKDIR /code
RUN npm ci

COPY . /code/
RUN npx nx build tup-ui
RUN npx nx build tup-cms-react

# TACC/Core-CMS#v4.6.0 (Python 3.11)
FROM taccwma/core-cms:8a56b9d

WORKDIR /code

COPY apps/tup-cms/src/apps /code/apps
COPY apps/tup-cms/src/taccsite_custom /code/taccsite_custom
COPY apps/tup-cms/src/taccsite_cms /code/taccsite_cms

COPY dist/apps/tup-ui/imports.html /code/taccsite_cms/templates/imports.html
COPY dist/apps/tup-ui/assets/ /code/taccsite_cms/static/assets/
COPY --from=node_build /code/dist/apps/tup-ui/imports.html /code/taccsite_cms/templates/imports.html
COPY --from=node_build /code/dist/apps/tup-ui/assets/ /code/taccsite_cms/static/assets/

COPY --from=node_build /code/dist/apps/tup-cms-react/assets /code/taccsite_cms/static/cms-react/assets
COPY --from=node_build /code/dist/apps/tup-cms-react/imports.html /code/taccsite_cms/templates/tup-cms-react.html

COPY dist/apps/tup-cms-react/assets /code/taccsite_cms/static/cms-react/assets
COPY /dist/apps/tup-cms-react/imports.html /code/taccsite_cms/templates/tup-cms-react.html
RUN python manage.py collectstatic --no-input --clear --ignore assets/*/font*.css
3 changes: 3 additions & 0 deletions apps/tup-cms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ A `Makefile` has been included for convenience. You may use
make start
```

> **Important**
> If you must run `python manage.py collectstatic`, do so via `python manage.py collectstatic --ignore assets/*/font*.css` to avoid error.
## Based on Core CMS Custom

This is a downstream CMS project, like those in [Core CMS Custom](https://github.com/tacc/core-cms-custom), but has been placed in [tup-ui](https://github.com/tacc/tup-ui) for convenient access to all public TUP code.
2 changes: 2 additions & 0 deletions apps/tup-cms/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ services:
hostname: tup_cms
volumes:
- ./src/apps:/code/apps
- ./src/media:/code/media
- ./src/data:/var/tmp/data
- ./src/taccsite_custom:/code/taccsite_custom
- ./src/taccsite_cms/custom_app_settings.py:/code/taccsite_cms/custom_app_settings.py
- ./src/taccsite_cms/urls_custom.py:/code/taccsite_cms/urls_custom.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
};
</script>
<script type="module">
import RefreshRuntime from 'http://localhost:3000/@react-refresh';
import RefreshRuntime from 'http://localhost:3000/static/@react-refresh';
RefreshRuntime.injectIntoGlobalHook(window);
window.$RefreshReg$ = () => {};
window.$RefreshSig$ = () => (type) => type;
window.__vite_plugin_react_preamble_installed__ = true;
</script>
<script type="module" src="http://localhost:3000/@vite/client"></script>
<script type="module" src="http://localhost:3000/src/main.tsx"></script>
<script type="module" src="http://localhost:3000/static/@vite/client"></script>
<script type="module" src="http://localhost:3000/static/src/main.tsx"></script>
{% endblock %}
9 changes: 8 additions & 1 deletion apps/tup-cms/src/apps/staff_profile/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
from djangocms_text_ckeditor.widgets import TextEditorWidget

from .models import StaffProfilePlugin
from django.core.exceptions import ValidationError

def validate_jr_and_sr(value):
if value.lower().endswith('jr') or value.lower().endswith('sr'):
if not value.endswith('.'):
raise ValidationError('Please use a period after Jr. or Sr.')

class StaffProfilePluginForm(ModelForm):
first_name = forms.CharField(
Expand All @@ -17,7 +23,8 @@ class StaffProfilePluginForm(ModelForm):
post_nomials = forms.CharField(
required=False,
label=_('Post-nomials'),
help_text=_('E.g. Ph.D., B.S., M.B.A.')
help_text=_('E.g. Ph.D., B.S., M.B.A.'),
validators=[validate_jr_and_sr]
)
title = forms.CharField(
required=True,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{% if instance.post_nomials %}
{{instance.first_name}} {{instance.last_name}}, {{instance.post_nomials}}
{% load post_nomials %}

{% post_nomials_exclusion_list as post_nomials_exclusion_list %}

{% if instance.post_nomials and instance.post_nomials not in post_nomials_exclusion_list %}
{{ instance.first_name }} {{ instance.last_name }}, {{ instance.post_nomials }}
{% else %}
{{instance.first_name}} {{instance.last_name}}
{{ instance.first_name }} {{ instance.last_name }} {{ instance.post_nomials }}
{% endif %}
Empty file.
13 changes: 13 additions & 0 deletions apps/tup-cms/src/apps/staff_profile/templatetags/post_nomials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django import template
from django.conf import settings

POST_NOMIALS_EXCLUSION_LIST = settings.TACC_STAFF_PROFILE_POST_NOMIALS_EXCLUSION_LIST

register = template.Library()

@register.simple_tag
def post_nomials_exclusion_list():

return POST_NOMIALS_EXCLUSION_LIST


Loading

0 comments on commit 46c7ec8

Please sign in to comment.