mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-12-04 14:46:37 -05:00
Implemented "all" system dummy
This commit is contained in:
parent
33bf4aa8ad
commit
8af4f3469e
95
system/all/all.go
Normal file
95
system/all/all.go
Normal file
@ -0,0 +1,95 @@
|
||||
package all
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/mrusme/gobbs/models/post"
|
||||
"github.com/mrusme/gobbs/models/reply"
|
||||
"github.com/mrusme/gobbs/system/adapter"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type System struct {
|
||||
ID int
|
||||
config map[string]interface{}
|
||||
logger *zap.SugaredLogger
|
||||
}
|
||||
|
||||
func (sys *System) GetID() int {
|
||||
return sys.ID
|
||||
}
|
||||
|
||||
func (sys *System) SetID(id int) {
|
||||
sys.ID = id
|
||||
}
|
||||
|
||||
func (sys *System) GetConfig() map[string]interface{} {
|
||||
return sys.config
|
||||
}
|
||||
|
||||
func (sys *System) SetConfig(cfg *map[string]interface{}) {
|
||||
}
|
||||
|
||||
func (sys *System) SetLogger(logger *zap.SugaredLogger) {
|
||||
sys.logger = logger
|
||||
}
|
||||
|
||||
func (sys *System) GetCapabilities() []adapter.Capability {
|
||||
var caps []adapter.Capability
|
||||
|
||||
caps = append(caps, adapter.Capability{
|
||||
ID: "posts",
|
||||
Name: "Posts",
|
||||
})
|
||||
caps = append(caps, adapter.Capability{
|
||||
ID: "groups",
|
||||
Name: "Groups",
|
||||
})
|
||||
caps = append(caps, adapter.Capability{
|
||||
ID: "search",
|
||||
Name: "Search",
|
||||
})
|
||||
|
||||
return caps
|
||||
}
|
||||
|
||||
func (sys *System) FilterValue() string {
|
||||
return fmt.Sprintf(
|
||||
"All",
|
||||
)
|
||||
}
|
||||
|
||||
func (sys *System) Title() string {
|
||||
return "All"
|
||||
}
|
||||
|
||||
func (sys *System) Description() string {
|
||||
return fmt.Sprintf(
|
||||
"Aggregate all systems",
|
||||
)
|
||||
}
|
||||
|
||||
func (sys *System) Load() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sys *System) Connect(sysURL string) error {
|
||||
return errors.New("This system can't be connected to")
|
||||
}
|
||||
|
||||
func (sys *System) ListPosts() ([]post.Post, error) {
|
||||
return []post.Post{}, nil
|
||||
}
|
||||
|
||||
func (sys *System) LoadPost(p *post.Post) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sys *System) CreatePost(p *post.Post) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sys *System) CreateReply(r *reply.Reply) error {
|
||||
return nil
|
||||
}
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@ -72,7 +73,13 @@ func (sys *System) FilterValue() string {
|
||||
}
|
||||
|
||||
func (sys *System) Title() string {
|
||||
return sys.config["url"].(string)
|
||||
sysUrl := sys.config["url"].(string)
|
||||
u, err := url.Parse(sysUrl)
|
||||
if err != nil {
|
||||
return sysUrl
|
||||
}
|
||||
|
||||
return u.Hostname()
|
||||
}
|
||||
|
||||
func (sys *System) Description() string {
|
||||
|
@ -70,7 +70,7 @@ func (sys *System) FilterValue() string {
|
||||
}
|
||||
|
||||
func (sys *System) Title() string {
|
||||
return "https://news.ycombinator.com"
|
||||
return "news.ycombinator.com"
|
||||
}
|
||||
|
||||
func (sys *System) Description() string {
|
||||
|
@ -3,6 +3,7 @@ package lemmy
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@ -71,7 +72,13 @@ func (sys *System) FilterValue() string {
|
||||
}
|
||||
|
||||
func (sys *System) Title() string {
|
||||
return sys.config["url"].(string)
|
||||
sysUrl := sys.config["url"].(string)
|
||||
u, err := url.Parse(sysUrl)
|
||||
if err != nil {
|
||||
return sysUrl
|
||||
}
|
||||
|
||||
return u.Hostname()
|
||||
}
|
||||
|
||||
func (sys *System) Description() string {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"github.com/mrusme/gobbs/models/post"
|
||||
"github.com/mrusme/gobbs/models/reply"
|
||||
"github.com/mrusme/gobbs/system/adapter"
|
||||
"github.com/mrusme/gobbs/system/all"
|
||||
"github.com/mrusme/gobbs/system/discourse"
|
||||
"github.com/mrusme/gobbs/system/hackernews"
|
||||
"github.com/mrusme/gobbs/system/lemmy"
|
||||
@ -47,6 +48,8 @@ func New(
|
||||
sys = new(lemmy.System)
|
||||
case "hackernews":
|
||||
sys = new(hackernews.System)
|
||||
case "all":
|
||||
sys = new(all.System)
|
||||
default:
|
||||
return nil, errors.New("No such system")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user