first commit
This commit is contained in:
commit
8c4dcae475
89 changed files with 24623 additions and 0 deletions
393
pages.go
Normal file
393
pages.go
Normal file
|
|
@ -0,0 +1,393 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// pageData is a page struct, it embeds Base and names its template.
|
||||
type pageData interface {
|
||||
base() *Base
|
||||
templateName() string
|
||||
}
|
||||
|
||||
// Base is what base.html reads. renderCode fills in everything but the
|
||||
// category boxes.
|
||||
type Base struct {
|
||||
Nav string
|
||||
APIEnabled bool
|
||||
Theme string
|
||||
CardPagePreview bool
|
||||
Prefs Prefs
|
||||
hasPrefs bool
|
||||
ShowCatBoxes bool
|
||||
CatCounts map[string]int
|
||||
ActiveCategory string
|
||||
}
|
||||
|
||||
func (b *Base) base() *Base { return b }
|
||||
|
||||
func pageWith(prefs Prefs) Base { return Base{Prefs: prefs, hasPrefs: true} }
|
||||
|
||||
type cardView struct {
|
||||
Docs []*Document
|
||||
ShowThumbs bool
|
||||
CardPagePreview bool
|
||||
HideClassification bool
|
||||
HideJournalists bool
|
||||
HidePeople bool
|
||||
HidePrograms bool
|
||||
HideSummary bool
|
||||
FOIAQS string // see Prefs.foiaLinkQS
|
||||
ShowUnpin bool
|
||||
ActiveCategory string
|
||||
ActiveValue string
|
||||
MarkReported bool // the "reported" badge on individually reported SIDtoday issues
|
||||
}
|
||||
|
||||
// listView is a page of documents as cards or as a table
|
||||
type listView struct {
|
||||
Docs []*Document
|
||||
Total int
|
||||
Page int
|
||||
TotalPages int
|
||||
View string
|
||||
Sort string
|
||||
Order string
|
||||
DefaultSort string
|
||||
BaseURL string
|
||||
SortURL string
|
||||
TableHeads []sortHead
|
||||
RowsHTML template.HTML // the table view's rows, pre-rendered
|
||||
Cards cardView
|
||||
// MarkReported badges the individually reported SIDtoday issues, which
|
||||
// only the SIDtoday tab tells apart from the bulk release.
|
||||
MarkReported bool
|
||||
}
|
||||
|
||||
// docTableRow is a row of the document table
|
||||
type docTableRow struct {
|
||||
*Document
|
||||
MarkReported bool
|
||||
}
|
||||
|
||||
func (lv listView) TableRows() []docTableRow {
|
||||
rows := make([]docTableRow, len(lv.Docs))
|
||||
for i, d := range lv.Docs {
|
||||
rows[i] = docTableRow{d, lv.MarkReported}
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
type viewer struct {
|
||||
Images []string
|
||||
Sizes []imageSize
|
||||
ImageBase string
|
||||
Content template.HTML
|
||||
Version *DocVersion
|
||||
}
|
||||
|
||||
func (v viewer) ImageSize(i int) template.HTMLAttr {
|
||||
if i < len(v.Sizes) {
|
||||
return v.Sizes[i].Attr()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type notFoundPage struct {
|
||||
Base
|
||||
Path string
|
||||
}
|
||||
|
||||
type aboutPage struct{ Base }
|
||||
|
||||
type indexPage struct {
|
||||
Base
|
||||
homeFigures
|
||||
TrackRecent bool
|
||||
RecentDocs []*Document
|
||||
SnowdenTotal int
|
||||
ArchiveTotal int
|
||||
FOIATotal int
|
||||
IncludeFOIA bool
|
||||
ReportedTotal int
|
||||
WithSIDtoday bool // the figures include the SIDtoday archive (/?sidtoday=1)
|
||||
}
|
||||
|
||||
// browsePage is /browse
|
||||
type browsePage struct {
|
||||
Base
|
||||
listView
|
||||
Collection string
|
||||
CollectionCounts map[string]int
|
||||
SIDTodayCount int
|
||||
SelectedTypes map[string]bool
|
||||
AllTypes map[string]int
|
||||
Params url.Values
|
||||
SeriesList []categoryEntry
|
||||
ArchiveYears []archiveYear
|
||||
TimelineHTML template.HTML
|
||||
}
|
||||
|
||||
// categoryPage is /browse/{category}
|
||||
type categoryPage struct {
|
||||
Base
|
||||
Title string
|
||||
Blurb string
|
||||
Heads []sortHead
|
||||
RowsHTML template.HTML
|
||||
Entries []categoryEntry
|
||||
CollCols bool
|
||||
ShowCollCols bool
|
||||
ShowAZ bool
|
||||
Letters []string
|
||||
SeeAlso []seeAlsoLink
|
||||
}
|
||||
|
||||
// listPage is /browse/{category}/{value}
|
||||
type listPage struct {
|
||||
Base
|
||||
listView
|
||||
Title string
|
||||
CatLabel string
|
||||
Blurb string
|
||||
SearchLink string
|
||||
SelectedTypes map[string]bool
|
||||
AllTypes map[string]int
|
||||
Params url.Values
|
||||
GlossaryEntry *GlossaryEntry
|
||||
Refinements []searchFacet
|
||||
Breakdowns []bdGroup
|
||||
Timeline []timelineBar
|
||||
PubTimeline []timelineBar
|
||||
YearScope string
|
||||
YearScopeAllURL string
|
||||
MonthNav []monthNavEntry
|
||||
MonthNavYear string
|
||||
MonthNavYearURL string
|
||||
MonthNavYearActive bool
|
||||
MonthlessCount int
|
||||
}
|
||||
|
||||
type docPage struct {
|
||||
Base
|
||||
viewer
|
||||
Doc *Document
|
||||
BrowseQS string
|
||||
OGImageURL string
|
||||
DocAbsURL string
|
||||
Embeds docEmbeds
|
||||
SeriesGroup *seriesGroup
|
||||
Assemblies []*Assembly
|
||||
SerialPrev *Document
|
||||
SerialNext *Document
|
||||
PublishedTogether []*Document
|
||||
PublishedShown int
|
||||
PublishedMore []*Article
|
||||
PublishedCards cardView
|
||||
RelatedDocs []*Document
|
||||
RelatedCards cardView
|
||||
Pinned bool
|
||||
}
|
||||
|
||||
type versionPage struct {
|
||||
Base
|
||||
viewer
|
||||
Doc *Document
|
||||
Publications []Publication
|
||||
PDFURL string
|
||||
}
|
||||
|
||||
// pagesPage is the page-image grid of a document or of one of its versions.
|
||||
type pagesPage struct {
|
||||
Base
|
||||
viewer
|
||||
Doc *Document
|
||||
TextOnly bool
|
||||
}
|
||||
|
||||
type articlesPage struct {
|
||||
Base
|
||||
Groups []articleYearGroup
|
||||
GroupsHTML template.HTML
|
||||
Total int
|
||||
Books int
|
||||
}
|
||||
|
||||
type articlePage struct {
|
||||
Base
|
||||
Article Article
|
||||
Total int
|
||||
BrowseQS string
|
||||
PublisherURL string
|
||||
Cards cardView
|
||||
}
|
||||
|
||||
type assembliesPage struct {
|
||||
Base
|
||||
Assemblies []*Assembly
|
||||
TextOnly bool
|
||||
}
|
||||
|
||||
type assemblyPage struct {
|
||||
Base
|
||||
Assembly *Assembly
|
||||
TextOnly bool
|
||||
}
|
||||
|
||||
type changelogPage struct {
|
||||
Base
|
||||
Entries []ChangeEntry
|
||||
Total int
|
||||
}
|
||||
|
||||
type codewordsPage struct {
|
||||
Base
|
||||
Rows []codewordRow
|
||||
RowsHTML template.HTML
|
||||
Total int
|
||||
Shown int
|
||||
Heads []sortHead
|
||||
}
|
||||
|
||||
type explorePage struct {
|
||||
Base
|
||||
Metrics []exploreMetric
|
||||
HasAssemblies bool
|
||||
}
|
||||
|
||||
type exploreTablePage struct {
|
||||
Base
|
||||
Metric *exploreMetric
|
||||
Rows []exploreRow
|
||||
RowsHTML template.HTML
|
||||
Total int
|
||||
Shown int
|
||||
Heads []sortHead
|
||||
}
|
||||
|
||||
type classPatternsPage struct {
|
||||
Base
|
||||
Cols []facetEntry
|
||||
Levels []string
|
||||
Strips []clsYearRow
|
||||
Sparse []clsYearRow
|
||||
MinMarks int
|
||||
HeatRows []heatRow
|
||||
}
|
||||
|
||||
type idsPage struct {
|
||||
Base
|
||||
Rows []idRow
|
||||
RowsHTML template.HTML
|
||||
Shown int
|
||||
}
|
||||
|
||||
type glossaryPage struct {
|
||||
Base
|
||||
Groups []glossaryGroup
|
||||
GroupsHTML template.HTML
|
||||
Total int
|
||||
}
|
||||
|
||||
type outletsPage struct {
|
||||
Base
|
||||
Table outletTable
|
||||
NewsOnly bool
|
||||
}
|
||||
|
||||
type portionsPage struct {
|
||||
Base
|
||||
Title string
|
||||
Stats portionSummary
|
||||
RowLimit int
|
||||
}
|
||||
|
||||
type pinnedPage struct {
|
||||
Base
|
||||
Total int
|
||||
Searches []recentSearch
|
||||
Full bool // a pin was refused: the cookie is full
|
||||
Cards cardView
|
||||
}
|
||||
|
||||
type preferencesPage struct {
|
||||
Base
|
||||
MaxCards int
|
||||
Saved bool
|
||||
Reset bool
|
||||
}
|
||||
|
||||
type searchPage struct {
|
||||
Base
|
||||
FieldOptions []searchField
|
||||
Facets []searchFacet
|
||||
Queries []string
|
||||
Fields []string
|
||||
Conjs []string
|
||||
Results []searchResult
|
||||
SearchTypeCounts map[string]int
|
||||
SelTypeSet map[string]bool
|
||||
FormParams url.Values
|
||||
Savable bool
|
||||
ShowThumbs bool
|
||||
FOIAQS string
|
||||
Total int
|
||||
Page int
|
||||
TotalPages int
|
||||
RecentSearches []recentSearch
|
||||
SelColl map[string]bool
|
||||
CollFiltered bool
|
||||
CanonicalQS string
|
||||
SearchPinned bool
|
||||
Searched bool
|
||||
QueryLabel string
|
||||
DateDocStart string
|
||||
DateDocEnd string
|
||||
DatePubStart string
|
||||
DatePubEnd string
|
||||
Sort string
|
||||
Order string
|
||||
SearchBaseURL string
|
||||
DateHist []timelineBar
|
||||
SnippetsCapped bool
|
||||
SnippetLimit int
|
||||
OverClauses int
|
||||
ClauseLimit int
|
||||
OverWords int
|
||||
WordLimit int
|
||||
}
|
||||
|
||||
func (*notFoundPage) templateName() string { return "404.html" }
|
||||
func (*aboutPage) templateName() string { return "about.html" }
|
||||
func (*indexPage) templateName() string { return "index.html" }
|
||||
func (*browsePage) templateName() string { return "browse.html" }
|
||||
func (*categoryPage) templateName() string { return "category.html" }
|
||||
func (*listPage) templateName() string { return "list.html" }
|
||||
func (*docPage) templateName() string { return "doc.html" }
|
||||
func (*versionPage) templateName() string { return "version.html" }
|
||||
func (*pagesPage) templateName() string { return "pages.html" }
|
||||
func (*articlesPage) templateName() string { return "articles.html" }
|
||||
func (*articlePage) templateName() string { return "article.html" }
|
||||
func (*assembliesPage) templateName() string { return "assemblies.html" }
|
||||
func (*assemblyPage) templateName() string { return "assembly.html" }
|
||||
func (*changelogPage) templateName() string { return "changelog.html" }
|
||||
func (*codewordsPage) templateName() string { return "codewords.html" }
|
||||
func (*explorePage) templateName() string { return "explore.html" }
|
||||
func (*exploreTablePage) templateName() string { return "explore_table.html" }
|
||||
func (*classPatternsPage) templateName() string { return "classpatterns.html" }
|
||||
func (*idsPage) templateName() string { return "ids.html" }
|
||||
func (*glossaryPage) templateName() string { return "glossary.html" }
|
||||
func (*outletsPage) templateName() string { return "outlets.html" }
|
||||
func (*portionsPage) templateName() string { return "portions.html" }
|
||||
func (*pinnedPage) templateName() string { return "pinned.html" }
|
||||
func (*preferencesPage) templateName() string { return "preferences.html" }
|
||||
func (*searchPage) templateName() string { return "search.html" }
|
||||
|
||||
var pageTypes = []pageData{
|
||||
¬FoundPage{}, &aboutPage{}, &indexPage{}, &browsePage{}, &categoryPage{}, &listPage{},
|
||||
&docPage{}, &versionPage{}, &pagesPage{}, &articlesPage{}, &articlePage{}, &assembliesPage{},
|
||||
&assemblyPage{}, &changelogPage{}, &codewordsPage{}, &explorePage{}, &exploreTablePage{},
|
||||
&classPatternsPage{}, &idsPage{}, &glossaryPage{}, &outletsPage{}, &portionsPage{},
|
||||
&pinnedPage{}, &preferencesPage{}, &searchPage{},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue