Browse Source

edit profile and avatar

master
Julian Steinwachs 9 years ago
parent
commit
4aecef468f
  1. 74
      build/app-bundle.js
  2. 63
      build/twister-lib.js
  3. 16
      css/main.css
  4. 2
      index.html
  5. 26
      jsx/App.js
  6. 46
      jsx/common/Post.js

74
build/app-bundle.js

@ -247,6 +247,7 @@ if (accounts.length==0) {
host: appSettings.host, host: appSettings.host,
logfunc: function(log){console.log(log)}, logfunc: function(log){console.log(log)},
outdatedLimit: appSettings.pollInterval, outdatedLimit: appSettings.pollInterval,
signatureVerification: "none",
walletType: "client", walletType: "client",
querySettingsByType: { querySettingsByType: {
@ -263,31 +264,6 @@ if (accounts.length==0) {
initializeApp(); initializeApp();
/*Twister.importClientSideAccount("pampalulu","L12kz6tabDN6VmPes1rfEpiznztPF6vgkHp8UZVBgZadxzebHhAp",function(){
var activeAccount = localStorage.getItem("twister-react-activeAccount");
var accounts = Twister.getAccounts();
if (!activeAccount) {
activeAccount = accounts[0];
localStorage.setItem("twister-react-activeAccount",activeAccount);
}
console.log("active account defaulted to "+activeAccount)
console.log(Twister.getAccount(activeAccount))
Twister.getAccount(activeAccount).activateTorrents(function(){
initializeApp();
});
});
*/
} else { } else {
var activeAccount = localStorage.getItem("twister-react-activeAccount"); var activeAccount = localStorage.getItem("twister-react-activeAccount");
@ -566,7 +542,9 @@ module.exports = Post = React.createClass({displayName: "Post",
avatar: "img/genericPerson.png", avatar: "img/genericPerson.png",
fullname: "", fullname: "",
timeAgo: "", timeAgo: "",
retwistingUser: this.props.post.username retwistingUsername: this.props.post.username,
retwistingUserFullname: "",
retwistingUserAvatar: "img/genericPerson.png",
}; };
}, },
updateTimeAgo: function() { updateTimeAgo: function() {
@ -599,6 +577,12 @@ module.exports = Post = React.createClass({displayName: "Post",
}); });
}); });
post.getUser().doAvatar(function(avatar){
thisComponent.setStateSafe({
retwistingUserAvatar: avatar.getUrl()
});
});
post=post.getRetwistedPost(); post=post.getRetwistedPost();
} }
@ -623,11 +607,16 @@ module.exports = Post = React.createClass({displayName: "Post",
var post = Twister.getUser(this.props.post.username).getPost(this.props.post.id); var post = Twister.getUser(this.props.post.username).getPost(this.props.post.id);
var retwist = false; var retwist = false;
var retwistWithComment = false;
var comment = "";
if (post.isRetwist()) { if (post.isRetwist()) {
retwist = true; retwist = true;
if(post.isRetwistWithComment()){
retwistWithComment=true;
comment = post.getContent();
}
post=post.getRetwistedPost(); post=post.getRetwistedPost();
} }
if (post.isReply()) { if (post.isReply()) {
@ -667,24 +656,32 @@ module.exports = Post = React.createClass({displayName: "Post",
return ( return (
React.createElement(ListGroupItem, null, React.createElement(ListGroupItem, null,
React.createElement(Row, {className: "nomargin"}, React.createElement(Row, {className: "nomargin post-main"},
React.createElement(Col, {xs: 2, md: 2, className: "fullytight"}, React.createElement(Col, {xs: 1, md: 1, className: "fullytight"},
React.createElement("a", {href: "#/profile/"+post.getUsername()}, React.createElement("a", {href: "#/profile/"+post.getUsername()},
React.createElement("img", {className: "img-responsive", src: this.state.avatar}) React.createElement("img", {className: "img-responsive", src: this.state.avatar})
) )
), ),
React.createElement(Col, {xs: 9, md: 9}, React.createElement(Col, {xs: 11, md: 11},
React.createElement("strong", null, this.state.fullname), React.createElement(Row, null,
React.createElement(PostContent, {content: post.getContent()}) React.createElement(Col, {xs: 11, md: 11},
React.createElement("strong", null, this.state.fullname)
),
React.createElement(Col, {xs: 1, md: 1, className: "fullytight"},
React.createElement("small", null, this.state.timeAgo)
)
), ),
React.createElement(Col, {xs: 1, md: 1, className: "fullytight text-align-right"}, this.state.timeAgo) React.createElement(PostContent, {content: post.getContent()})
)
), ),
React.createElement(Row, {className: "nomargin"}, React.createElement(Row, {className: "nomargin"},
React.createElement(Col, {xs: 6, md: 6, className: "fullytight"}, React.createElement(Col, {xs: 8, md: 8, className: "fullytight"},
retwist && React.createElement("small", null, React.createElement("em", null, "retwisted by ", this.state.retwistingUserFullname)) retwist && React.createElement("small", null, React.createElement("em", null,
"retwisted by ", React.createElement("img", {className: "micro-avatar", src: this.state.retwistingUserAvatar}), this.state.retwistingUserFullname, retwistWithComment && ":"
))
), ),
React.createElement(Col, {xs: 4, md: 4, className: "fullytight text-align-right"}, React.createElement(Col, {xs: 2, md: 2, className: "fullytight text-align-right"},
conversationLink conversationLink
), ),
React.createElement(Col, {xs: 1, md: 1, className: "fullytight text-align-right"}, React.createElement(Col, {xs: 1, md: 1, className: "fullytight text-align-right"},
@ -693,6 +690,11 @@ module.exports = Post = React.createClass({displayName: "Post",
React.createElement(Col, {xs: 1, md: 1, className: "fullytight text-align-right"}, React.createElement(Col, {xs: 1, md: 1, className: "fullytight text-align-right"},
retwistLink retwistLink
) )
),
retwistWithComment && React.createElement(Row, null,
React.createElement(Col, {xs: 12, md: 12},
React.createElement("small", null, React.createElement(PostContent, {content: comment}))
)
) )
) )

63
build/twister-lib.js

@ -30001,8 +30001,8 @@ TwisterAccount.prototype.reply = function (replyusername,replyid,msg,cbfunc) {
this._signAndPublish(post,function(newpost){ this._signAndPublish(post,function(newpost){
var v = { var v = {
rt: newpost._data, sig_userpost: newpost._signature,
sig_rt: newpost._signature userpost: newpost._data
} }
thisAccount._dhtput( thisAccount._dhtput(
@ -30194,8 +30194,6 @@ TwisterAccount.prototype._dhtput = function(username,resource,sorm,value,seq,cbf
var p = { var p = {
height: info.blocks-1, height: info.blocks-1,
v:value,
seq: seq,
target:{ target:{
"n" : username, "n" : username,
"r" : resource, "r" : resource,
@ -30205,16 +30203,22 @@ TwisterAccount.prototype._dhtput = function(username,resource,sorm,value,seq,cbf
v: value v: value
}; };
console.log("dhtputraw",p) if(sorm=="s"){
p.seq=seq;
}
console.log("dhtputraw",username,resource,sorm,p)
thisAccount._privkey.sign(p,function(sig){ thisAccount._privkey.sign(p,function(sig,pWithBuffers){
var dhtentry = { var dhtentry = {
p: p, p: pWithBuffers,
sig_user:thisAccount._name, sig_user:thisAccount._name,
sig_p: sig sig_p: sig
} }
//console.log("p",dhtentry)
var message = bencode.encode(dhtentry); var message = bencode.encode(dhtentry);
thisAccount.RPC("dhtputraw",[message.toString("hex")],function(){ thisAccount.RPC("dhtputraw",[message.toString("hex")],function(){
@ -30275,10 +30279,14 @@ TwisterAccount.prototype._publishPostOnDht = function(v,cbfunc){
} }
); );
console.log(v)
if(v.userpost && v.userpost.msg){ if(v.userpost && v.userpost.msg){
var parsedContent = TwisterContentParser.parseContent(v.userpost.msg); var parsedContent = TwisterContentParser.parseContent(v.userpost.msg);
console.log("parsed content",parsedContent)
parsedContent.map(function(item){ parsedContent.map(function(item){
if(item.type=="hashtag"){ if(item.type=="hashtag"){
@ -30863,6 +30871,20 @@ TwisterPrivKey.prototype.sign = function (message_ori, cbfunc) {
var message = JSON.parse(JSON.stringify(message_ori)); var message = JSON.parse(JSON.stringify(message_ori));
if ("p" in message && (typeof message.p)=="object"){
if ("v" in message.p && (typeof message.p.v)=="object"){
if("sig_userpost" in message.p.v && !Buffer.isBuffer(message.p.v.sig_userpost)) {
message.p.v.sig_userpost = new Buffer(message.p.v.sig_userpost, 'hex');
}
if ("userpost" in message.p.v) {
if ("sig_rt" in message.p.v.userpost && !Buffer.isBuffer(message.p.v.userpost.sig_rt)) {
message.p.v.userpost.sig_rt = new Buffer(message.p.v.userpost.sig_rt, 'hex');
}
}
}
}
if ("v" in message && (typeof message.v)=="object"){ if ("v" in message && (typeof message.v)=="object"){
if("sig_userpost" in message.v && !Buffer.isBuffer(message.v.sig_userpost)) { if("sig_userpost" in message.v && !Buffer.isBuffer(message.v.sig_userpost)) {
message.v.sig_userpost = new Buffer(message.v.sig_userpost, 'hex'); message.v.sig_userpost = new Buffer(message.v.sig_userpost, 'hex');
@ -30877,6 +30899,9 @@ TwisterPrivKey.prototype.sign = function (message_ori, cbfunc) {
if ("sig_rt" in message && !Buffer.isBuffer(message.sig_rt)) { if ("sig_rt" in message && !Buffer.isBuffer(message.sig_rt)) {
message.sig_rt = new Buffer(message.sig_rt, 'hex'); message.sig_rt = new Buffer(message.sig_rt, 'hex');
} }
if("sig_userpost" in message && !Buffer.isBuffer(message.sig_userpost)) {
message.sig_userpost = new Buffer(message.sig_userpost, 'hex');
}
var Twister = this._scope; var Twister = this._scope;
@ -30886,11 +30911,13 @@ TwisterPrivKey.prototype.sign = function (message_ori, cbfunc) {
var startTime = Date.now(); var startTime = Date.now();
message = bencode.encode(message); //console.log("signing",message);
bmessage = bencode.encode(message);
try { try {
var retVal = Bitcoin.message.sign(keyPair,message ,twister_network); var retVal = Bitcoin.message.sign(keyPair,bmessage ,twister_network);
cbfunc(retVal) cbfunc(retVal,message)
} catch(e) { } catch(e) {
//console.log(e) //console.log(e)
thisResource._handleError({ thisResource._handleError({
@ -33363,6 +33390,14 @@ TwisterPost.prototype.isRetwist = function () {
return ("rt" in this._data); return ("rt" in this._data);
} }
/** @function
* @name isRetwist
* @description returns true if the postis an rewtist.
*/
TwisterPost.prototype.isRetwistWithComment = function () {
return ("rt" in this._data && "msg" in this._data);
}
/** @function /** @function
* @name getRetwistedId * @name getRetwistedId
@ -33903,6 +33938,10 @@ TwisterPubKey.prototype.getKey = function () {
TwisterPubKey.prototype.verifySignature = function (message_ori, signature_ori, cbfunc) { TwisterPubKey.prototype.verifySignature = function (message_ori, signature_ori, cbfunc) {
var verifySignatures = (this.getQuerySetting("signatureVerification")!="none");
if(verifySignatures){
var thisResource = this; var thisResource = this;
var signature = JSON.parse(JSON.stringify(signature_ori)); var signature = JSON.parse(JSON.stringify(signature_ori));
@ -33967,7 +34006,9 @@ TwisterPubKey.prototype.verifySignature = function (message_ori, signature_ori,
},timeout); },timeout);
}else{
cbfunc(true);
}
} }
}).call(this,require("buffer").Buffer) }).call(this,require("buffer").Buffer)

16
css/main.css

@ -7,6 +7,10 @@ body.modal-open {
margin: 0; margin: 0;
} }
.container {
padding: 0;
}
.modal { .modal {
overflow: auto; overflow: auto;
} }
@ -45,6 +49,7 @@ body.modal-open {
.img-responsive { .img-responsive {
width: 100%; width: 100%;
border-radius: 0.25em;
} }
.item-enter { .item-enter {
@ -65,6 +70,10 @@ body.modal-open {
opacity: 0.01; opacity: 0.01;
} }
.post-main{
margin-bottom: 5px;
}
.mention { .mention {
color: red; color: red;
} }
@ -81,3 +90,10 @@ body.modal-open {
color: coral; color: coral;
} }
.micro-avatar {
height: 1em;
border-radius: 0.25em;
vertical-align: text-top;
margin-left: 0.25em;
margin-right: 0.125em;
}

2
index.html

@ -11,7 +11,7 @@
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css"> <link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="css/paper-theme.css"> <link rel="stylesheet" type="text/css" href="css/paper-theme.css">
<link rel="stylesheet" type="text/css" href="css/main.css"> <link rel="stylesheet" type="text/css" href="css/main.css">
<meta name="viewport" content="width=548" /> <meta name="viewport" content="width=360, user-scalable=no" />
</head> </head>
<body> <body>

26
jsx/App.js

@ -246,6 +246,7 @@ if (accounts.length==0) {
host: appSettings.host, host: appSettings.host,
logfunc: function(log){console.log(log)}, logfunc: function(log){console.log(log)},
outdatedLimit: appSettings.pollInterval, outdatedLimit: appSettings.pollInterval,
signatureVerification: "none",
walletType: "client", walletType: "client",
querySettingsByType: { querySettingsByType: {
@ -262,31 +263,6 @@ if (accounts.length==0) {
initializeApp(); initializeApp();
/*Twister.importClientSideAccount("pampalulu","L12kz6tabDN6VmPes1rfEpiznztPF6vgkHp8UZVBgZadxzebHhAp",function(){
var activeAccount = localStorage.getItem("twister-react-activeAccount");
var accounts = Twister.getAccounts();
if (!activeAccount) {
activeAccount = accounts[0];
localStorage.setItem("twister-react-activeAccount",activeAccount);
}
console.log("active account defaulted to "+activeAccount)
console.log(Twister.getAccount(activeAccount))
Twister.getAccount(activeAccount).activateTorrents(function(){
initializeApp();
});
});
*/
} else { } else {
var activeAccount = localStorage.getItem("twister-react-activeAccount"); var activeAccount = localStorage.getItem("twister-react-activeAccount");

46
jsx/common/Post.js

@ -57,7 +57,9 @@ module.exports = Post = React.createClass({
avatar: "img/genericPerson.png", avatar: "img/genericPerson.png",
fullname: "", fullname: "",
timeAgo: "", timeAgo: "",
retwistingUser: this.props.post.username retwistingUsername: this.props.post.username,
retwistingUserFullname: "",
retwistingUserAvatar: "img/genericPerson.png",
}; };
}, },
updateTimeAgo: function() { updateTimeAgo: function() {
@ -90,6 +92,12 @@ module.exports = Post = React.createClass({
}); });
}); });
post.getUser().doAvatar(function(avatar){
thisComponent.setStateSafe({
retwistingUserAvatar: avatar.getUrl()
});
});
post=post.getRetwistedPost(); post=post.getRetwistedPost();
} }
@ -114,11 +122,16 @@ module.exports = Post = React.createClass({
var post = Twister.getUser(this.props.post.username).getPost(this.props.post.id); var post = Twister.getUser(this.props.post.username).getPost(this.props.post.id);
var retwist = false; var retwist = false;
var retwistWithComment = false;
var comment = "";
if (post.isRetwist()) { if (post.isRetwist()) {
retwist = true; retwist = true;
if(post.isRetwistWithComment()){
retwistWithComment=true;
comment = post.getContent();
}
post=post.getRetwistedPost(); post=post.getRetwistedPost();
} }
if (post.isReply()) { if (post.isReply()) {
@ -158,24 +171,32 @@ module.exports = Post = React.createClass({
return ( return (
<ListGroupItem> <ListGroupItem>
<Row className="nomargin"> <Row className="nomargin post-main">
<Col xs={2} md={2} className="fullytight"> <Col xs={1} md={1} className="fullytight">
<a href={"#/profile/"+post.getUsername()}> <a href={"#/profile/"+post.getUsername()}>
<img className="img-responsive" src={this.state.avatar}/> <img className="img-responsive" src={this.state.avatar}/>
</a> </a>
</Col> </Col>
<Col xs={9} md={9}> <Col xs={11} md={11}>
<Row>
<Col xs={11} md={11}>
<strong>{this.state.fullname}</strong> <strong>{this.state.fullname}</strong>
</Col>
<Col xs={1} md={1} className="fullytight">
<small>{this.state.timeAgo}</small>
</Col>
</Row>
<PostContent content={post.getContent()}/> <PostContent content={post.getContent()}/>
</Col> </Col>
<Col xs={1} md={1} className="fullytight text-align-right">{this.state.timeAgo}</Col>
</Row> </Row>
<Row className="nomargin"> <Row className="nomargin">
<Col xs={6} md={6} className="fullytight"> <Col xs={8} md={8} className="fullytight">
{retwist && <small><em>retwisted by {this.state.retwistingUserFullname}</em></small> {retwist && <small><em>
retwisted by <img className="micro-avatar" src={this.state.retwistingUserAvatar} />{this.state.retwistingUserFullname}{retwistWithComment && ":"}
</em></small>
} }
</Col> </Col>
<Col xs={4} md={4} className="fullytight text-align-right"> <Col xs={2} md={2} className="fullytight text-align-right">
{conversationLink} {conversationLink}
</Col> </Col>
<Col xs={1} md={1} className="fullytight text-align-right"> <Col xs={1} md={1} className="fullytight text-align-right">
@ -185,7 +206,12 @@ module.exports = Post = React.createClass({
{retwistLink} {retwistLink}
</Col> </Col>
</Row> </Row>
{retwistWithComment && <Row>
<Col xs={12} md={12}>
<small><PostContent content={comment}/></small>
</Col>
</Row>
}
</ListGroupItem> </ListGroupItem>
); );
} }

Loading…
Cancel
Save