Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSON Schema link for base_event #89

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions lib/schema_web/controllers/page_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,11 @@ defmodule SchemaWeb.PageController do
end

@doc """
Renders the base event attributes.
Redirects from the older /base_event URL to /classes/base_event.
"""
@spec base_event(Plug.Conn.t(), any) :: Plug.Conn.t()
def base_event(conn, params) do
data =
Schema.class(:base_event)
|> sort_attributes()
|> Map.put(:key, :base_event)

render(conn, "class.html",
extensions: Schema.extensions(),
profiles: SchemaController.get_profiles(params),
data: data
)
def base_event(conn, _params) do
redirect(conn, to: "/classes/base_event")
end

@doc """
Expand Down
4 changes: 2 additions & 2 deletions lib/schema_web/templates/layout/app.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ limitations under the License.
case '/classes':
$('#classes_id').addClass("active");
break;
case '/base_event':
case '/classes/base_event':
$('#base_event_id').addClass("active");
break;
case '/dictionary':
Expand Down Expand Up @@ -187,7 +187,7 @@ limitations under the License.
<a class="nav-link" href='<%= Routes.static_path(@conn, "/classes") %>'>Classes</a>
</li>
<li id="base_event_id" class="nav-item">
<a class="nav-link" href='<%= Routes.static_path(@conn, "/base_event") %>'>Base Event</a>
<a class="nav-link" href='<%= Routes.static_path(@conn, "/classes/base_event") %>'>Base Event</a>
</li>
<li id="dictionary_id" class="nav-item">
<a class="nav-link" href='<%= Routes.static_path(@conn, "/dictionary") %>'>Dictionary</a>
Expand Down
6 changes: 3 additions & 3 deletions lib/schema_web/views/page_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ defmodule SchemaWeb.PageView do
[
[
"<a href=\"",
SchemaWeb.Router.Helpers.static_path(conn, "/base_event"),
SchemaWeb.Router.Helpers.static_path(conn, "/classes/base_event"),
"\" data-toggle=\"tooltip\ title=\"Directly referenced\">Base Event Class</a>"
]
| acc
Expand Down Expand Up @@ -902,7 +902,7 @@ defmodule SchemaWeb.PageView do
fn link, acc ->
type_path =
if link[:type] == "base_event" do
SchemaWeb.Router.Helpers.static_path(conn, "/base_event")
SchemaWeb.Router.Helpers.static_path(conn, "/classes/base_event")
else
SchemaWeb.Router.Helpers.static_path(conn, "/classes/" <> link[:type])
end
Expand Down Expand Up @@ -1083,7 +1083,7 @@ defmodule SchemaWeb.PageView do
[
[
"<a href=\"",
SchemaWeb.Router.Helpers.static_path(conn, "/base_event"),
SchemaWeb.Router.Helpers.static_path(conn, "/classes/base_event"),
"\">Base Event Class</a>"
]
| acc
Expand Down
2 changes: 2 additions & 0 deletions lib/schemas.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ defmodule Schemas do
{_er, _, _} -> false
end)
|> Enum.map(fn {_, version, path} -> {version, path} end)
# Simplistic lexical sort of versions - not perfect, but better than random
|> Enum.sort(fn {v1, _p1}, {v2, _p2} -> v1 <= v2 end)
else
{:error, reason} ->
err_msg = :file.format_error(reason)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
defmodule Schema.MixProject do
use Mix.Project

@version "2.70.0"
@version "2.70.1"

def project do
build = System.get_env("GITHUB_RUN_NUMBER") || "SNAPSHOT"
Expand Down
Loading