aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/ui/form
diff options
context:
space:
mode:
Diffstat (limited to 'server/ui/form')
-rw-r--r--server/ui/form/auth.go34
-rw-r--r--server/ui/form/category.go38
-rw-r--r--server/ui/form/feed.go64
-rw-r--r--server/ui/form/integration.go73
-rw-r--r--server/ui/form/settings.go70
-rw-r--r--server/ui/form/subscription.go42
-rw-r--r--server/ui/form/user.go87
7 files changed, 0 insertions, 408 deletions
diff --git a/server/ui/form/auth.go b/server/ui/form/auth.go
deleted file mode 100644
index c18a0be..0000000
--- a/server/ui/form/auth.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2017 Frédéric Guillot. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-package form
-
-import (
- "net/http"
-
- "github.com/miniflux/miniflux/errors"
-)
-
-// AuthForm represents the authentication form.
-type AuthForm struct {
- Username string
- Password string
-}
-
-// Validate makes sure the form values are valid.
-func (a AuthForm) Validate() error {
- if a.Username == "" || a.Password == "" {
- return errors.NewLocalizedError("All fields are mandatory.")
- }
-
- return nil
-}
-
-// NewAuthForm returns a new AuthForm.
-func NewAuthForm(r *http.Request) *AuthForm {
- return &AuthForm{
- Username: r.FormValue("username"),
- Password: r.FormValue("password"),
- }
-}
diff --git a/server/ui/form/category.go b/server/ui/form/category.go
deleted file mode 100644
index 31b7196..0000000
--- a/server/ui/form/category.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2017 Frédéric Guillot. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-package form
-
-import (
- "net/http"
-
- "github.com/miniflux/miniflux/errors"
- "github.com/miniflux/miniflux/model"
-)
-
-// CategoryForm represents a feed form in the UI
-type CategoryForm struct {
- Title string
-}
-
-// Validate makes sure the form values are valid.
-func (c CategoryForm) Validate() error {
- if c.Title == "" {
- return errors.NewLocalizedError("The title is mandatory.")
- }
- return nil
-}
-
-// Merge update the given category fields.
-func (c CategoryForm) Merge(category *model.Category) *model.Category {
- category.Title = c.Title
- return category
-}
-
-// NewCategoryForm returns a new CategoryForm.
-func NewCategoryForm(r *http.Request) *CategoryForm {
- return &CategoryForm{
- Title: r.FormValue("title"),
- }
-}
diff --git a/server/ui/form/feed.go b/server/ui/form/feed.go
deleted file mode 100644
index 896a6d7..0000000
--- a/server/ui/form/feed.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2017 Frédéric Guillot. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-package form
-
-import (
- "net/http"
- "strconv"
-
- "github.com/miniflux/miniflux/errors"
- "github.com/miniflux/miniflux/model"
-)
-
-// FeedForm represents a feed form in the UI
-type FeedForm struct {
- FeedURL string
- SiteURL string
- Title string
- ScraperRules string
- RewriteRules string
- Crawler bool
- CategoryID int64
-}
-
-// ValidateModification validates FeedForm fields
-func (f FeedForm) ValidateModification() error {
- if f.FeedURL == "" || f.SiteURL == "" || f.Title == "" || f.CategoryID == 0 {
- return errors.NewLocalizedError("All fields are mandatory.")
- }
- return nil
-}
-
-// Merge updates the fields of the given feed.
-func (f FeedForm) Merge(feed *model.Feed) *model.Feed {
- feed.Category.ID = f.CategoryID
- feed.Title = f.Title
- feed.SiteURL = f.SiteURL
- feed.FeedURL = f.FeedURL
- feed.ScraperRules = f.ScraperRules
- feed.RewriteRules = f.RewriteRules
- feed.Crawler = f.Crawler
- feed.ParsingErrorCount = 0
- feed.ParsingErrorMsg = ""
- return feed
-}
-
-// NewFeedForm parses the HTTP request and returns a FeedForm
-func NewFeedForm(r *http.Request) *FeedForm {
- categoryID, err := strconv.Atoi(r.FormValue("category_id"))
- if err != nil {
- categoryID = 0
- }
-
- return &FeedForm{
- FeedURL: r.FormValue("feed_url"),
- SiteURL: r.FormValue("site_url"),
- Title: r.FormValue("title"),
- ScraperRules: r.FormValue("scraper_rules"),
- RewriteRules: r.FormValue("rewrite_rules"),
- Crawler: r.FormValue("crawler") == "1",
- CategoryID: int64(categoryID),
- }
-}
diff --git a/server/ui/form/integration.go b/server/ui/form/integration.go
deleted file mode 100644
index 8cc6d35..0000000
--- a/server/ui/form/integration.go
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2017 Frédéric Guillot. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-package form
-
-import (
- "net/http"
-
- "github.com/miniflux/miniflux/model"
-)
-
-// IntegrationForm represents user integration settings form.
-type IntegrationForm struct {
- PinboardEnabled bool
- PinboardToken string
- PinboardTags string
- PinboardMarkAsUnread bool
- InstapaperEnabled bool
- InstapaperUsername string
- InstapaperPassword string
- FeverEnabled bool
- FeverUsername string
- FeverPassword string
- WallabagEnabled bool
- WallabagURL string
- WallabagClientID string
- WallabagClientSecret string
- WallabagUsername string
- WallabagPassword string
-}
-
-// Merge copy form values to the model.
-func (i IntegrationForm) Merge(integration *model.Integration) {
- integration.PinboardEnabled = i.PinboardEnabled
- integration.PinboardToken = i.PinboardToken
- integration.PinboardTags = i.PinboardTags
- integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
- integration.InstapaperEnabled = i.InstapaperEnabled
- integration.InstapaperUsername = i.InstapaperUsername
- integration.InstapaperPassword = i.InstapaperPassword
- integration.FeverEnabled = i.FeverEnabled
- integration.FeverUsername = i.FeverUsername
- integration.FeverPassword = i.FeverPassword
- integration.WallabagEnabled = i.WallabagEnabled
- integration.WallabagURL = i.WallabagURL
- integration.WallabagClientID = i.WallabagClientID
- integration.WallabagClientSecret = i.WallabagClientSecret
- integration.WallabagUsername = i.WallabagUsername
- integration.WallabagPassword = i.WallabagPassword
-}
-
-// NewIntegrationForm returns a new AuthForm.
-func NewIntegrationForm(r *http.Request) *IntegrationForm {
- return &IntegrationForm{
- PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
- PinboardToken: r.FormValue("pinboard_token"),
- PinboardTags: r.FormValue("pinboard_tags"),
- PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
- InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
- InstapaperUsername: r.FormValue("instapaper_username"),
- InstapaperPassword: r.FormValue("instapaper_password"),
- FeverEnabled: r.FormValue("fever_enabled") == "1",
- FeverUsername: r.FormValue("fever_username"),
- FeverPassword: r.FormValue("fever_password"),
- WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
- WallabagURL: r.FormValue("wallabag_url"),
- WallabagClientID: r.FormValue("wallabag_client_id"),
- WallabagClientSecret: r.FormValue("wallabag_client_secret"),
- WallabagUsername: r.FormValue("wallabag_username"),
- WallabagPassword: r.FormValue("wallabag_password"),
- }
-}
diff --git a/server/ui/form/settings.go b/server/ui/form/settings.go
deleted file mode 100644
index e5f6939..0000000
--- a/server/ui/form/settings.go
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2017 Frédéric Guillot. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-package form
-
-import (
- "net/http"
-
- "github.com/miniflux/miniflux/errors"
- "github.com/miniflux/miniflux/model"
-)
-
-// SettingsForm represents the settings form.
-type SettingsForm struct {
- Username string
- Password string
- Confirmation string
- Theme string
- Language string
- Timezone string
- EntryDirection string
-}
-
-// Merge updates the fields of the given user.
-func (s *SettingsForm) Merge(user *model.User) *model.User {
- user.Username = s.Username
- user.Theme = s.Theme
- user.Language = s.Language
- user.Timezone = s.Timezone
- user.EntryDirection = s.EntryDirection
-
- if s.Password != "" {
- user.Password = s.Password
- }
-
- return user
-}
-
-// Validate makes sure the form values are valid.
-func (s *SettingsForm) Validate() error {
- if s.Username == "" || s.Theme == "" || s.Language == "" || s.Timezone == "" || s.EntryDirection == "" {
- return errors.NewLocalizedError("The username, theme, language and timezone fields are mandatory.")
- }
-
- if s.Password != "" {
- if s.Password != s.Confirmation {
- return errors.NewLocalizedError("Passwords are not the same.")
- }
-
- if len(s.Password) < 6 {
- return errors.NewLocalizedError("You must use at least 6 characters")
- }
- }
-
- return nil
-}
-
-// NewSettingsForm returns a new SettingsForm.
-func NewSettingsForm(r *http.Request) *SettingsForm {
- return &SettingsForm{
- Username: r.FormValue("username"),
- Password: r.FormValue("password"),
- Confirmation: r.FormValue("confirmation"),
- Theme: r.FormValue("theme"),
- Language: r.FormValue("language"),
- Timezone: r.FormValue("timezone"),
- EntryDirection: r.FormValue("entry_direction"),
- }
-}
diff --git a/server/ui/form/subscription.go b/server/ui/form/subscription.go
deleted file mode 100644
index 7d2caaf..0000000
--- a/server/ui/form/subscription.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2017 Frédéric Guillot. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-package form
-
-import (
- "net/http"
- "strconv"
-
- "github.com/miniflux/miniflux/errors"
-)
-
-// SubscriptionForm represents the subscription form.
-type SubscriptionForm struct {
- URL string
- CategoryID int64
- Crawler bool
-}
-
-// Validate makes sure the form values are valid.
-func (s *SubscriptionForm) Validate() error {
- if s.URL == "" || s.CategoryID == 0 {
- return errors.NewLocalizedError("The URL and the category are mandatory.")
- }
-
- return nil
-}
-
-// NewSubscriptionForm returns a new SubscriptionForm.
-func NewSubscriptionForm(r *http.Request) *SubscriptionForm {
- categoryID, err := strconv.Atoi(r.FormValue("category_id"))
- if err != nil {
- categoryID = 0
- }
-
- return &SubscriptionForm{
- URL: r.FormValue("url"),
- Crawler: r.FormValue("crawler") == "1",
- CategoryID: int64(categoryID),
- }
-}
diff --git a/server/ui/form/user.go b/server/ui/form/user.go
deleted file mode 100644
index 8b8346e..0000000
--- a/server/ui/form/user.go
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2017 Frédéric Guillot. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-package form
-
-import (
- "net/http"
-
- "github.com/miniflux/miniflux/errors"
- "github.com/miniflux/miniflux/model"
-)
-
-// UserForm represents the user form.
-type UserForm struct {
- Username string
- Password string
- Confirmation string
- IsAdmin bool
-}
-
-// ValidateCreation validates user creation.
-func (u UserForm) ValidateCreation() error {
- if u.Username == "" || u.Password == "" || u.Confirmation == "" {
- return errors.NewLocalizedError("All fields are mandatory.")
- }
-
- if u.Password != u.Confirmation {
- return errors.NewLocalizedError("Passwords are not the same.")
- }
-
- if len(u.Password) < 6 {
- return errors.NewLocalizedError("You must use at least 6 characters.")
- }
-
- return nil
-}
-
-// ValidateModification validates user modification.
-func (u UserForm) ValidateModification() error {
- if u.Username == "" {
- return errors.NewLocalizedError("The username is mandatory.")
- }
-
- if u.Password != "" {
- if u.Password != u.Confirmation {
- return errors.NewLocalizedError("Passwords are not the same.")
- }
-
- if len(u.Password) < 6 {
- return errors.NewLocalizedError("You must use at least 6 characters.")
- }
- }
-
- return nil
-}
-
-// ToUser returns a User from the form values.
-func (u UserForm) ToUser() *model.User {
- return &model.User{
- Username: u.Username,
- Password: u.Password,
- IsAdmin: u.IsAdmin,
- }
-}
-
-// Merge updates the fields of the given user.
-func (u UserForm) Merge(user *model.User) *model.User {
- user.Username = u.Username
- user.IsAdmin = u.IsAdmin
-
- if u.Password != "" {
- user.Password = u.Password
- }
-
- return user
-}
-
-// NewUserForm returns a new UserForm.
-func NewUserForm(r *http.Request) *UserForm {
- return &UserForm{
- Username: r.FormValue("username"),
- Password: r.FormValue("password"),
- Confirmation: r.FormValue("confirmation"),
- IsAdmin: r.FormValue("is_admin") == "1",
- }
-}