diff --git a/cmd/webapi/__debug_bin b/cmd/webapi/__debug_bin
new file mode 100755
index 0000000..aabc500
Binary files /dev/null and b/cmd/webapi/__debug_bin differ
diff --git a/cmd/webapi/wasaphoto.db b/cmd/webapi/wasaphoto.db
index 7880ef6..9d81079 100644
Binary files a/cmd/webapi/wasaphoto.db and b/cmd/webapi/wasaphoto.db differ
diff --git a/service/api/followers.go b/service/api/followers.go
index 852fbc1..de2a435 100644
--- a/service/api/followers.go
+++ b/service/api/followers.go
@@ -72,14 +72,14 @@ func (rt *_router) GetFollowersFollowing(w http.ResponseWriter, r *http.Request,
func (rt *_router) PutFollow(w http.ResponseWriter, r *http.Request, ps httprouter.Params, ctx reqcontext.RequestContext) {
uid := ps.ByName("user_id")
- followed := ps.ByName("follower_uid")
+ follower := ps.ByName("follower_uid")
// send error if the user has no permission to perform this action
- if !authorization.SendAuthorizationError(ctx.Auth.UserAuthorized, uid, rt.db, w, rt.baseLogger, http.StatusNotFound) {
+ if !authorization.SendAuthorizationError(ctx.Auth.UserAuthorized, follower, rt.db, w, rt.baseLogger, http.StatusNotFound) {
return
}
- status, err := rt.db.FollowUser(uid, followed)
+ status, err := rt.db.FollowUser(follower, uid)
if err != nil {
helpers.SendInternalError(err, "Database error: FollowUser", w, rt.baseLogger)
@@ -102,14 +102,14 @@ func (rt *_router) PutFollow(w http.ResponseWriter, r *http.Request, ps httprout
func (rt *_router) DeleteFollow(w http.ResponseWriter, r *http.Request, ps httprouter.Params, ctx reqcontext.RequestContext) {
uid := ps.ByName("user_id")
- followed := ps.ByName("follower_uid")
+ follower := ps.ByName("follower_uid")
// send error if the user has no permission to perform this action
- if !authorization.SendAuthorizationError(ctx.Auth.UserAuthorized, uid, rt.db, w, rt.baseLogger, http.StatusNotFound) {
+ if !authorization.SendAuthorizationError(ctx.Auth.UserAuthorized, follower, rt.db, w, rt.baseLogger, http.StatusNotFound) {
return
}
- status, err := rt.db.UnfollowUser(uid, followed)
+ status, err := rt.db.UnfollowUser(follower, uid)
if err != nil {
helpers.SendInternalError(err, "Database error: UnfollowUser", w, rt.baseLogger)
diff --git a/webui/src/components/UserCard.vue b/webui/src/components/UserCard.vue
new file mode 100644
index 0000000..8e33b14
--- /dev/null
+++ b/webui/src/components/UserCard.vue
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/webui/src/main.js b/webui/src/main.js
index 5e10d5d..f16448f 100644
--- a/webui/src/main.js
+++ b/webui/src/main.js
@@ -5,6 +5,7 @@ import { axios, updateToken as axiosUpdate } from './services/axios.js';
import ErrorMsg from './components/ErrorMsg.vue'
import LoadingSpinner from './components/LoadingSpinner.vue'
import PostCard from './components/PostCard.vue'
+import UserCard from './components/UserCard.vue'
import 'bootstrap-icons/font/bootstrap-icons.css'
import './assets/dashboard.css'
@@ -16,5 +17,6 @@ app.config.globalProperties.$axiosUpdate = axiosUpdate;
app.component("ErrorMsg", ErrorMsg);
app.component("LoadingSpinner", LoadingSpinner);
app.component("PostCard", PostCard);
+app.component("UserCard", UserCard);
app.use(router)
app.mount('#app')
\ No newline at end of file
diff --git a/webui/src/router/index.js b/webui/src/router/index.js
index 56546a6..17086ad 100644
--- a/webui/src/router/index.js
+++ b/webui/src/router/index.js
@@ -1,15 +1,18 @@
import {createRouter, createWebHashHistory} from 'vue-router'
import HomeView from '../views/HomeView.vue'
+import ProfileView from '../views/ProfileView.vue'
import LoginView from '../views/LoginView.vue'
+import SearchView from '../views/SearchView.vue'
const router = createRouter({
history: createWebHashHistory(import.meta.env.BASE_URL),
routes: [
{path: '/', component: HomeView},
{path: '/login', component: LoginView},
+ {path: '/search', component: SearchView},
{path: '/link1', component: HomeView},
{path: '/link2', component: HomeView},
- {path: '/some/:id/link', component: HomeView},
+ {path: '/profile/:user_id', component: ProfileView},
]
})
diff --git a/webui/src/views/HomeView.vue b/webui/src/views/HomeView.vue
index ebed081..1540c41 100644
--- a/webui/src/views/HomeView.vue
+++ b/webui/src/views/HomeView.vue
@@ -4,18 +4,28 @@ export default {
return {
errormsg: null,
loading: false,
- stream_data: null,
+ stream_data: [],
+ data_ended: false,
+ start_idx: 0,
+ limit: 1,
my_id: sessionStorage.getItem("token"),
}
},
methods: {
async refresh() {
+ this.limit = Math.round(window.innerHeight / 450);
+ this.start_idx = 0;
+ this.data_ended = false;
+ this.stream_data = [];
+ this.loadContent();
+ },
+ async loadContent() {
this.loading = true;
this.errormsg = null;
try {
- let response = await this.$axios.get("/stream");
- this.stream_data = response.data;
- this.errormsg = this.stream_data; // TODO: temporary
+ let response = await this.$axios.get("/stream?start_index=" + this.start_idx + "&limit=" + this.limit);
+ if (response.data.length == 0) this.data_ended = true;
+ else this.stream_data = this.stream_data.concat(response.data);
this.loading = false;
} catch (e) {
if (e.response.status == 401) {
@@ -24,9 +34,23 @@ export default {
this.errormsg = e.toString();
}
},
+ scroll () {
+ window.onscroll = () => {
+ let bottomOfWindow = Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop) + window.innerHeight === document.documentElement.offsetHeight
+ if (bottomOfWindow && !this.data_ended) {
+ this.start_idx += this.limit;
+ this.loadContent();
+ }
+ }
+ },
},
mounted() {
- this.refresh()
+ // this way we are sure that we fill the first page
+ // 450 is a bit more of the max height of a post
+ // todo: may not work in 4k screens :/
+ this.limit = Math.round(window.innerHeight / 450);
+ this.scroll();
+ this.loadContent();
}
}
@@ -41,12 +65,9 @@ export default {
-
-
@@ -70,6 +91,10 @@ export default {
:my_id="my_id" />
+
+ Hai visualizzato tutti i post. Hooray! 👻
+
+
diff --git a/webui/src/views/ProfileView.vue b/webui/src/views/ProfileView.vue
new file mode 100644
index 0000000..3894c73
--- /dev/null
+++ b/webui/src/views/ProfileView.vue
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ user_data["photos"] }}
+ Photos
+
+
+
{{ user_data["followers"] }}
+ Followers
+
+
+
{{ user_data["following"] }}
+ Following
+
+
+
+
+
+
+ Hai visualizzato tutti i post. Hooray! 👻
+
+
+
+
+
+
+
+
+
+
+
diff --git a/webui/src/views/SearchView.vue b/webui/src/views/SearchView.vue
new file mode 100644
index 0000000..90a62f8
--- /dev/null
+++ b/webui/src/views/SearchView.vue
@@ -0,0 +1,98 @@
+
+
+
+
+
+
Search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+