diff options
author | Arthur Zamarin <arthurzam@gentoo.org> | 2024-05-20 22:33:22 +0300 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2024-05-20 22:33:22 +0300 |
commit | 7a4fa55d86ac1304d79302b805cf6c53a61e2b72 (patch) | |
tree | 0dfc49e24e977ff5221ced9e40bc519ed290dce5 | |
parent | update templ (diff) | |
download | soko-7a4fa55d86ac1304d79302b805cf6c53a61e2b72.tar.gz soko-7a4fa55d86ac1304d79302b805cf6c53a61e2b72.tar.bz2 soko-7a4fa55d86ac1304d79302b805cf6c53a61e2b72.zip |
remove packages preferences
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | assets/pgo1.png | bin | 87834 -> 0 bytes | |||
-rw-r--r-- | assets/pgo2.png | bin | 82435 -> 0 bytes | |||
-rw-r--r-- | pkg/app/handler/packages/overview.templ | 7 | ||||
-rw-r--r-- | pkg/app/handler/packages/show.go | 4 | ||||
-rw-r--r-- | pkg/app/handler/packages/show.templ | 4 | ||||
-rw-r--r-- | pkg/app/handler/user/packages.templ | 100 | ||||
-rw-r--r-- | pkg/app/handler/user/preferences.templ | 2 | ||||
-rw-r--r-- | pkg/app/serve.go | 3 | ||||
-rw-r--r-- | pkg/app/utils/userdata.go | 9 | ||||
-rw-r--r-- | pkg/models/userpreferences.go | 17 |
10 files changed, 5 insertions, 141 deletions
diff --git a/assets/pgo1.png b/assets/pgo1.png Binary files differdeleted file mode 100644 index 29765df..0000000 --- a/assets/pgo1.png +++ /dev/null diff --git a/assets/pgo2.png b/assets/pgo2.png Binary files differdeleted file mode 100644 index 2d1cf06..0000000 --- a/assets/pgo2.png +++ /dev/null diff --git a/pkg/app/handler/packages/overview.templ b/pkg/app/handler/packages/overview.templ index 0e18082..43632e2 100644 --- a/pkg/app/handler/packages/overview.templ +++ b/pkg/app/handler/packages/overview.templ @@ -3,7 +3,6 @@ package packages import "slices" import "strings" import "time" -import "soko/pkg/app/handler/packages/components" import "soko/pkg/app/utils" import "soko/pkg/models" @@ -133,7 +132,7 @@ templ maintainersList(maintainers []*models.Maintainer) { } } -templ overview(pkg *models.Package, userPreferences *models.UserPreferences) { +templ overview(pkg *models.Package) { <div class="row"> <div class="col-md-9"> if len(pkg.Outdated) > 0 { @@ -393,10 +392,6 @@ templ overview(pkg *models.Package, userPreferences *models.UserPreferences) { } </ul> </div> - if userPreferences.Packages.Overview.Layout == "full" { - <div class="mt-4 pt-4"></div> - @components.Changelog(pkg.Atom, pkg.Commits) - } </div> <div class="col-md-3 pl-4 pt-4 mt-2"> <h4 class="mb-2 ml-1"> diff --git a/pkg/app/handler/packages/show.go b/pkg/app/handler/packages/show.go index a3c71b7..718a2a6 100644 --- a/pkg/app/handler/packages/show.go +++ b/pkg/app/handler/packages/show.go @@ -109,9 +109,7 @@ func Show(w http.ResponseWriter, r *http.Request) { sortVersionsDesc(gpackage.Versions) - layout.Layout(gpackage.Atom, layout.Packages, - show(&gpackage, currentSubTab, utils.GetUserPreferences(r)), - ).Render(r.Context(), w) + layout.Layout(gpackage.Atom, layout.Packages, show(&gpackage, currentSubTab)).Render(r.Context(), w) } func updateSearchHistory(atom string, w http.ResponseWriter, r *http.Request) { diff --git a/pkg/app/handler/packages/show.templ b/pkg/app/handler/packages/show.templ index 6718ae0..64d99c9 100644 --- a/pkg/app/handler/packages/show.templ +++ b/pkg/app/handler/packages/show.templ @@ -132,7 +132,7 @@ func collectSecurityBugs(pkg *models.Package) (string, []*models.Bug) { return pkg.Atom, bugs } -templ show(pkg *models.Package, currentSubTab string, userPreferences models.UserPreferences) { +templ show(pkg *models.Package, currentSubTab string) { if currentSubTab == "Reverse Dependencies" { @tabbedHeader(pkg, "Dependencies") } else { @@ -156,7 +156,7 @@ templ show(pkg *models.Package, currentSubTab string, userPreferences models.Use case "Reverse Dependencies": @reverseDependencies(pkg) default: - @overview(pkg, &userPreferences) + @overview(pkg) } </div> </div> diff --git a/pkg/app/handler/user/packages.templ b/pkg/app/handler/user/packages.templ deleted file mode 100644 index c9d8459..0000000 --- a/pkg/app/handler/user/packages.templ +++ /dev/null @@ -1,100 +0,0 @@ -package user - -import "encoding/base64" -import "encoding/json" -import "net/http" -import "time" -import "soko/pkg/app/utils" -import "soko/pkg/models" - -templ packages(preferences models.PackagesPreferences) { - <div class="row"> - <form method="post" action="/user/preferences/packages/edit"> - <h4 class="mb-1">Layout</h4> - <div class="row"> - <div class="col-6 mt-1"> - <div class="card" style="background: transparent;"> - <div class="card-body"> - <img id="img1" alt="Versions + Metadata (default)" src="/assets/pgo2.png" style="width: 100%;cursor: pointer;"/> - </div> - </div> - <div class="text-center mt-2"> - <div class="form-check text-center form-check-inline" style="text-overflow: ellipsis;overflow: hidden;"> - <input - type="radio" - id="minimalOverviewLayout" - name="overview-layout" - value="minimal" - checked?={ preferences.Overview.Layout == "minimal" } - /> - <label class="form-check-label ml-1" for="minimalOverviewLayout" style="overflow:hidden;text-overflow: ellipsis;" title="Versions + Metadata (default)">Versions + Metadata <i>(default)</i></label> - </div> - </div> - </div> - <div class="col-6 mt-1"> - <div class="card" style="background: transparent;"> - <div class="card-body"> - <img id="img2" alt="Versions + Metadata + Changelog" src="/assets/pgo1.png" onclick="document.getElementById('fullOverviewLayout').checked = true;" style="width: 100%;cursor: pointer;"/> - </div> - </div> - <div class="text-center mt-2"> - <div class="form-check text-center form-check-inline" style="text-overflow: ellipsis;overflow: hidden;"> - <input - type="radio" - id="fullOverviewLayout" - name="overview-layout" - value="full" - checked?={ preferences.Overview.Layout == "full" } - /> - <label class="form-check-label ml-1" for="fullOverviewLayout" style="overflow:hidden;text-overflow: ellipsis;" title="Versions + Metadata + Changelog">Versions + Metadata + Changelog</label> - </div> - </div> - </div> - </div> - <div class="row"> - <div class="col-12 mt-4"> - <button type="submit" class="float-right btn btn-sm btn-primary">Save</button> - <a class="float-right btn btn-sm btn-outline-danger mr-2" href="/user/preferences/packages/reset">Reset to Defaults</a> - </div> - </div> - </form> - </div> - <div id="myModal" class="modal"> - <span class="close">×</span> - <img class="modal-content" id="img01"/> - <div id="caption"></div> - </div> -} - -func EditPackagesPreferences(w http.ResponseWriter, r *http.Request) { - - userPreferences := utils.GetUserPreferences(r) - - r.ParseForm() - - // Overview: Layout - overviewLayout := r.Form.Get("overview-layout") - if overviewLayout == "minimal" || overviewLayout == "full" { - userPreferences.Packages.Overview.Layout = overviewLayout - } - - // - // Store cookie - // - encodedUserPreferences, err := json.Marshal(&userPreferences.Packages) - if err == nil { - sEnc := base64.StdEncoding.EncodeToString(encodedUserPreferences) - addCookie(w, "userpref_packages", "/", sEnc, 365*24*time.Hour) - } - http.Redirect(w, r, "/user/preferences/packages", http.StatusSeeOther) -} - -func ResetPackages(w http.ResponseWriter, r *http.Request) { - userPreferences := utils.GetDefaultUserPreferences() - encodedUserPreferences, err := json.Marshal(&userPreferences.Packages) - if err == nil { - sEnc := base64.StdEncoding.EncodeToString(encodedUserPreferences) - addCookie(w, "userpref_packages", "/", sEnc, 365*24*time.Hour) - } - http.Redirect(w, r, "/user/preferences/packages", http.StatusSeeOther) -} diff --git a/pkg/app/handler/user/preferences.templ b/pkg/app/handler/user/preferences.templ index 9fe7031..2c39bad 100644 --- a/pkg/app/handler/user/preferences.templ +++ b/pkg/app/handler/user/preferences.templ @@ -30,8 +30,6 @@ templ show(currentSubTab string, preferences models.UserPreferences) { switch currentSubTab { case "General": @general(preferences.General) - case "Packages": - @packages(preferences.Packages) case "Maintainers": @maintainers(preferences.Maintainers) } diff --git a/pkg/app/serve.go b/pkg/app/serve.go index 7e627ad..8f71ae7 100644 --- a/pkg/app/serve.go +++ b/pkg/app/serve.go @@ -115,9 +115,6 @@ func Serve() { setRoute("/user/preferences/general/layout", user.General) setRoute("/user/preferences/general/reset", user.ResetGeneral) - setRoute("/user/preferences/packages/edit", user.EditPackagesPreferences) - setRoute("/user/preferences/packages/reset", user.ResetPackages) - setRoute("/user/preferences/maintainers/edit", user.Maintainers) setRoute("/user/preferences/maintainers/reset", user.ResetMaintainers) diff --git a/pkg/app/utils/userdata.go b/pkg/app/utils/userdata.go index dc4258b..13874f8 100644 --- a/pkg/app/utils/userdata.go +++ b/pkg/app/utils/userdata.go @@ -22,14 +22,6 @@ func GetUserPreferences(r *http.Request) models.UserPreferences { } } - cookie, err = r.Cookie("userpref_packages") - if err == nil { - cookieValue, err := b64.StdEncoding.DecodeString(cookie.Value) - if err == nil { - json.Unmarshal(cookieValue, &userPreferences.Packages) - } - } - cookie, err = r.Cookie("userpref_maintainers") if err == nil { cookieValue, err := b64.StdEncoding.DecodeString(cookie.Value) @@ -38,6 +30,7 @@ func GetUserPreferences(r *http.Request) models.UserPreferences { } } + // old cookie: userpref_packages // old cookie: userpref_useflags // old cookie: userpref_arches diff --git a/pkg/models/userpreferences.go b/pkg/models/userpreferences.go index ba22a46..0db7107 100644 --- a/pkg/models/userpreferences.go +++ b/pkg/models/userpreferences.go @@ -4,7 +4,6 @@ package models type UserPreferences struct { General GeneralPreferences - Packages PackagesPreferences Maintainers MaintainersPreferences } @@ -12,14 +11,6 @@ type GeneralPreferences struct { LandingPageLayout string } -type PackagesPreferences struct { - Overview PackagesOverviewPreferences -} - -type PackagesOverviewPreferences struct { - Layout string -} - type MaintainersPreferences struct { IncludeProjectPackages bool ExcludedProjects []string @@ -31,14 +22,10 @@ var AllArches = [...]string{"alpha", "amd64", "arm", "arm64", "hppa", "ia64", "m func GetDefaultUserPreferences() UserPreferences { userPreferences := UserPreferences{} userPreferences.General = GeneralPreferences{} - userPreferences.Packages = PackagesPreferences{} - userPreferences.Packages.Overview = PackagesOverviewPreferences{} userPreferences.Maintainers = MaintainersPreferences{} userPreferences.General.LandingPageLayout = "classic" - userPreferences.Packages.Overview.Layout = "minimal" - userPreferences.Maintainers.IncludeProjectPackages = false userPreferences.Maintainers.ExcludedProjects = []string{} @@ -51,8 +38,4 @@ func (u *UserPreferences) Sanitize() { if !(u.General.LandingPageLayout == "classic" || u.General.LandingPageLayout == "full") { u.General.LandingPageLayout = defaultUserPreferences.General.LandingPageLayout } - - if !(u.Packages.Overview.Layout == "minimal" || u.Packages.Overview.Layout == "full") { - u.Packages.Overview.Layout = defaultUserPreferences.Packages.Overview.Layout - } } |