Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instrument list front-end #47

Merged
merged 38 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
031d22f
🆕 Initialize templates
yinanazhou Sep 22, 2023
8ace63f
🆕 Initialize css files
yinanazhou Sep 22, 2023
54c1ec1
🆕 Create 404 page
yinanazhou Sep 22, 2023
e6f008c
🛠️ Set up base navbar & footer
yinanazhou Sep 23, 2023
086d3ac
Add language button
yinanazhou Sep 25, 2023
cd8b312
Minor style adjustment for base page
yinanazhou Sep 25, 2023
4e72f32
Init masonry for instruments
yinanazhou Sep 26, 2023
c283d83
Adjust footer style
yinanazhou Sep 26, 2023
c62d3d9
Add example content for sidebar
yinanazhou Sep 26, 2023
98e44af
Rename sidebar-block to info-block
yinanazhou Sep 26, 2023
4161885
Adjust card style
yinanazhou Sep 26, 2023
b913550
Remove redundant tag
yinanazhou Sep 27, 2023
365ec47
Adjust page layout
yinanazhou Sep 27, 2023
9c80551
Only display english names
yinanazhou Sep 27, 2023
7d68850
Wrap masonry into js file
yinanazhou Sep 27, 2023
fc59d94
Add pagination block
yinanazhou Sep 27, 2023
2006b6b
Rename show-more collapse id
yinanazhou Sep 27, 2023
cb8cf41
Remove slice
yinanazhou Sep 28, 2023
f0960a0
Adjust page button style
yinanazhou Sep 28, 2023
05dd19f
Update pagination style & link
yinanazhou Sep 28, 2023
65803c0
Rename content-container to body-container
yinanazhou Sep 28, 2023
f8c4317
♻️Update ImagesLoaded & Masonry
yinanazhou Sep 28, 2023
5121cc7
Add masonry display button
yinanazhou Sep 28, 2023
d5ff326
Add display switch functionality
yinanazhou Sep 29, 2023
e6a14b5
Adjust layout style
yinanazhou Sep 29, 2023
2135659
🪄 Add list view
yinanazhou Sep 29, 2023
94f7743
Align image center
yinanazhou Oct 2, 2023
fd4287a
Remove padding
yinanazhou Oct 2, 2023
291e1b2
Add standard view
yinanazhou Oct 2, 2023
57eb368
Save display mode to local storage
yinanazhou Oct 2, 2023
b2c69a7
Add home page
yinanazhou Oct 3, 2023
8b1b121
Move base templates & static folder into VIM/
yinanazhou Oct 3, 2023
d0dd722
Add links to navbar
yinanazhou Oct 3, 2023
0723518
Correct static files dirs
yinanazhou Oct 3, 2023
f6e6a55
Add about page & include urls from main app
yinanazhou Oct 3, 2023
8490f19
Add active indication & adjust navbar styles
yinanazhou Oct 4, 2023
0184714
Change uri to url in templates
dchiller Oct 4, 2023
92cf01c
Format code
dchiller Oct 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_instrument_data(self, instrument_ids: list[str]) -> list[dict]:

def create_database_objects(self, instrument_attrs: dict, ins_img_url: str) -> None:
"""
Given a dictionary of instrument attributes and a url to an instrument image,
Given a dictionary of instrument attributes and a url to an instrument image,
create the corresponding database objects.

instrument_attrs [dict]: Dictionary of instrument attributes. See
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class Command(BaseCommand):
"""
The import_languages command populates the database with languages in which instrument
names can be provided in VIM.

