summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-11 11:17:55 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-11 11:17:55 +0100
commitce73133c4e982db99f218bf930d82eb991ce81e3 (patch)
treecb15654419b8e912296ac9cea6deef068099910a /public
parentb6992903b7fe2a0aad9e6e47b0c14122b448b11c (diff)
profile
Diffstat (limited to 'public')
-rw-r--r--public/assets/css/bucky.css17
-rw-r--r--public/assets/js/lib/router.js33
-rw-r--r--public/assets/js/lib/views/profile/profile.js37
3 files changed, 74 insertions, 13 deletions
diff --git a/public/assets/css/bucky.css b/public/assets/css/bucky.css
index e96c0aa..a0ad54e 100644
--- a/public/assets/css/bucky.css
+++ b/public/assets/css/bucky.css
@@ -683,6 +683,23 @@ header .search_form {
display: none;
}
+/* PROFILE */
+
+#profile img {
+ max-width: 300px;
+ max-height: 300px;
+}
+#profile td {
+ padding: 4px;
+ font-size: 13px;
+ color: #211;
+}
+#profile td:first-child {
+ font-weight: bold;
+ padding-right: 20px;
+ color: #322;
+}
+
/* LOGIN */
#login div,
diff --git a/public/assets/js/lib/router.js b/public/assets/js/lib/router.js
index 27c8617..5862503 100644
--- a/public/assets/js/lib/router.js
+++ b/public/assets/js/lib/router.js
@@ -3,19 +3,21 @@ var SiteRouter = Router.extend({
el: "body",
routes: {
- "/": 'login',
- "/index/:keyword": 'index',
- "/index": 'index',
- "/login": 'login',
- "/details/:id": 'details',
- "/post": 'post',
- "/post/:keyword": 'post',
- "/search": 'search',
- "/mail": 'mailbox',
- "/mail/:mailbox": 'mailbox',
- "/mail/compose": 'compose',
- "/message/:id": 'message',
- "/comment/:id/edit": 'editComment',
+ "/": 'login',
+ "/index/:keyword": 'index',
+ "/index": 'index',
+ "/login": 'login',
+ "/details/:id": 'details',
+ "/post": 'post',
+ "/post/:keyword": 'post',
+ "/search": 'search',
+ "/mail": 'mailbox',
+ "/mail/:mailbox": 'mailbox',
+ "/mail/compose": 'compose',
+ "/message/:id": 'message',
+ "/comment/:id/edit": 'editComment',
+ "/profile": 'profile',
+ "/profile/:username": 'profile',
},
initialize: function(){
@@ -55,6 +57,11 @@ var SiteRouter = Router.extend({
app.view.load(keyword || "")
},
+ profile: function(username){
+ app.view = new ProfileView ()
+ app.view.load(username || auth.user.username)
+ },
+
compose: function(){
app.view = new ComposeView ()
},
diff --git a/public/assets/js/lib/views/profile/profile.js b/public/assets/js/lib/views/profile/profile.js
new file mode 100644
index 0000000..2180532
--- /dev/null
+++ b/public/assets/js/lib/views/profile/profile.js
@@ -0,0 +1,37 @@
+var ProfileView = View.extend({
+
+ el: "#profile",
+
+ events: {
+ },
+
+ action: "/api/user/",
+
+ initialize: function(opt){
+ this.template = this.$(".template").html()
+ },
+
+ load: function(username){
+ $.get(this.action + username, this.populate.bind(this))
+ },
+
+ populate: function(user){
+ $("body").removeClass('loading')
+ var $table = this.$("table")
+ this.$("img").attr("src", "/data/profile/" + sanitize(user.username) + ".jpg")
+ var fields = "username realname phone location".split(" ").map((key) => {
+ if (! user[key]) return;
+ var t = this.template.replace(/{{key}}/, sanitize(key))
+ .replace(/{{value}}/, sanitize(user[key]))
+ $table.append(t)
+ })
+ var fields = "firstseen lastseen".split(" ").map((key) => {
+ if (! user[key]) return;
+ var date = verbose_date(user[key])
+ var t = this.template.replace(/{{key}}/, sanitize(key))
+ .replace(/{{value}}/, date[0] + ' <small>' + date[1] + '</small>')
+ $table.append(t)
+ })
+ },
+
+})