Skip to content

Commit

Permalink
ding ding! another batch of minor fixes coming through! (events page …
Browse files Browse the repository at this point in the history
…resizing, events page cateogry unhiding fix, remove silly console logs I forgot to remove, remove 'control characters'(?) for events page rss feed, fix orderby thing for authors photos page, use first_published_at for archive page for speed)
  • Loading branch information
SamuelmdLow committed Sep 30, 2024
1 parent eb026e1 commit c780df9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions archive/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def get_paginated_articles(self, context, objects, video_section, request):
def get_order_objects(self, order, objects, videos_section):
if videos_section == False:
if order == 'oldest':
article_order = "explicit_published_at"
article_order = "first_published_at"
else:
article_order = "-explicit_published_at"
article_order = "-first_published_at"

return objects.order_by(article_order)
else:
Expand All @@ -211,7 +211,7 @@ def get_order_objects(self, order, objects, videos_section):

def get_year_objects(self, objects, videos_section):
if videos_section == False:
return objects.filter(explicit_published_at__year=str(self.year))
return objects.filter(first_published_at__year=str(self.year))
else:
return objects.filter(created_at__gte=str(self.year) + "-01-01", created_at__lte = str(self.year + 1) + "-12-31")

Expand Down
6 changes: 3 additions & 3 deletions archive/templates/archive/objects/gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ <h3 class="o-archive__header__title">
{% if page_obj %} {{ page_obj.paginator.count }} RESULTS {% else %}NO RESULTS{% endif %}
{% if q %} FOR "{{ q }}"{% endif %}
</h3>
<div class="o-archive__header__sort o-dropdown js-dropdown">
<a class="o-button o-dropdown__button">
<div class="o-archive__header__sort o-dropdown">
<a class="o-button o-dropdown__button preventDefault" href="#">
<span>{{ order|title }}</span>
<ion-icon name="caret-down-outline"></ion-icon>
</a>
<ul class="o-dropdown__list js-dropdown-list">
<ul class="o-dropdown__list">
<li class="o-dropdown__item{% if order == 'newest' %} o-dropdown__item--is-active{% endif %}">
<a href="?{% modify_query_string 'order' 'newest' %}">Newest</a>
</li>
Expand Down
4 changes: 3 additions & 1 deletion events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,10 @@ def items(self, category):
return Event.objects.filter(hidden=False, end_time__gte=timezone.now(), start_time__lte=timezone.now() + timedelta(days=7)).exclude(category='seminar')

def item_title(self, item):
import re
item.start_time = item.start_time.astimezone(timezone.get_current_timezone())
return item.start_time.strftime("%-m/%-d %-I:%M%P") + " " + item.title.replace("<br>", "")
title = item.start_time.strftime("%-m/%-d %-I:%M%P") + " " + item.title.replace("<br>", "")
return re.sub(r'[\x00-\x1f\x7f-\x9f]', '', title)

def item_pubdate(self, item):
return item.start_time.astimezone(timezone.get_current_timezone())
Expand Down
17 changes: 12 additions & 5 deletions ubyssey/static_src/src/js/components/Events/calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function EventsCalendar({events}) {
hidden = hidden.filter((i) => i!="");

if (hidden.includes(that.id)) {
hidden.pop(hidden.indexOf(that.id));
hidden.splice(hidden.indexOf(that.id), 1);
} else {
hidden.push(that.id);
}
Expand Down Expand Up @@ -455,7 +455,7 @@ function EventsCalendar({events}) {
<ul>{legend.map((key, i) =>
<li key={i} className={slugify(key)}>
<button id={slugify(key)} className={"legend-button" + (hidden.includes(slugify(key)) ? " inactive" : "")}
onClick={(e) => toggleCategory(e.target, searchParams, setSearchParams)} title={key}
onClick={(e) => {console.log(e); toggleCategory(e.target, searchParams, setSearchParams);}} title={key}
dangerouslySetInnerHTML={
{__html: key}
}></button>
Expand All @@ -467,6 +467,7 @@ function EventsCalendar({events}) {
}

function EventInfo({events}) {
const [widthMode, setWidthMode] = React.useState(window.innerWidth <= 759);
let [searchParams, setSearchParams] = useSearchParams();
let query = useQuery();
var event = false;
Expand All @@ -484,15 +485,21 @@ function EventInfo({events}) {
}
}

React.useLayoutEffect(()=> {

window.addEventListener('resize', ()=> {
setWidthMode(window.innerWidth <= 759);
});
}, []);

React.useEffect(()=>{
console.log(document.getElementById('event-dialog'));
if(document.getElementById('event-dialog')) {
document.getElementById('event-dialog').showModal();
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = 'auto';
}
})
});

function exitEvent(searchParams, setSearchParams) {
searchParams.delete("event");
Expand All @@ -503,7 +510,7 @@ function EventInfo({events}) {
<div class="events-info-container">
{event &&
<>
{screen.width <= 759 ?
{widthMode ?
<>
<dialog id="event-dialog" open="" aria-modal="true">
<div className="events-info-shadow" onClick={() => exitEvent(searchParams, setSearchParams)}></div>
Expand Down
3 changes: 0 additions & 3 deletions ubyssey/static_src/src/js/infinitefeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ function recievedata(data) {
congratz.innerHTML = "You reached the end! 🥳";
loader.replaceChildren(congratz);
} else {
console.log("epic");
for (let i=0; i<data.length; i++) {
feed.insertAdjacentHTML("beforeend", data[i]);
console.log("placed");
}
console.log("done");
loader.classList.add("hide");
loader.removeAttribute("inactive");
}
Expand Down

0 comments on commit c780df9

Please sign in to comment.