NOTE: For now, this script only imports English and French.
"""

help = "Imports possible languages for instrument names from Wikidata."

def handle(self, *args, **options):
Expand Down
196 changes: 160 additions & 36 deletions web-app/django/VIM/apps/instruments/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,188 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
]
dependencies = []

operations = [
migrations.CreateModel(
name='AVResource',
name="AVResource",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('type', models.CharField(choices=[('audio', 'Audio'), ('video', 'Video'), ('image', 'Image')], help_text='What type of audiovisual resource is this?', max_length=5)),
('format', models.CharField()),
('url', models.URLField(max_length=1000)),
('instrument_date', models.DateField(blank=True, help_text='When was this instrument made?', null=True)),
('instrument_maker', models.CharField(blank=True, help_text='Who made this instrument?')),
('instrument_description', models.TextField(blank=True, help_text='Additional information about the instrument.')),
('source_name', models.CharField(help_text='What is the name of the source of this AVResource?')),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"type",
models.CharField(
choices=[
("audio", "Audio"),
("video", "Video"),
("image", "Image"),
],
help_text="What type of audiovisual resource is this?",
max_length=5,
),
),
("format", models.CharField()),
("url", models.URLField(max_length=1000)),
(
"instrument_date",
models.DateField(
blank=True,
help_text="When was this instrument made?",
null=True,
),
),
(
"instrument_maker",
models.CharField(blank=True, help_text="Who made this instrument?"),
),
(
"instrument_description",
models.TextField(
blank=True,
help_text="Additional information about the instrument.",
),
),
(
"source_name",
models.CharField(
help_text="What is the name of the source of this AVResource?"
),
),
],
),
migrations.CreateModel(
name='Instrument',
name="Instrument",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('wikidata_id', models.CharField(max_length=20, unique=True)),
('hornbostel_sachs_class', models.CharField(blank=True, help_text='Hornbostel-Sachs classification', max_length=50)),
('mimo_class', models.CharField(blank=True, help_text='Musical Instrument Museums Online classification', max_length=50)),
('default_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='default_image_of', to='instruments.avresource')),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("wikidata_id", models.CharField(max_length=20, unique=True)),
(
"hornbostel_sachs_class",
models.CharField(
blank=True,
help_text="Hornbostel-Sachs classification",
max_length=50,
),
),
(
"mimo_class",
models.CharField(
blank=True,
help_text="Musical Instrument Museums Online classification",
max_length=50,
),
),
(
"default_image",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="default_image_of",
to="instruments.avresource",
),
),
],
),
migrations.CreateModel(
name='Language',
name="Language",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('wikidata_code', models.CharField(help_text='Language code in Wikidata', unique=True)),
('wikidata_id', models.CharField(help_text='Language ID (Q number) in Wikidata', unique=True)),
('en_label', models.CharField(help_text='Language label in English')),
('autonym', models.CharField(help_text='Language label in the language itself')),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"wikidata_code",
models.CharField(
help_text="Language code in Wikidata", unique=True
),
),
(
"wikidata_id",
models.CharField(
help_text="Language ID (Q number) in Wikidata", unique=True
),
),
("en_label", models.CharField(help_text="Language label in English")),
(
"autonym",
models.CharField(help_text="Language label in the language itself"),
),
],
),
migrations.CreateModel(
name='InstrumentName',
name="InstrumentName",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('source_name', models.CharField(help_text='Who or what called the instrument this?', max_length=50)),
('instrument', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='instruments.instrument')),
('language', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='instruments.language')),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=50)),
(
"source_name",
models.CharField(
help_text="Who or what called the instrument this?",
max_length=50,
),
),
(
"instrument",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
to="instruments.instrument",
),
),
(
"language",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
to="instruments.language",
),
),
],
),
migrations.AddField(
model_name='avresource',
name='instrument',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='instruments.instrument'),
model_name="avresource",
name="instrument",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT, to="instruments.instrument"
),
),
migrations.AddField(
model_name='avresource',
name='instrument_description_language',
field=models.ForeignKey(blank=True, help_text='What language is Instrument Description written in?', null=True, on_delete=django.db.models.deletion.PROTECT, to='instruments.language'),
model_name="avresource",
name="instrument_description_language",
field=models.ForeignKey(
blank=True,
help_text="What language is Instrument Description written in?",
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="instruments.language",
),
),
]
10 changes: 8 additions & 2 deletions web-app/django/VIM/apps/instruments/models/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ class Instrument(models.Model):
null=True,
related_name="default_image_of",
)
hornbostel_sachs_class = models.CharField(max_length=50, blank=True, help_text = "Hornbostel-Sachs classification")
mimo_class = models.CharField(max_length=50, blank=True, help_text = "Musical Instrument Museums Online classification")
hornbostel_sachs_class = models.CharField(
max_length=50, blank=True, help_text="Hornbostel-Sachs classification"
)
mimo_class = models.CharField(
max_length=50,
blank=True,
help_text="Musical Instrument Museums Online classification",
)
120 changes: 120 additions & 0 deletions web-app/django/VIM/apps/instruments/static/instruments/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

@import url("https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css");

h4 {
color: #435334;
font-size: 20px;
font-weight: 700;
}

h5 {
color: #435334;
}

hr {
border: 1.5px solid #435334;
margin-top: 0;
}

/* sidebar */
.sidebar-container {
background-color: white;
border: 3px solid #9EB384;
border-radius: 30px;
height: auto !important;
}

.info-block {
background-color: #FAF1E4;
border: 1.5px solid #CEDEBD;
border-radius: 10px;
height: auto !important;
}

.list-group-item {
border: none !important;
background-color: transparent !important;
color: #9EB384;
}

.toggle-more{
color: #435334;
}

.toggle-more:hover {
cursor: pointer;
color: #9EB384;
}

/* body */
.body-container {
background-color: white;
border: 3px solid #9EB384;
border-radius: 30px;
}

.display-btn {
font-weight: bold;
color: #435334;
font-size: 20px;
}

.display-btn:focus {
border-color:#435334;
}

.card {
background-color: #FAF1E4;
}

.card-title {
color: #435334;
}

.pagination-container {
color: #435334;
}

.page-link {
color: #435334;
}

.page-number,
.page-link:hover {
color: #9EB384;
}

/* list view */
.list-item-container {
min-height: 200px;
max-height: 300px;
overflow: hidden;
}

.card-title h5:hover {
color: #9EB384;
}

.more-info {
color: #435334;
}

.more-info:hover {
border: 1px solid #435334;
}

/* standard view */
.square-box {
position: relative;
padding-top: 100%;
overflow: hidden;
}

.square-box img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
Loading