mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-03 16:17:59 +01:00
support seeding static pages
This commit is contained in:
parent
658472f16b
commit
19442633c6
2 changed files with 12 additions and 2 deletions
|
@ -21,7 +21,8 @@ alias Philomena.{
|
||||||
Reports.Report,
|
Reports.Report,
|
||||||
Roles.Role,
|
Roles.Role,
|
||||||
Tags.Tag,
|
Tags.Tag,
|
||||||
Users.User
|
Users.User,
|
||||||
|
StaticPages.StaticPage
|
||||||
}
|
}
|
||||||
|
|
||||||
alias Philomena.Elasticsearch
|
alias Philomena.Elasticsearch
|
||||||
|
@ -88,6 +89,14 @@ for role_def <- resources["roles"] do
|
||||||
|> Repo.insert(on_conflict: :nothing)
|
|> Repo.insert(on_conflict: :nothing)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
IO.puts("---- Generating static pages")
|
||||||
|
|
||||||
|
for page_def <- resources["pages"] do
|
||||||
|
%StaticPage{title: page_def["title"], slug: page_def["slug"], body: page_def["body"]}
|
||||||
|
|> StaticPage.changeset(%{})
|
||||||
|
|> Repo.insert(on_conflict: :nothing)
|
||||||
|
end
|
||||||
|
|
||||||
IO.puts("---- Indexing content")
|
IO.puts("---- Indexing content")
|
||||||
Elasticsearch.reindex(Tag |> preload(^Tags.indexing_preloads()), Tag)
|
Elasticsearch.reindex(Tag |> preload(^Tags.indexing_preloads()), Tag)
|
||||||
|
|
||||||
|
|
|
@ -91,5 +91,6 @@
|
||||||
{"name": "moderator", "resource_type": "Topic"},
|
{"name": "moderator", "resource_type": "Topic"},
|
||||||
{"name": "admin", "resource_type": "Advert"},
|
{"name": "admin", "resource_type": "Advert"},
|
||||||
{"name": "admin", "resource_type": "StaticPage"}
|
{"name": "admin", "resource_type": "StaticPage"}
|
||||||
]
|
],
|
||||||
|
"pages": []
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue