Skip to content
Browse files

various improvements

  • Loading branch information...
1 parent b68eea5 commit 98983a435d2c8428a4d8fd37a86a1898d39a6c63 @jchris committed Mar 1, 2010
View
20 _attachments/style/main.css
@@ -57,15 +57,22 @@ ul {
border: 1px solid #999;
background-color:#ddd;
-webkit-border-radius:14px;
- -webkit-transition-property:background-color;
- -webkit-transition-duration:0.5s;
-moz-border-radius:14px;
- -moz-transition-property:background-color;
- -moz-transition-duration:0.5s;
}
+#chat li a.delete {
+ color:#ddd;
+ -webkit-transition-property:color;
+ -webkit-transition-duration:0.25s;
+ -moz-transition-property:color;
+ -moz-transition-duration:0.25s;
+}
+
+#chat li:hover a.delete {
+ color:#00b;
+}
-#chat .date {
+#chat .meta {
font-size: 0.78em;
color:#333;
padding:4px;
@@ -81,6 +88,9 @@ form {
margin:6px;
}
+input[name=message] {
+ width:88%;
+}
div.avatar {
padding:2px;
View
15 evently/chat/join/selectors/ul/_changes/data.js
@@ -1,10 +1,17 @@
function(row) {
var v = row.value;
- return {
- avatar_url : v.author && v.author.gravatar_url,
+ var d = {
+ avatar_url : v.author && v.author.gravatar_url || "",
body : $.linkify($.mustache.escape(v.body)),
- name : v.author && v.author.nickname,
- url : v.author && v.author.url,
+ name : v.author && v.author.nickname || "",
+ url : v.author && v.author.url || "",
+ id : row.id,
created_at : $.prettyDate(v.created_at)
};
+ var p = $$("#profile").profile;
+ if (p && v.author && v.author.rand && (v.author.rand == p.rand)) {
+ // todo _admin owns everything...
+ d.owned = true;
+ }
+ return d;
};
View
9 evently/chat/join/selectors/ul/_changes/mustache.html
@@ -1,10 +1,13 @@
-<li>
+<li data-id="{{id}}">
<div class="avatar">
- <img src="{{avatar_url}}"/>
+ {{#avatar_url}}<img src="{{avatar_url}}"/>{{/avatar_url}}
<br/>
<a class="name" href="{{url}}">{{name}}</a>
</div>
<div class="body">{{{body}}}</div>
- <div class="date">{{created_at}}</div>
+ <div class="meta">
+ <span class="date">{{created_at}}</span>
+ {{#owned}}<a class="delete" href="#delete">[x]</a>{{/owned}}
+ </div>
<div class="clear"></div>
</li>
View
18 evently/chat/join/selectors/ul/_changes/selectors/a[href=#delete]/click.js
@@ -0,0 +1,18 @@
+function() {
+ var li = $(this).parents("li");
+ var app = $$(this).app;
+ $.log("d",li);
+ var message_id = li.attr("data-id");
+ app.db.openDoc(message_id, {
+ success : function(doc) {
+ $.log("delete", doc)
+ app.db.removeDoc(doc, {
+ success : function() {
+ li.slideUp("slow");
+ }
+ });
+ }
+ });
+
+ return false;
+};
View
3 evently/chat/newChannel/selectors/form/submit.js
@@ -6,7 +6,8 @@ function() {
id : "toast.channel:"+name,
channel : name,
desc : $("input[name=desc]", f).val(),
- type : "channel"
+ type : "channel",
+ author : $$("#profile").profile
};
app.db.saveDoc(doc, {
success : function() {
View
9 validate_doc_update.js
@@ -9,6 +9,15 @@ function (newDoc, oldDoc, userCtx) {
if (userCtx.roles.indexOf('_admin') == -1) {
// admin can edit anything, only check when not admin...
+ if (!newDoc.author || !newDoc.author.name) {
+ forbidden("Docs must have an author with a name");
+ }
+ // you can't lie about authorship
+ if (newDoc.author.name != userCtx.name) {
+ forbidden("You may only update your own docs.");
+ }
+ // you can only update your own docs
+
if (newDoc._deleted)
forbidden("You may not delete a doc.");
}
View
3 vendor/couchapp/evently/profile/loggedIn.js
@@ -8,6 +8,9 @@ function(e, r) {
success : function(userDoc) {
var profile = userDoc["couch.app.profile"];
if (profile) {
+ // we copy the name to the profile so it can be used later
+ // without publishing the entire userdoc (roles, pass, etc)
+ profile.name = userDoc.name;
$$(widget).profile = profile;
widget.trigger("profileReady", [profile]);
} else {
View
3 vendor/couchapp/evently/profile/profileReady/after.js
@@ -0,0 +1,3 @@
+function(e, p) {
+ $$(this).profile = p;
+};
View
2 vendor/couchapp/evently/profile/profileReady/mustache.html
@@ -1,5 +1,5 @@
<div class="avatar">
- {{#avatar_url}}<img src="{{{avatar_url}}}"/>{{/avatar_url}}
+ {{#avatar_url}}<img src="{{avatar_url}}"/>{{/avatar_url}}
<div class="name">
{{nickname}}
</div>

0 comments on commit 98983a4

Please sign in to comment.
Something went wrong with that request. Please try again.