| 1 |
package website.controller; |
| 2 |
|
| 3 |
import haxe.crypto.Md5; |
| 4 |
import ufront.web.Controller; |
| 5 |
import ufront.web.result.*; |
| 6 |
import website.api.UserApi; |
| 7 |
using tink.CoreApi; |
| 8 |
|
| 9 |
@cacheRequest |
| 10 |
class UserController extends Controller { |
| 11 |
|
| 12 |
@inject public var api:UserApi; |
| 13 |
|
| 14 |
@:route("/$username") |
| 15 |
public function profile( username:String ) { |
| 16 |
var data = api.getUserProfile( username ).sure(); |
| 17 |
var user = data.a; |
| 18 |
return new ViewResult({ |
| 19 |
title: '$username (${user.fullname}) on Haxelib', |
| 20 |
user: user, |
| 21 |
projects: data.b, |
| 22 |
emailHash: Md5.encode( user.email ), |
| 23 |
}); |
| 24 |
} |
| 25 |
|
| 26 |
@:route("/") |
| 27 |
public function list() { |
| 28 |
var userList = api.getUserList().sure(); |
| 29 |
return new ViewResult({ |
| 30 |
title: 'Haxelib Contributors', |
| 31 |
list: userList |
| 32 |
}); |
| 33 |
} |
| 34 |
// Future: edit your own profile. Especially password resets. |
| 35 |
} |