Skip to content

Commit

Permalink
Merge pull request #60 from acl-org/papers-page
Browse files Browse the repository at this point in the history
Add an option to select the program from
  • Loading branch information
jcklie authored Oct 28, 2020
2 parents e53e457 + b4c1c0c commit aa9c558
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 49 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ node_modules/

# MacOS
.DS_Store

.vscode
50 changes: 42 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,43 @@ def chat():

@app.route("/papers.json")
def papers_json():
return jsonify(site_data["papers"])
all_papers = []
all_papers.extend(site_data["papers"])
for wsh in site_data["workshops"]:
all_papers.extend(wsh.papers)
return jsonify(all_papers)


@app.route("/track_<track_name>.json")
def track_json(track_name):
@app.route("/papers_<program>.json")
def papers_program(program):
paper: Paper
papers_for_track = [
paper for paper in site_data["papers"] if paper.content.track == track_name
]
if program == "workshop":
papers_for_program = []
for wsh in site_data["workshops"]:
papers_for_program.extend(wsh.papers)
else:
papers_for_program = [
paper for paper in site_data["papers"] if paper.content.program == program
]
return jsonify(papers_for_program)


@app.route("/track_<program_name>_<track_name>.json")
def track_json(program_name, track_name):
paper: Paper
if program_name == "workshop":
papers_for_track = None
for wsh in site_data["workshops"]:
if wsh.title == track_name:
papers_for_track = wsh.papers
break
else:
papers_for_track = [
paper
for paper in site_data["papers"]
if paper.content.track == track_name
and paper.content.program == program_name
]
return jsonify(papers_for_track)


Expand All @@ -216,8 +244,14 @@ def generator():
paper: Paper
for paper in site_data["papers"]:
yield "paper", {"uid": paper.id}
for track in site_data["tracks"]:
yield "track_json", {"track_name": track}
for program in site_data["programs"]:
yield "papers_program", {"program": program}
for track in site_data["tracks"]:
yield "track_json", {"track_name": track, "program_name": program}

yield "papers_program", {"program": "workshop"}
for wsh in site_data["workshops"]:
yield "track_json", {"track_name": wsh.title, "program_name": "workshop"}
plenary_session: PlenarySession
for _, plenary_sessions_on_date in site_data["plenary_sessions"].items():
for plenary_session in plenary_sessions_on_date:
Expand Down
36 changes: 35 additions & 1 deletion miniconf/load_site_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ def load_site_data(
]
site_data["plenary_session_days"][0][-1] = "active"

# Papers' progam to their data
for p in (
site_data["main_papers"] + site_data["cl_papers"] + site_data["tacl_papers"]
):
p["program"] = "main"

for p in site_data["demo_papers"]:
p["program"] = "demo"

for p in site_data["srw_papers"]:
p["program"] = "srw"

site_data["programs"] = ["main", "demo", "findings", "srw", "workshop"]

# papers.{html,json}
papers = build_papers(
raw_papers=site_data["main_papers"]
Expand Down Expand Up @@ -653,6 +667,7 @@ def build_papers(
paper_type=item.get("paper_type", ""),
sessions=sessions_for_paper[item["UID"]],
similar_paper_uids=paper_recs.get(item["UID"], [item["UID"]]),
program=item["program"],
),
)
for item in raw_papers
Expand Down Expand Up @@ -711,6 +726,11 @@ def build_workshops(
raw_workshop_papers: Dict[str, List[Dict[str, Any]]],
workshop_schedules: Dict[str, List[Dict[str, Any]]],
) -> List[Workshop]:
def workshop_title(workshop_id):
for wsh in raw_workshops:
if wsh["UID"] == workshop_id:
return wsh["title"]
return ""

workshop_papers: DefaultDict[str, List[WorkshopPaper]] = defaultdict(list)
for workshop_id, papers in raw_workshop_papers.items():
Expand All @@ -720,7 +740,21 @@ def build_workshops(
id=item["UID"],
title=item["title"],
speakers=item["speakers"],
presentation_id=item.get("presentation_id", ""),
presentation_id=item.get("presentation_id", None),
content=PaperContent(
title=item["title"],
authors=[item["speakers"]],
track=workshop_title(workshop_id),
paper_type=None,
abstract=None,
tldr=None,
keywords=[],
pdf_url=None,
demo_url=None,
sessions=[],
similar_paper_uids=[],
program="workshop",
),
)
)

Expand Down
8 changes: 6 additions & 2 deletions miniconf/site_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,19 @@ class PaperContent:
demo_url: Optional[str]
sessions: List[SessionInfo]
similar_paper_uids: List[str]
program: str

def __post_init__(self):
assert self.track, self
if self.program != "workshop":
assert self.track, self
if self.pdf_url:
assert self.pdf_url.startswith("https://"), self.pdf_url
if self.demo_url:
assert self.demo_url.startswith("https://") or self.demo_url.startswith(
"http://"
), self.demo_url
assert self.paper_type[0].isupper(), self
if self.program != "workshop":
assert self.paper_type[0].isupper(), self


@dataclass(frozen=True)
Expand Down Expand Up @@ -178,6 +181,7 @@ class WorkshopPaper:
title: str
speakers: str
presentation_id: Optional[str]
content: PaperContent


@dataclass(frozen=True)
Expand Down
18 changes: 18 additions & 0 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,21 @@ div#papers_options > div {
.card-link-warning {
color: #ffc107 !important;
}

.button-box {
display: flex;
}

.bottom-bar {
margin-bottom: 0em;
}

@media (max-width: 768px) {
.button-box {
display: block;
}

.bottom-bar {
margin-bottom: 1em;
}
}
3 changes: 3 additions & 0 deletions static/js/little_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,18 @@ let calcAllKeys = function (allPapers, allKeys) {
const collectAuthors = new Set();
const collectKeywords = new Set();
const collectSessions = new Set();
const collectTracks = new Set();

allPapers.forEach(
d => {
d.content.authors.forEach(a => collectAuthors.add(a));
d.content.keywords.forEach(a => collectKeywords.add(a));
d.content.sessions.forEach(a => collectSessions.add(a));
collectTracks.add(d.content.track);
allKeys.titles.push(d.content.title);
});
allKeys.authors = Array.from(collectAuthors);
allKeys.keywords = Array.from(collectKeywords);
allKeys.sessions = Array.from(collectSessions);
allKeys.tracks = Array.from(collectTracks).sort();
};
Loading

0 comments on commit aa9c558

Please sign in to comment.