Add Lists page
This commit is contained in:
parent
33c8ef30ec
commit
723b7e4fa1
23
internal/webserver/handler_lists.go
Normal file
23
internal/webserver/handler_lists.go
Normal file
@ -0,0 +1,23 @@
|
||||
package webserver
|
||||
|
||||
import (
|
||||
// "errors"
|
||||
"net/http"
|
||||
|
||||
"gitlab.com/offline-twitter/twitter_offline_engine/pkg/scraper"
|
||||
)
|
||||
|
||||
func (app *Application) Lists(w http.ResponseWriter, r *http.Request) {
|
||||
app.traceLog.Printf("'Lists' handler (path: %q)", r.URL.Path)
|
||||
|
||||
var users []scraper.User
|
||||
err := app.Profile.DB.Select(&users, `
|
||||
select id, display_name, handle, bio, following_count, followers_count, location, website, join_date, is_private, is_verified,
|
||||
is_banned, is_deleted, profile_image_url, profile_image_local_path, banner_image_url, banner_image_local_path,
|
||||
pinned_tweet_id, is_content_downloaded, is_followed
|
||||
from users
|
||||
where is_followed = 1`)
|
||||
panic_if(err)
|
||||
|
||||
app.buffered_render_basic_page(w, "tpl/list.tpl", users)
|
||||
}
|
@ -121,6 +121,8 @@ func (app *Application) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
app.UserUnfollow(w, r)
|
||||
case "search":
|
||||
http.StripPrefix("/search", http.HandlerFunc(app.Search)).ServeHTTP(w, r)
|
||||
case "lists":
|
||||
app.Lists(w, r)
|
||||
default:
|
||||
app.UserFeed(w, r)
|
||||
}
|
||||
|
@ -543,3 +543,14 @@ func TestStaticFileNonexistent(t *testing.T) {
|
||||
resp := do_request(httptest.NewRequest("GET", "/static/blehblehblehwfe", nil))
|
||||
require.Equal(resp.StatusCode, 404)
|
||||
}
|
||||
|
||||
// Lists
|
||||
// -----
|
||||
|
||||
func TestLists(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
resp := do_request(httptest.NewRequest("GET", "/lists", nil))
|
||||
root, err := html.Parse(resp.Body)
|
||||
assert.NoError(err)
|
||||
assert.Len(cascadia.QueryAll(root, selector(".users-list-container .author-info")), 4)
|
||||
}
|
||||
|
@ -596,3 +596,13 @@ ul.dropdown-items {
|
||||
.like-icon.liked, .like-icon:hover {
|
||||
filter: invert(20%) sepia(97%) saturate(4383%) hue-rotate(321deg) brightness(101%) contrast(95%);
|
||||
}
|
||||
|
||||
.users-list-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
padding: 1em;
|
||||
}
|
||||
.users-list-container .author-info .profile-image {
|
||||
width: 4em;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
<span>Messages</span>
|
||||
</li>
|
||||
</a>
|
||||
<a class="unstyled-link" href="#">
|
||||
<a class="unstyled-link" href="/lists">
|
||||
<li class="quick-link">
|
||||
<img class="svg-icon" src="/static/icons/lists.svg" />
|
||||
<span>Lists</span>
|
||||
|
9
internal/webserver/tpl/list.tpl
Normal file
9
internal/webserver/tpl/list.tpl
Normal file
@ -0,0 +1,9 @@
|
||||
{{define "title"}}Followed Users{{end}}
|
||||
|
||||
{{define "main"}}
|
||||
<div class="users-list-container">
|
||||
{{range .}}
|
||||
{{template "author-info" .}}
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
Loading…
x
Reference in New Issue
Block a user