-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load embedded resources into the application
- Loading branch information
Showing
10 changed files
with
167 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,79 @@ | ||
<template> | ||
<div> | ||
<div class="container-fluid"> | ||
|
||
<div class="row justify-content-center"> | ||
<div class="col-12 col-lg-10 col-xl-10 content-pop"> | ||
<!-- <page-header title="Components" pre-title="Preview Components"/>--> | ||
|
||
<div class="container-fluid"> | ||
|
||
<div class="header mt-md-1"> | ||
<div class="header-body"> | ||
<h1 class="header-title" id="progress-bars"> | ||
Changelog & News | ||
</h1> | ||
|
||
<p class="header-subtitle"> | ||
See the latest Spire changes here! | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<v-runtime-template :template="changelog"/> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import EqWindow from "@/components/eq-ui/EQWindow"; | ||
import UserContext from "@/app/user/UserContext"; | ||
import EqWindow from "@/components/eq-ui/EQWindow"; | ||
import UserContext from "@/app/user/UserContext"; | ||
import {SpireApiClient} from "../../app/api/spire-api-client"; | ||
export default { | ||
components: { EqWindow }, | ||
data() { | ||
return { | ||
userContext: null, | ||
} | ||
}, | ||
async mounted() { | ||
this.userContext = await (UserContext.getUser()) | ||
export default { | ||
components: { | ||
EqWindow, | ||
"v-runtime-template": () => import("v-runtime-template") | ||
}, | ||
data() { | ||
return { | ||
userContext: null, | ||
changelog: "", | ||
} | ||
}, | ||
async mounted() { | ||
this.userContext = await (UserContext.getUser()) | ||
SpireApiClient.v1().get(`/app/changelog`).then((response) => { | ||
if (response.data && response.data.data) { | ||
const md = require("markdown-it")({ | ||
html: true, | ||
xhtmlOut: false, | ||
breaks: true, | ||
typographer: false | ||
}); | ||
let result = response.data.data | ||
result = md.render(result); | ||
console.log(result) | ||
// doc | ||
this.changelog = "<div>" + result + "</div>" | ||
} | ||
}) | ||
} | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package controllers | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/Akkadius/spire/internal/env" | ||
"github.com/Akkadius/spire/internal/http/routes" | ||
"github.com/labstack/echo/v4" | ||
gocache "github.com/patrickmn/go-cache" | ||
"github.com/sirupsen/logrus" | ||
"net/http" | ||
) | ||
|
||
type AppController struct { | ||
cache *gocache.Cache | ||
logger *logrus.Logger | ||
} | ||
|
||
func NewAppController(cache *gocache.Cache, logger *logrus.Logger) *AppController { | ||
return &AppController{ | ||
cache: cache, | ||
logger: logger, | ||
} | ||
} | ||
|
||
func (d *AppController) Routes() []*routes.Route { | ||
return []*routes.Route{ | ||
routes.RegisterRoute(http.MethodGet, "app/changelog", d.changelog, nil), | ||
routes.RegisterRoute(http.MethodGet, "app/env", d.env, nil), | ||
} | ||
} | ||
|
||
func (d *AppController) changelog(c echo.Context) error { | ||
changelog, _ := d.cache.Get("changelog") | ||
return c.JSON(200, echo.Map{"data": changelog}) | ||
} | ||
|
||
type EnvResponse struct { | ||
Env string `json:"env"` | ||
Version string `json:"version"` | ||
} | ||
|
||
type PackageJson struct { | ||
Name string `json:"name"` | ||
Version string `json:"version"` | ||
Repository struct { | ||
Type string `json:"type"` | ||
URL string `json:"url"` | ||
} `json:"repository"` | ||
} | ||
|
||
func (d *AppController) env(c echo.Context) error { | ||
data, _ := d.cache.Get("packageJson") | ||
|
||
pJson, ok := data.([]byte) | ||
if ok { | ||
var pkg PackageJson | ||
err := json.Unmarshal(pJson, &pkg) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
response := EnvResponse{ | ||
Env: env.Get("APP_ENV", "local"), | ||
Version: pkg.Version, | ||
} | ||
|
||
return c.JSON(200, echo.Map{"data": response}) | ||
} | ||
|
||
return c.JSON(500, echo.Map{"error": "Unknown error"}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters