Skip to content

Commit

Permalink
Add deep linking
Browse files Browse the repository at this point in the history
<!-- ps-id: 9465f69d-b2b7-4c6a-9675-9367aeb54322 -->
  • Loading branch information
EntilZha committed Jul 12, 2023
1 parent 8194017 commit 64d117e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion acl_miniconf/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def day(self) -> str:
# expects the dates to have the second format. If we do it the previous
# way, the `sessions.html` tabs for each day don't work well.
# return self.start_time.astimezone(pytz.utc).strftime("%B %d")
return self.start_time.astimezone(pytz.utc).strftime("%b %d")
return self.start_time.astimezone(pytz.utc).strftime("%B %d")

@property
def time_string(self) -> str:
Expand Down
10 changes: 5 additions & 5 deletions acl_miniconf/load_site_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def generate_paper_events(site_data: SiteData) -> List[Dict[str, Any]]:
end = session.end_time
tab_id = (
session.start_time.astimezone(pytz.utc)
.strftime("%b %d")
.strftime("%B %d")
.replace(" ", "")
.lower()
)
Expand All @@ -96,7 +96,7 @@ def generate_paper_events(site_data: SiteData) -> List[Dict[str, Any]]:
elif session.type == "Socials":
url = f"socials.html#tab-{tab_id}"
else:
url = f"sessions.html#tab-{tab_id}"
url = f"sessions.html#link-{tab_id}-{session.id}"

event = FrontendCalendarEvent(
title=session.name,
Expand All @@ -117,7 +117,7 @@ def generate_paper_events(site_data: SiteData) -> List[Dict[str, Any]]:
elif event.type == 'Plenary Sessions':
url = "/plenary_sessions.html"
else:
url = "/sessions.html"
url = f"/sessions.html#link-{tab_id}-{event.id}"
frontend_event = FrontendCalendarEvent(
title=f"<b>{event.track}</b>",
start=start,
Expand Down Expand Up @@ -227,7 +227,7 @@ def generate_social_events(site_data: SiteData) -> List[Dict[str, Any]]:
end = session.end_time
tab_id = (
session.start_time.astimezone(pytz.utc)
.strftime("%b %d")
.strftime("%B %d")
.replace(" ", "")
.lower()
)
Expand Down Expand Up @@ -409,6 +409,6 @@ def reformat_plenary_data(plenaries):
# Sorting days like this only works in this very specific case.
session_day_data.sort()
session_day_data = [
(f"jul1{idx}", day, idx == 0) for idx, day in enumerate(session_day_data)
(f"july1{idx}", day, idx == 0) for idx, day in enumerate(session_day_data)
]
return session_data, session_day_data
2 changes: 1 addition & 1 deletion templates/components.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ul class="nav nav-pills justify-content-center">
{% for tab in tab_group %}
<li class="nav-item">
<a class="nav-link {{tab[2]}}" data-toggle="tab" href="#tab-{{tab[0]}}" role="tab" aria-controls="nav-home"
<a id="link-{{tab[0]}}" class="nav-link {{tab[2]}}" data-toggle="tab" href="#tab-{{tab[0]}}" role="tab" aria-controls="nav-home"
aria-selected="true">{{tab[1]}}
</a>
</li>
Expand Down
20 changes: 18 additions & 2 deletions templates/sessions.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{% for session in sessions[day] %}
{% if session.type not in excluded_session_types and not session.name.startswith('Diversity and
Inclusion') %}
<div class="row p-4 col-md-12">
<div class="row p-4 col-md-12" id="{{ session.id }}">
{% if session.type == 'Tutorials' %}
<div class="row col-12">
{% set tutorial_event = session.tutorial_events | take_one %}
Expand Down Expand Up @@ -64,7 +64,7 @@ <h5>{{ event_type }} Presentations</h5>
<div class="col-12 mb-4">
<div class="card">
<div class="card-header">
<div class="row">
<div class="row" id="{{ event.id }}">
<div class='col-sm-7'>
<h5 class='text-left'>{{ event.track }} ({{ event.type }})</h5>
</div>
Expand Down Expand Up @@ -119,7 +119,23 @@ <h5 class='text-right'>Room: {{ event.room }}</h5>
<script>
$(document).ready(() => {
add_local_tz('.session_times');
var hash = window.location.hash;
if (hash.startsWith('#link-')) {
var parts = hash.split('-')
if (parts.length >= 2) {
var tab_link = parts[0] + '-' + parts[1];
console.log('Clicking:' + tab_link);
$(tab_link).trigger("click");
if (parts.length >= 3) {
var event_link = parts.slice(2).join('-');
console.log('Href to: ' + event_link);
location.href = '#' + event_link;
}
}

}
});

</script>

{% endblock %}

0 comments on commit 64d117e

Please sign in to comment.