mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
Refactored Startpage
This commit is contained in:
@@ -8,6 +8,7 @@ full_bin = "./tmp/musenalm --dir ./pb_data serve"
|
||||
cmd = "go build -tags=dev,fts5,sqlite_icu -o ./tmp/musenalm ."
|
||||
delay = 400
|
||||
exclude_dir = [
|
||||
"views/transform",
|
||||
"views/routes",
|
||||
"views/layouts",
|
||||
"views/assets",
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
package dbmodels
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
type EntriesAgents map[string][]*REntriesAgents
|
||||
|
||||
func EntriesForID(app core.App, query int) ([]*Entry, error) {
|
||||
entries := []*Entry{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
Where(dbx.HashExp{MUSENALMID_FIELD: strconv.Itoa(query)}).
|
||||
All(&entries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func YearsForEntries(app core.App) ([]int, error) {
|
||||
rec := []core.Record{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
Select(YEAR_FIELD + " AS id").
|
||||
Distinct(true).
|
||||
OrderBy("id").
|
||||
All(&rec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
years := []int{}
|
||||
for _, r := range rec {
|
||||
years = append(years, r.GetInt("id"))
|
||||
}
|
||||
|
||||
return years, nil
|
||||
}
|
||||
|
||||
func EntriesForYear(app core.App, year int) ([]*Entry, error) {
|
||||
entries := []*Entry{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
Where(dbx.HashExp{YEAR_FIELD: year}).
|
||||
All(&entries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func EntriesForAgent(app core.App, agentId string) ([]*Entry, EntriesAgents, error) {
|
||||
relations := []*core.Record{}
|
||||
err := app.RecordQuery(RelationTableName(ENTRIES_TABLE, AGENTS_TABLE)).
|
||||
Where(dbx.HashExp{AGENTS_TABLE: agentId}).
|
||||
All(&relations)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
app.ExpandRecords(relations, []string{ENTRIES_TABLE}, nil)
|
||||
entries := []*Entry{}
|
||||
for _, r := range relations {
|
||||
record := r.ExpandedOne(ENTRIES_TABLE)
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
entries = append(entries, NewEntry(record))
|
||||
}
|
||||
|
||||
agents := map[string][]*REntriesAgents{}
|
||||
for _, r := range relations {
|
||||
agent := NewREntriesAgents(r)
|
||||
agents[agent.Entry()] = append(agents[agent.Entry()], agent)
|
||||
}
|
||||
|
||||
return entries, agents, nil
|
||||
}
|
||||
|
||||
func EntriesForPlace(app core.App, placeId string) ([]*Entry, error) {
|
||||
entries := []*Entry{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
Where(dbx.Like(PLACES_TABLE, placeId).Match(true, true)).
|
||||
All(&entries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func EntryForId(app core.App, id string) (*Entry, error) {
|
||||
entry := &Entry{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
Where(dbx.HashExp{ID_FIELD: id}).
|
||||
One(entry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entry, nil
|
||||
}
|
||||
|
||||
func EntriesForIds(app core.App, ids []any) ([]*Entry, error) {
|
||||
entries := []*Entry{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
Where(dbx.HashExp{ID_FIELD: ids}).
|
||||
All(&entries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func EntryForMusenalmID(app core.App, id string) (*Entry, error) {
|
||||
entry := &Entry{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
Where(dbx.HashExp{MUSENALMID_FIELD: id}).
|
||||
One(entry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entry, nil
|
||||
}
|
||||
|
||||
func EntriesForContents(app core.App, contents []*Content) (map[string]*Entry, error) {
|
||||
cids := []any{}
|
||||
for _, c := range contents {
|
||||
cids = append(cids, c.Entry())
|
||||
}
|
||||
|
||||
entries := []*Entry{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
Where(dbx.HashExp{ID_FIELD: cids}).
|
||||
All(&entries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
entriesMap := make(map[string]*Entry, len(entries))
|
||||
for _, e := range entries {
|
||||
entriesMap[e.Id] = e
|
||||
}
|
||||
|
||||
return entriesMap, nil
|
||||
}
|
||||
@@ -103,6 +103,11 @@ func Series_IDs(app core.App, ids []any) ([]*Series, error) {
|
||||
return TableByIDs[[]*Series](app, SERIES_TABLE, ids)
|
||||
}
|
||||
|
||||
func Series_ID(app core.App, id string) (*Series, error) {
|
||||
ret, err := TableByID[Series](app, SERIES_TABLE, id)
|
||||
return &ret, err
|
||||
}
|
||||
|
||||
func Places_IDs(app core.App, ids []any) ([]*Place, error) {
|
||||
return TableByIDs[[]*Place](app, PLACES_TABLE, ids)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dbmodels
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/helpers/datatypes"
|
||||
@@ -69,7 +68,7 @@ outer_loop:
|
||||
ids = append(ids, id.ID)
|
||||
}
|
||||
|
||||
altseries, err := SeriessesForIds(app, ids)
|
||||
altseries, err := Series_IDs(app, ids)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -99,246 +98,3 @@ func TitleSearchSeries(app core.App, query string) ([]*Series, error) {
|
||||
|
||||
return series, nil
|
||||
}
|
||||
|
||||
// INFO: expects a normalized query string
|
||||
// Returns all ids that match the query
|
||||
func FTS5SearchSeries(app core.App, query string) ([]*FTS5IDQueryResult, error) {
|
||||
seriesids := []*FTS5IDQueryResult{}
|
||||
q := NewFTS5Query().
|
||||
From(SERIES_TABLE).
|
||||
SelectID()
|
||||
|
||||
queries := strings.Split(query, " ")
|
||||
for _, que := range queries {
|
||||
que := datatypes.NormalizeString(que)
|
||||
if len(que) >= 3 {
|
||||
q.AndMatch([]string{SERIES_TITLE_FIELD, ANNOTATION_FIELD, REFERENCES_FIELD}, que)
|
||||
}
|
||||
}
|
||||
|
||||
querystring := q.Query()
|
||||
if querystring == "" {
|
||||
return seriesids, nil
|
||||
}
|
||||
|
||||
err := app.DB().NewQuery(querystring).All(&seriesids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return seriesids, nil
|
||||
}
|
||||
|
||||
func IDsForSeriesses(series []*Series) []any {
|
||||
ids := []any{}
|
||||
for _, s := range series {
|
||||
ids = append(ids, s.Id)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
func makeMapForEnrySeries(relations []*REntriesSeries, entries map[string]*Entry) SeriesEntries {
|
||||
m := map[string][]*REntriesSeries{}
|
||||
for _, r := range relations {
|
||||
m[r.Series()] = append(m[r.Series()], r)
|
||||
}
|
||||
|
||||
for _, rel := range m {
|
||||
slices.SortFunc(rel, func(i, j *REntriesSeries) int {
|
||||
ientry := entries[i.Entry()]
|
||||
jentry := entries[j.Entry()]
|
||||
return ientry.Year() - jentry.Year()
|
||||
})
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func EntriesForSeriesses(app core.App, series []*Series) (
|
||||
SeriesEntries,
|
||||
map[string]*Entry,
|
||||
error) {
|
||||
ids := IDsForSeriesses(series)
|
||||
relations := []*core.Record{}
|
||||
|
||||
err := app.RecordQuery(RelationTableName(ENTRIES_TABLE, SERIES_TABLE)).
|
||||
Where(dbx.HashExp{
|
||||
SERIES_TABLE: ids,
|
||||
}).
|
||||
All(&relations)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
app.ExpandRecords(relations, []string{ENTRIES_TABLE}, nil)
|
||||
bmap := map[string]*Entry{}
|
||||
for _, r := range relations {
|
||||
record := r.ExpandedOne(ENTRIES_TABLE)
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
entry := NewEntry(record)
|
||||
bmap[entry.Id] = entry
|
||||
}
|
||||
|
||||
smap := map[string][]*REntriesSeries{}
|
||||
for _, r := range relations {
|
||||
rel := NewREntriesSeries(r)
|
||||
smap[rel.Series()] = append(smap[rel.Series()], rel)
|
||||
}
|
||||
|
||||
for _, rel := range smap {
|
||||
slices.SortFunc(rel, func(i, j *REntriesSeries) int {
|
||||
ientry := bmap[i.Entry()]
|
||||
jentry := bmap[j.Entry()]
|
||||
return ientry.Year() - jentry.Year()
|
||||
})
|
||||
}
|
||||
|
||||
return smap, bmap, nil
|
||||
}
|
||||
|
||||
func LettersForSeries(app core.App) ([]string, error) {
|
||||
letters := []core.Record{}
|
||||
ids := []string{}
|
||||
|
||||
err := app.RecordQuery(SERIES_TABLE).
|
||||
Select("upper(substr(" + SERIES_TITLE_FIELD + ", 1, 1)) AS id").
|
||||
Distinct(true).
|
||||
All(&letters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, l := range letters {
|
||||
ids = append(ids, l.GetString("id"))
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
func AllAgentsForSeries(app core.App) ([]*Agent, error) {
|
||||
rels := []*core.Record{}
|
||||
// INFO: we could just fetch all relations here
|
||||
err := app.RecordQuery(RelationTableName(ENTRIES_TABLE, AGENTS_TABLE)).
|
||||
GroupBy(AGENTS_TABLE).
|
||||
All(&rels)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
app.ExpandRecords(rels, []string{AGENTS_TABLE}, nil)
|
||||
agents := []*Agent{}
|
||||
for _, r := range rels {
|
||||
record := r.ExpandedOne(AGENTS_TABLE)
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
agent := NewAgent(record)
|
||||
agents = append(agents, agent)
|
||||
}
|
||||
|
||||
SortAgentsByName(agents)
|
||||
|
||||
return agents, err
|
||||
}
|
||||
|
||||
func SeriesForLetter(app core.App, letter string) ([]*Series, error) {
|
||||
series := []*Series{}
|
||||
err := app.RecordQuery(SERIES_TABLE).
|
||||
Where(dbx.Like(SERIES_TITLE_FIELD, letter).Match(false, true)).
|
||||
OrderBy(SERIES_TITLE_FIELD).
|
||||
All(&series)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return series, nil
|
||||
}
|
||||
|
||||
func SeriesForAgent(app core.App, id string) ([]*Series, SeriesEntries, map[string]*Entry, error) {
|
||||
entries, _, err := EntriesForAgent(app, id)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
return SeriesForEntries(app, entries)
|
||||
}
|
||||
|
||||
func SeriesForPlace(app core.App, id string) ([]*Series, SeriesEntries, map[string]*Entry, error) {
|
||||
entries, err := EntriesForPlace(app, id)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
return SeriesForEntries(app, entries)
|
||||
}
|
||||
|
||||
func SeriesForEntries(app core.App, entries []*Entry) ([]*Series, SeriesEntries, map[string]*Entry, error) {
|
||||
bids := make([]any, 0, len(entries))
|
||||
for _, e := range entries {
|
||||
bids = append(bids, e.Id)
|
||||
}
|
||||
|
||||
srels := []*REntriesSeries{}
|
||||
err := app.RecordQuery(RelationTableName(ENTRIES_TABLE, SERIES_TABLE)).
|
||||
Where(dbx.HashExp{ENTRIES_TABLE: bids}).
|
||||
All(&srels)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
sids := []any{}
|
||||
for _, s := range srels {
|
||||
sids = append(sids, s.Series())
|
||||
}
|
||||
|
||||
series := []*Series{}
|
||||
err = app.RecordQuery(SERIES_TABLE).
|
||||
Where(dbx.HashExp{ID_FIELD: sids}).
|
||||
All(&series)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
bmap := make(map[string]*Entry, len(entries))
|
||||
for _, e := range entries {
|
||||
bmap[e.Id] = e
|
||||
}
|
||||
|
||||
smap := makeMapForEnrySeries(srels, bmap)
|
||||
|
||||
return series, smap, bmap, nil
|
||||
}
|
||||
|
||||
func SeriesForYear(app core.App, year int) ([]*Series, SeriesEntries, map[string]*Entry, error) {
|
||||
series, err := EntriesForYear(app, year)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
return SeriesForEntries(app, series)
|
||||
}
|
||||
|
||||
func SeriesForId(app core.App, id string) (*Series, error) {
|
||||
s := &Series{}
|
||||
err := app.RecordQuery(SERIES_TABLE).
|
||||
Where(dbx.HashExp{MUSENALMID_FIELD: id}).
|
||||
One(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func SeriessesForIds(app core.App, ids []any) ([]*Series, error) {
|
||||
series := []*Series{}
|
||||
err := app.RecordQuery(SERIES_TABLE).
|
||||
Where(dbx.HashExp{ID_FIELD: ids}).
|
||||
All(&series)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return series, nil
|
||||
}
|
||||
|
||||
@@ -35,17 +35,27 @@ func (p *ReihePage) Setup(router *router.Router[*core.RequestEvent], app core.Ap
|
||||
router.GET(URL_REIHE, func(e *core.RequestEvent) error {
|
||||
id := e.Request.PathValue("id")
|
||||
data := make(map[string]interface{})
|
||||
reihe, err := dbmodels.SeriesForId(app, id)
|
||||
reihe, err := dbmodels.Series_ID(app, id)
|
||||
if err != nil {
|
||||
return engine.Response404(e, err, data)
|
||||
}
|
||||
data["series"] = reihe
|
||||
|
||||
rmap, emap, err := dbmodels.EntriesForSeriesses(app, []*dbmodels.Series{reihe})
|
||||
entries, relations, err := Entries_Series_IDs(app, []any{id})
|
||||
if err != nil {
|
||||
return engine.Response404(e, err, data)
|
||||
}
|
||||
|
||||
emap := make(map[string]*dbmodels.Entry)
|
||||
for _, entry := range entries {
|
||||
emap[entry.Id] = entry
|
||||
}
|
||||
|
||||
rmap := make(map[string][]*dbmodels.REntriesSeries)
|
||||
for _, relation := range relations {
|
||||
rmap[relation.Series()] = append(rmap[relation.Series()], relation)
|
||||
}
|
||||
|
||||
data["relations"] = rmap[reihe.Id]
|
||||
data["entries"] = emap
|
||||
|
||||
|
||||
133
pages/reihen.go
133
pages/reihen.go
@@ -2,6 +2,7 @@ package pages
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/app"
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels"
|
||||
@@ -150,6 +151,10 @@ func (p *ReihenPage) SearchRequest(app core.App, engine *templating.Engine, e *c
|
||||
|
||||
func (p *ReihenPage) Get(request *core.RequestEvent, engine *templating.Engine, data map[string]interface{}) error {
|
||||
data["common"] = NewCommonReihenData(request.App)
|
||||
record, _ := p.GetLatestData(request.App)
|
||||
if record != nil {
|
||||
data["record"] = pagemodels.NewReihen(record)
|
||||
}
|
||||
return engine.Response200(request, URL_REIHEN, data)
|
||||
}
|
||||
|
||||
@@ -278,15 +283,10 @@ func NewSeriesListResult_Letter(app core.App, letter string) (*SeriesListResult,
|
||||
entriesMap[e.Id] = e
|
||||
}
|
||||
|
||||
rmap, bmap, err := dbmodels.EntriesForSeriesses(app, series)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &SeriesListResult{
|
||||
Series: series,
|
||||
Entries: bmap,
|
||||
EntriesSeries: rmap,
|
||||
Entries: entriesMap,
|
||||
EntriesSeries: relationsMap,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -445,56 +445,121 @@ func NewSeriesResult_Search(app core.App, search string) (*SeriesListResult, err
|
||||
dbmodels.Sort_Series_Title(series)
|
||||
dbmodels.Sort_Series_Title(altseries)
|
||||
|
||||
rmap, bmap, err := dbmodels.EntriesForSeriesses(app, series)
|
||||
keys := []any{}
|
||||
keys = append(keys, dbmodels.Ids(series)...)
|
||||
keys = append(keys, dbmodels.Ids(altseries)...)
|
||||
|
||||
entries, relations, err := Entries_Series_IDs(app, keys)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rmap2, bmap2, err := dbmodels.EntriesForSeriesses(app, altseries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
relationsMap := make(map[string][]*dbmodels.REntriesSeries)
|
||||
entriesMap := make(map[string]*dbmodels.Entry)
|
||||
for _, v := range relations {
|
||||
relationsMap[v.Series()] = append(relationsMap[v.Series()], v)
|
||||
}
|
||||
|
||||
for k, v := range rmap2 {
|
||||
rmap[k] = v
|
||||
}
|
||||
for k, v := range bmap2 {
|
||||
bmap[k] = v
|
||||
for _, v := range entries {
|
||||
entriesMap[v.Id] = v
|
||||
}
|
||||
|
||||
ids := []*dbmodels.Series{}
|
||||
if searchint, err := strconv.Atoi(search); err == nil {
|
||||
identries, err := dbmodels.EntriesForID(app, searchint)
|
||||
ret := &SeriesListResult{
|
||||
Series: series,
|
||||
AltSeries: altseries,
|
||||
Entries: entriesMap,
|
||||
EntriesSeries: relationsMap,
|
||||
}
|
||||
|
||||
if _, err := strconv.Atoi(strings.TrimSpace(search)); err == nil {
|
||||
identries := []*dbmodels.Entry{}
|
||||
err := app.RecordQuery(dbmodels.ENTRIES_TABLE).
|
||||
Where(dbx.HashExp{dbmodels.MUSENALMID_FIELD: search}).
|
||||
All(&identries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(identries) != 0 {
|
||||
|
||||
idseries, rmap3, bmap3, err := dbmodels.SeriesForEntries(app, identries)
|
||||
app.Logger().Info("Found entries by musenalmid", "count", len(identries))
|
||||
idseries, idrelations, err := Series_Entries(app, identries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ids = idseries
|
||||
|
||||
dbmodels.Sort_Series_Title(idseries)
|
||||
ret.IDSeries = idseries
|
||||
|
||||
for k, v := range rmap3 {
|
||||
rmap[k] = v
|
||||
for _, v := range idrelations {
|
||||
ret.EntriesSeries[v.Series()] = append(relationsMap[v.Series()], v)
|
||||
}
|
||||
|
||||
for k, v := range bmap3 {
|
||||
bmap[k] = v
|
||||
for _, v := range identries {
|
||||
ret.Entries[v.Id] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &SeriesListResult{
|
||||
Series: series,
|
||||
Entries: bmap,
|
||||
EntriesSeries: rmap,
|
||||
IDSeries: ids,
|
||||
AltSeries: altseries,
|
||||
}, nil
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (r *SeriesListResult) Count() int {
|
||||
return len(r.Series) + len(r.AltSeries) + len(r.IDSeries)
|
||||
}
|
||||
|
||||
func Entries_Series(app core.App, series []*dbmodels.Series) ([]*dbmodels.Entry, []*dbmodels.REntriesSeries, error) {
|
||||
relations, err := dbmodels.REntriesSeries_Seriess(app, dbmodels.Ids(series))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
eids := []any{}
|
||||
for _, r := range relations {
|
||||
eids = append(eids, r.Entry())
|
||||
}
|
||||
|
||||
entries, err := dbmodels.Entries_IDs(app, eids)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return entries, relations, nil
|
||||
}
|
||||
|
||||
func Entries_Series_IDs(app core.App, ids []any) ([]*dbmodels.Entry, []*dbmodels.REntriesSeries, error) {
|
||||
relations, err := dbmodels.REntriesSeries_Seriess(app, ids)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
eids := []any{}
|
||||
for _, r := range relations {
|
||||
eids = append(eids, r.Entry())
|
||||
}
|
||||
|
||||
entries, err := dbmodels.Entries_IDs(app, eids)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return entries, relations, nil
|
||||
}
|
||||
|
||||
func Series_Entries(app core.App, entries []*dbmodels.Entry) ([]*dbmodels.Series, []*dbmodels.REntriesSeries, error) {
|
||||
relations, err := dbmodels.REntriesSeries_Entries(app, dbmodels.Ids(entries))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
sids := []any{}
|
||||
for _, r := range relations {
|
||||
sids = append(sids, r.Series())
|
||||
}
|
||||
|
||||
series, err := dbmodels.Series_IDs(app, sids)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return series, relations, nil
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ const (
|
||||
TEMPLATE_SUCHE = "/suche/"
|
||||
)
|
||||
|
||||
var availableTypes = []string{"reihen", "baende", "beitraege", "personen"}
|
||||
var availableTypes = []string{"baende", "beitraege"}
|
||||
|
||||
func init() {
|
||||
rp := &SuchePage{
|
||||
@@ -72,7 +72,7 @@ func (p *SuchePage) SimpleSearchBaendeRequest(app core.App, engine *templating.E
|
||||
return engine.Response404(e, err, nil)
|
||||
}
|
||||
|
||||
query := dbmodels.NormalizeQuery(params.Query)
|
||||
query := params.NormalizeQuery()
|
||||
if len(query) == 0 {
|
||||
engine.Response404(e, nil, nil)
|
||||
}
|
||||
@@ -165,6 +165,10 @@ func NewParameters(e *core.RequestEvent) (*Parameters, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *Parameters) NormalizeQuery() []string {
|
||||
return dbmodels.NormalizeQuery(p.Query)
|
||||
}
|
||||
|
||||
type SimpleParameters struct {
|
||||
Parameters
|
||||
Annotations bool
|
||||
@@ -196,14 +200,17 @@ func NewSimpleParameters(e *core.RequestEvent, p Parameters) (*SimpleParameters,
|
||||
|
||||
return &SimpleParameters{
|
||||
Parameters: p,
|
||||
// INFO: Common parameters
|
||||
Alm: alm,
|
||||
Title: title,
|
||||
Series: series,
|
||||
Persons: persons,
|
||||
Annotations: annotations,
|
||||
|
||||
// INFO: Baende parameters
|
||||
Places: places,
|
||||
Refs: refs,
|
||||
Annotations: annotations,
|
||||
Year: year,
|
||||
Series: series,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -37,27 +37,25 @@ Modelle umwandeln (zzt RecordProxy)
|
||||
|
||||
- In der Almanach-Ansicht werden die Abkürzungen erklärt
|
||||
- In der Almanach- und Suchansicht werden Sammlungen abgehoben
|
||||
- In der Almanach- und Suchansicht werden auch mehrere Bilder zu einem Eintrag angezeigt
|
||||
- In der Almanach- und Suchansicht werden auch mehrere Bilder zu einem Eintrag angezeigt, falls vorhanden
|
||||
- In der Almanach- und Suchansicht kann nach Inhalten frei gefiltert werden, oder nach Typ
|
||||
|
||||
- Es gibt neue URLs, die fest verlinkt werden können für einzelne:
|
||||
- Es gibt URLs, die fest verlinkt werden können für einzelne:
|
||||
- Personen
|
||||
- Reihen
|
||||
- Bände
|
||||
- Beiträge
|
||||
- Alle Suchanfragen
|
||||
|
||||
- Die Suche ist klar nach Typ unterteilt und insgesamt zuverlässiger
|
||||
- Zusätzlich zur jetzigen Suchfunktion gibt es für jeden Typ noch eine Detailsuche
|
||||
- Zusätzlich zur jetzigen Suchfunktion gibt es für Beiträge und Bände noch eine Detailsuche
|
||||
- Suchergebnisse können nach Typ, Person, Jahr gefiltert werden
|
||||
- Suchergebnisse könnnen nach Jahr und Band, nach Band und Jahr (nach Personen) sortiert werden
|
||||
- Jede Suche hat eine eindeutige URL
|
||||
|
||||
|
||||
TODO danach:
|
||||
- Google-Suchoptimierung
|
||||
- Error Pages prüfen & error-Verhalten von HTMX
|
||||
- Stimmigere Page-Abstraktion
|
||||
- Weißraum in den Antworten
|
||||
- Antworten komprimieren
|
||||
- Cache?
|
||||
- Footer
|
||||
|
||||
@@ -44,7 +44,12 @@
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
<div class="container-normal mt-12" id="">
|
||||
<div class="container-oversize mt-12">
|
||||
<div class="pb-1.5 ml-32"><i class="ri-book-line"></i> Almanach</div>
|
||||
<div class=" border relative pt-0">
|
||||
<div class="ml-32 relative pt-2 bg-stone-50 mt-0 w-max flex flex-col">
|
||||
</div>
|
||||
<div class="container-normal !py-8" id="">
|
||||
<div class="flex flex-col" id="entrydata">
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Almanach-Nummer</div>
|
||||
@@ -76,7 +81,7 @@
|
||||
</div>
|
||||
{{- if $model.result.Entry.ResponsibilityStmt -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Herausgeber</div>
|
||||
<div class="fieldlabel">Herausgeberangabe</div>
|
||||
<div class="fieldvalue">{{ $model.result.Entry.ResponsibilityStmt }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
@@ -177,7 +182,8 @@
|
||||
<a href="/person/{{ $a.Id }}">
|
||||
{{ $a.Name }}
|
||||
</a>
|
||||
<span class="ml-2 px-2 py-0.5 rounded text-sm font-sans bg-slate-200 inline-block">
|
||||
<span
|
||||
class="ml-2 px-2 py-0.5 rounded text-sm font-sans bg-slate-200 inline-block">
|
||||
{{- $r.Type -}}
|
||||
</span>
|
||||
</div>
|
||||
@@ -196,6 +202,8 @@
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
let abbrevs = {{- $model.abbrs -}};
|
||||
@@ -207,3 +215,4 @@
|
||||
}
|
||||
|
||||
</script>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<div class="container-normal flex flex-col font-serif mt-12">
|
||||
<div class="font-sans">
|
||||
<svg
|
||||
{{/* <svg
|
||||
class="w-[0.9rem] h-[0.9rem] relative bottom-[0.04rem] inline-block"
|
||||
width="65px"
|
||||
height="65px"
|
||||
@@ -39,6 +39,8 @@
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
*/}}
|
||||
<i class="ri-book-shelf-fill"></i>
|
||||
Reihe
|
||||
</div>
|
||||
<div class="grow-0">
|
||||
|
||||
@@ -23,6 +23,17 @@
|
||||
// Only on place request
|
||||
Place *dbmodels.Place
|
||||
}
|
||||
|
||||
// Parameters:
|
||||
.letter
|
||||
.search
|
||||
.hidden
|
||||
|
||||
.record
|
||||
.record.Image(Path)
|
||||
.record.Text
|
||||
|
||||
.startpage
|
||||
*/}}
|
||||
|
||||
{{ $model := . }}
|
||||
@@ -86,7 +97,7 @@
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ if .series }}
|
||||
{{ if $model.result.Series }}
|
||||
<div class="border-b text-sm font-sans text-right pb-0.5">
|
||||
Treffer in Reihentiteln ↑
|
||||
</div>
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
hx-trigger="input changed delay=1500ms, keyup[key=='Enter']"
|
||||
hx-select="#searchcontent"
|
||||
hx-target="#searchcontent"
|
||||
hx-swap="outerHTML"
|
||||
autocomplete="off"
|
||||
{{ if $model.search }}disabled="true"{{ end }} />
|
||||
</div>
|
||||
|
||||
@@ -4,10 +4,26 @@
|
||||
x-data="{ open: true }"
|
||||
x-show="open">
|
||||
<div class="container-extraoversize flex flex-row gap-x-8">
|
||||
<div class="max-w-[52rem] font-serif text-lg hyphens-auto">
|
||||
<div
|
||||
class="max-w-[52rem] font-serif text-base hyphens-auto bg-gray-50 py-8 border-r
|
||||
border-b">
|
||||
<div class="px-8">
|
||||
{{ Safe $model.record.Text }}
|
||||
<div class="pt-3">
|
||||
<a href="/edition/einfuehrung">Einführung</i></a>
|
||||
<i class="ri-seedling-line px-1.5"></i>
|
||||
<a href="/edition/dokumentation">Dokumentation </a>
|
||||
</div>
|
||||
<div class="-mr-16 pt-2 grow-0 shrink-0">
|
||||
|
||||
<div class="mt-4 py-2 px-3 rounded bg-orange-100 border border-orange-200
|
||||
text-orange-950 font-sans font-bold">
|
||||
Bitte beachten Sie, dass es sich hier noch um eine öffentliche Testversion
|
||||
handelt. Über Rückmeldungen und Anregungen freuen wir uns [→ <a
|
||||
href="/edition//kontakt">Kontakt</a>]
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="-mr-16 pt-2 grow-0">
|
||||
<img src="{{ $model.record.ImagePath }}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
{{ $model := . }}
|
||||
{{/* .parameters
|
||||
type Parameters struct {
|
||||
Extended bool
|
||||
Collection string
|
||||
Query string
|
||||
}
|
||||
type SimpleParameters struct {
|
||||
Parameters
|
||||
Annotations bool
|
||||
Persons bool
|
||||
Title bool
|
||||
Alm bool
|
||||
Series bool
|
||||
Places bool
|
||||
Refs bool
|
||||
Year bool
|
||||
}
|
||||
*/}}
|
||||
|
||||
|
||||
<div id="searchcontrol" class="container-normal">
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
}
|
||||
|
||||
#entrydata .fieldlabel {
|
||||
@apply font-bold text-base font-sans whitespace-nowrap min-w-48 grow-0 shrink-0 pt-0.5;
|
||||
@apply font-bold font-serif text-base whitespace-nowrap min-w-48 grow-0 shrink-0 pt-0.5;
|
||||
}
|
||||
|
||||
#entrydata .fieldvalue {
|
||||
|
||||
Reference in New Issue
Block a user