@ -0,0 +1,20 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
|
||||
steps:
|
||||
- name: docker-build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
registry: hub.codefirst.iut.uca.fr
|
||||
repo: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-home
|
||||
username:
|
||||
from_secret: SECRET_REGISTRY_USERNAME
|
||||
password:
|
||||
from_secret: SECRET_REGISTRY_PASSWORD
|
@ -0,0 +1,23 @@
|
||||
# ---> Go
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
|
@ -0,0 +1,102 @@
|
||||
# options for analysis running
|
||||
run:
|
||||
# timeout for analysis, e.g. 30s, 5m, default is 1m
|
||||
timeout: 1m
|
||||
|
||||
# exit code when at least one issue was found, default is 1
|
||||
issues-exit-code: 0
|
||||
|
||||
# include test files or not, default is true
|
||||
tests: false
|
||||
|
||||
# which dirs to skip: issues from them won't be reported;
|
||||
# can use regexp here: generated.*, regexp is applied on full path;
|
||||
# default value is empty list, but default dirs are skipped independently
|
||||
# from this option's value (see skip-dirs-use-default).
|
||||
# "/" will be replaced by current OS file path separator to properly work
|
||||
# on Windows.
|
||||
skip-dirs:
|
||||
- wasm
|
||||
- static
|
||||
- node_modules
|
||||
- documents
|
||||
- docker
|
||||
- bind-*
|
||||
|
||||
# default is true. Enables skipping of directories:
|
||||
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
|
||||
skip-dirs-use-default: true
|
||||
|
||||
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
|
||||
# If invoked with -mod=readonly, the go command is disallowed from the implicit
|
||||
# automatic updating of go.mod described above. Instead, it fails when any changes
|
||||
# to go.mod are needed. This setting is most useful to check that go.mod does
|
||||
# not need updates, such as in a continuous integration and testing system.
|
||||
# If invoked with -mod=vendor, the go command assumes that the vendor
|
||||
# directory holds the correct copies of dependencies and ignores
|
||||
# the dependency descriptions in go.mod.
|
||||
modules-download-mode: mod
|
||||
|
||||
# Allow multiple parallel golangci-lint instances running.
|
||||
# If false (default) - golangci-lint acquires file lock on start.
|
||||
allow-parallel-runners: true
|
||||
|
||||
|
||||
# output configuration options
|
||||
output:
|
||||
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
|
||||
# default is "colored-line-number"
|
||||
format: colored-line-number
|
||||
|
||||
# print lines of code with issue, default is true
|
||||
print-issued-lines: true
|
||||
|
||||
# print linter name in the end of issue text, default is true
|
||||
print-linter-name: true
|
||||
|
||||
# make issues output unique by line, default is true
|
||||
uniq-by-line: true
|
||||
|
||||
# add a prefix to the output file references; default is no prefix
|
||||
path-prefix: ""
|
||||
|
||||
# sorts results by: filepath, line and column
|
||||
sort-results: false
|
||||
|
||||
|
||||
# all available settings of specific linters
|
||||
linters-settings:
|
||||
gofmt:
|
||||
# simplify code: gofmt with `-s` option, true by default
|
||||
simplify: true
|
||||
staticcheck:
|
||||
# Select the Go version to target. The default is '1.13'.
|
||||
go: "1.19"
|
||||
# https://staticcheck.io/docs/options#checks
|
||||
checks: ["all"]
|
||||
stylecheck:
|
||||
# Select the Go version to target. The default is '1.13'.
|
||||
go: "1.19"
|
||||
# https://staticcheck.io/docs/options#checks
|
||||
checks: ["all"]
|
||||
errcheck:
|
||||
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
|
||||
# default is false: such cases aren't reported by default.
|
||||
check-blank: true
|
||||
|
||||
linters:
|
||||
enable:
|
||||
# go install github.com/kisielk/errcheck@latest
|
||||
# go install github.com/gordonklaus/ineffassign@latest
|
||||
# go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||
# go install gitlab.com/opennota/check/cmd/varcheck@latest
|
||||
# go install github.com/go-critic/go-critic/cmd/gocritic@latest
|
||||
- errcheck
|
||||
- staticcheck
|
||||
- stylecheck
|
||||
- ineffassign
|
||||
- varcheck
|
||||
- gofmt
|
||||
- gocritic
|
||||
- wsl
|
||||
fast: false
|
@ -0,0 +1,18 @@
|
||||
FROM golang:1.19-bullseye
|
||||
LABEL author="Thomas Bellembois"
|
||||
|
||||
# Copying sources.
|
||||
WORKDIR /go/src/github.com/tbellembois/codefirst-home/
|
||||
COPY . .
|
||||
|
||||
# Installing.
|
||||
RUN go install -v ./...
|
||||
RUN chmod +x /go/bin/codefirst-home
|
||||
|
||||
# Copying entrypoint.
|
||||
COPY entrypoint.sh /
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
USER www-data
|
||||
EXPOSE 8081
|
||||
CMD ["/entrypoint.sh"]
|
@ -0,0 +1,14 @@
|
||||
# Code#0 home page
|
||||
|
||||
Background generated with:
|
||||
|
||||
```bash
|
||||
grep -v "///" /tmp/TarotController.cs | tr -d "\n" > /tmp/text.txt
|
||||
sed -i 's/ */ /g' text.txt
|
||||
|
||||
convert -background "#000000" -fill "#ffffff" -font "B612-Mono-Regular" -pointsize 14 -blur 0x2 -size 1280x1024 caption:@/tmp/text.txt /tmp/output.png
|
||||
```
|
||||
|
||||
# TODO
|
||||
|
||||
- remove hard coded URLs
|
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "$CODEFIRSTURL" ] || [ -z "$REGISTRYURL" ]
|
||||
then
|
||||
echo "Missing parameter."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
/go/bin/codefirst-home -codefirsturl=$CODEFIRSTURL -registryurl=$REGISTRYURL
|
@ -0,0 +1,12 @@
|
||||
module codefirst.iut.uca.fr/tbellembois/codefirst-home
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.0
|
||||
github.com/maragudk/gomponents v0.18.0
|
||||
github.com/nicksnyder/go-i18n/v2 v2.2.0
|
||||
golang.org/x/text v0.3.7
|
||||
)
|
||||
|
||||
require gopkg.in/yaml.v2 v2.4.0 // indirect
|
@ -0,0 +1,17 @@
|
||||
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
|
||||
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/maragudk/gomponents v0.18.0 h1:EcdeRUWsWW6hK9ftnGAoyXR00SQWecCBxuXghQvdEcc=
|
||||
github.com/maragudk/gomponents v0.18.0/go.mod h1:0OdlqOoqxcwvhBFrp8wlKHnEXhNB7IVhb8GuARmd+tI=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.2.0 h1:MNXbyPvd141JJqlU6gJKrczThxJy+kdCNivxZpBQFkw=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.2.0/go.mod h1:4OtLfzqyAxsscyCb//3gfqSvBc81gImX91LrZzczN1o=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
@ -0,0 +1,10 @@
|
||||
changePassword = "Change my password"
|
||||
logout = "Logout"
|
||||
projects = "Enter Code#0"
|
||||
documentation = "My generated code documentation"
|
||||
|
||||
cicd = "CI/CD"
|
||||
codeAnalyse = "code analyse"
|
||||
registry = "docker registry"
|
||||
api = "docker runner"
|
||||
chat = "discussions"
|
@ -0,0 +1,10 @@
|
||||
changePassword = "Changer mon mot de passe"
|
||||
logout = "Me déconnecter"
|
||||
projects = "Entrer sur Code#0"
|
||||
documentation = "ma documentation de code générée"
|
||||
|
||||
cicd = "CI/CD"
|
||||
codeAnalyse = "analyse de code"
|
||||
registry = "registre docker"
|
||||
api = "lanceur docker"
|
||||
chat = "discussions"
|
@ -0,0 +1,201 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
|
||||
g "github.com/maragudk/gomponents"
|
||||
c "github.com/maragudk/gomponents/components"
|
||||
. "github.com/maragudk/gomponents/html"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed web/*
|
||||
embedWebBox embed.FS
|
||||
|
||||
i18nBundle *i18n.Bundle
|
||||
|
||||
test bool
|
||||
codefirsturl, registryurl string
|
||||
proxypath string
|
||||
)
|
||||
|
||||
func init() {
|
||||
i18nBundle = i18n.NewBundle(language.English)
|
||||
i18nBundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
|
||||
i18nBundle.MustLoadMessageFile("lang/en.toml")
|
||||
i18nBundle.MustLoadMessageFile("lang/fr.toml")
|
||||
|
||||
flag.StringVar(&codefirsturl, "codefirsturl", "", "code#0 main URL")
|
||||
flag.StringVar(®istryurl, "registryurl", "", "code#0 registry URL")
|
||||
flag.StringVar(&proxypath, "proxypath", "/home/", "application proxy path (default: /home)")
|
||||
flag.BoolVar(&test, "test", false, "render the page for development purposes")
|
||||
flag.Parse()
|
||||
|
||||
if !test && (codefirsturl == "" || registryurl == "") {
|
||||
fmt.Println("Missing parameter.")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if test {
|
||||
proxypath = "/"
|
||||
}
|
||||
|
||||
codefirsturl = strings.TrimSuffix(codefirsturl, "/")
|
||||
registryurl = strings.TrimSuffix(registryurl, "/")
|
||||
}
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
xForwardedUser := r.Header["X-Forwarded-User"]
|
||||
|
||||
if test {
|
||||
xForwardedUser = []string{"test@test.com"}
|
||||
}
|
||||
|
||||
if len(xForwardedUser) == 0 || xForwardedUser[0] == "" {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
lang := r.FormValue("lang")
|
||||
accept := r.Header.Get("Accept-Language")
|
||||
localizer := i18n.NewLocalizer(i18nBundle, lang, accept)
|
||||
|
||||
// changePasswordMessage := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
// DefaultMessage: &i18n.Message{
|
||||
// ID: "changePassword",
|
||||
// },
|
||||
// })
|
||||
logoutMessage := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "logout",
|
||||
},
|
||||
})
|
||||
projectsMessage := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "projects",
|
||||
},
|
||||
})
|
||||
// cicdMessage := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
// DefaultMessage: &i18n.Message{
|
||||
// ID: "cicd",
|
||||
// },
|
||||
// })
|
||||
// codeAnalyseMessage := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
// DefaultMessage: &i18n.Message{
|
||||
// ID: "codeAnalyse",
|
||||
// },
|
||||
// })
|
||||
// registryMessage := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
// DefaultMessage: &i18n.Message{
|
||||
// ID: "registry",
|
||||
// },
|
||||
// })
|
||||
// apiMessage := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
// DefaultMessage: &i18n.Message{
|
||||
// ID: "api",
|
||||
// },
|
||||
// })
|
||||
// documentationMessage := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
// DefaultMessage: &i18n.Message{
|
||||
// ID: "documentation",
|
||||
// },
|
||||
// })
|
||||
// chatMessage := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
// DefaultMessage: &i18n.Message{
|
||||
// ID: "chat",
|
||||
// },
|
||||
// })
|
||||
|
||||
pageContent := Div(Class("card mx-auto mt-5 p-3"), StyleAttr("width: 29rem;"),
|
||||
Img(Src(proxypath+"web/img/logo.png"), Width("110px"), Class("mx-auto d-block")),
|
||||
Div(Class("card-body"),
|
||||
P(Class("card-text text-center fst-italic"), g.Text(xForwardedUser[0])),
|
||||
Div(Class("row"),
|
||||
A(Href(fmt.Sprintf("%s/git/user/oauth2/keycloak", codefirsturl)), Span(Class("mdi mdi-24px mdi-git"), g.Text(projectsMessage))),
|
||||
),
|
||||
Div(Class("row"),
|
||||
A(Href(fmt.Sprintf("%s/keycloak/realms/master/protocol/openid-connect/logout", codefirsturl)), Span(Class("mdi mdi-24px mdi-logout"), g.Text(logoutMessage))),
|
||||
),
|
||||
// Div(Class("row"),
|
||||
// A(Href(fmt.Sprintf("%s/keycloak/realms/master/account/?referrer=security-admin-console&referrer_uri=%s/keycloak/auth/admin/master/console/%23%2Fforbidden#/security/signingin", codefirsturl, codefirsturl)), Span(Class("mdi mdi-24px mdi-lock-reset"), g.Text(changePasswordMessage))),
|
||||
// ),
|
||||
// Div(Class("row"),
|
||||
// A(Href(fmt.Sprintf("%s/login", codefirsturl)), Span(Class("mdi mdi-24px mdi-flash"), g.Text(cicdMessage))),
|
||||
// ),
|
||||
// Div(Class("row"),
|
||||
// A(Href(fmt.Sprintf("%s/sonar/sessions/init/oidc?return_to=/sonar/", codefirsturl)), Span(Class("mdi mdi-24px mdi-radar"), g.Text(codeAnalyseMessage))),
|
||||
// ),
|
||||
// Div(Class("row"),
|
||||
// A(Href(registryurl), Span(Class("mdi mdi-24px mdi-docker"), g.Text(registryMessage))),
|
||||
// ),
|
||||
// Div(Class("row"),
|
||||
// A(Href(fmt.Sprintf("%s/cinny/", codefirsturl)), Span(Class("mdi mdi-24px mdi-wechat"), g.Text(chatMessage))),
|
||||
// ),
|
||||
// Div(Class("row"),
|
||||
// A(Href(fmt.Sprintf("%s/dockerrunner/static/html/", codefirsturl)), Span(Class("mdi mdi-24px mdi-api"), g.Text(apiMessage))),
|
||||
// ),
|
||||
// Div(Class("row"),
|
||||
// A(Href(fmt.Sprintf("%s/documentation/", codefirsturl)), Span(Class("mdi mdi-24px mdi-file-document-edit-outline"), g.Text(documentationMessage))),
|
||||
// ),
|
||||
),
|
||||
Div(Class("mt-sm-4"),
|
||||
Img(Src(proxypath+"web/img/logo_UCA.png"), Height("50px"), Class("m-sm-2 float-start mx-auto d-block")),
|
||||
Img(Src(proxypath+"web/img/logo_I-SITE.png"), Height("50px"), Class("m-sm-2 float-start mx-auto d-block")),
|
||||
Img(Src(proxypath+"web/img/logo_LIA.png"), Height("50px"), Class("m-sm-2 float-start mx-auto d-block")),
|
||||
Img(Src(proxypath+"web/img/logo_investir.png"), Height("50px"), Class("m-sm-2 float-start mx-auto d-block"))),
|
||||
)
|
||||
|
||||
page := c.HTML5(c.HTML5Props{
|
||||
Title: "Code#0",
|
||||
Language: "fr",
|
||||
Head: []g.Node{
|
||||
Link(Rel("stylesheet"), Href(proxypath+"web/css/materialdesignicons.min.css")),
|
||||
Link(Rel("stylesheet"), Href(proxypath+"web/css/bootstrap.min.css")),
|
||||
StyleEl(Type("text/css"), g.Raw(`
|
||||
body {
|
||||
height: 100%;
|
||||
background-image: url('`+proxypath+`web/img/home_background.png');
|
||||
background-position: center;
|
||||
background-repeat-x: no-repeat;
|
||||
background-repeat-y: repeat;
|
||||
background-size: cover;
|
||||
}
|
||||
`)),
|
||||
},
|
||||
Body: []g.Node{
|
||||
Div(Class("container"), ID("indexPage"), pageContent),
|
||||
Div(g.Group([]g.Node{
|
||||
Script(Src(proxypath + "web/js/bootstrap.bundle.min.js")),
|
||||
g.Raw(`
|
||||
<script>
|
||||
</script>
|
||||
`),
|
||||
}),
|
||||
),
|
||||
},
|
||||
})
|
||||
|
||||
if err := page.Render(w); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.Handle("/web/", http.FileServer(http.FS(embedWebBox)))
|
||||
http.HandleFunc("/", handler)
|
||||
|
||||
log.Println("Server running.")
|
||||
log.Fatal(http.ListenAndServe(":8081", nil))
|
||||
}
|
After Width: | Height: | Size: 2.4 MiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 403 KiB |
After Width: | Height: | Size: 429 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 5.7 KiB |