Permalink
Browse files

Merge branch 'master' of github.com:timehome/djangodash2011

  • Loading branch information...
2 parents 6c570f7 + 0c24abb commit b173bb45ad1cc738df6e2a9daaa0db06e2511490 @rafaelcaricio rafaelcaricio committed Jul 31, 2011
@@ -148,8 +148,9 @@ class CroppedPhoto(models.Model):
url = models.CharField(max_length=500, db_index=True)
hash = models.CharField(max_length=200, null=True, db_index=True)
- def set_hash(self):
- self.hash = md5(self.url).hexdigest()
+ @classmethod
+ def get_hash(cls, url):
+ return md5(url).hexdigest()
def get_absolute_url(self):
return "%s.%s" % (self.hash, splitext(self.url)[-1].lstrip('.'))
@@ -24,6 +24,18 @@
padding-bottom: 12px;
}
+.crop-popin .crop h3 {
+ padding-bottom: 12px;
+}
+
+.crop-popin .crop p {
+ margin-bottom: 12px;
+}
+
+.crop-popin .crop .crop-image-container {
+ overflow: hidden;
+}
+
.crop-popin .crop .photo {
margin-bottom: 16px;
}
@@ -59,14 +71,39 @@
.crop-popin .crop .share-details {
visibility: hidden;
+ padding-top: 12px;
+}
+
+.crop-popin .crop .preview img {
+ display: block;
+ margin: 0 auto;
+ border: #333 solid 4px;
+ border-radius: 4px;
}
.markup {
font-family: courier;
font-size: 13px;
background-color: #333;
- color: white;
+ color: #fff;
width: 580px;
height: 78px;
padding: 10px;
}
+
+.socials {
+ overflow: hidden;
+}
+
+.social-item {
+ margin-right: 12px;
+ float: left;
+}
+
+.social-item.twitter {
+ padding-top: 2px;
+}
+
+#___plusone_0 {
+ width: 38px !important;
+}
@@ -0,0 +1,12 @@
+body {
+ background: #ddd;
+ color: #333;
+ font-family: arial,helvetica,freesans,sans-serif;
+}
+a {
+ color: #c73ed7;
+ text-decoration: underline;
+}
+a:hover {
+ text-decoration: none;
+}
@@ -28,7 +28,6 @@ header h1 {
text-shadow: 0 1px #fff, 1px 0 #fff, -1px 0 #fff, 0 -1px #fff;
padding: 0 14px 8px 0;
margin-right: 14px;
- border-right: 1px solid #474747;
}
header h1:hover {
text-shadow: 0 1px #fff, 1px 0 #fff, -1px 0 #fff, 0 -1px #fff,
@@ -1,14 +1,11 @@
html {
overflow: hidden;
}
-html, body, h1, h2, ul, ol{
+html, body, h1, h2, h3, h4, h5, h6, ul, ol, p {
padding: 0;
margin: 0;
}
-body {
- background: #ddd;
- font-family: arial,helvetica,freesans,sans-serif;
-}
ul, ol{
list-style: none;
}
+
@@ -5,6 +5,7 @@
initialize: function(){
this.parent.apply(this, arguments);
+ this.selectElements();
this.bindEvents();
this.createRequest();
},
@@ -15,16 +16,21 @@
});
},
- bindEvents: function() {
+ selectElements: function() {
this.shareButton = this.element.getElement('.share-button');
this.token = this.element.getElement('[name="csrfmiddlewaretoken"]');
- this.shareButton.addEvent('click', this.share.bind(this));
this.shareArea = this.element.getElement('div.share-details');
this.croppedLink = this.element.getElement('a.url');
this.embedURL = this.element.getElement('span.url');
this.embedTitle = this.element.getElement('span.title');
this.embedComments = this.element.getElement('span.comment-page');
this.socials = this.element.getElement('div.socials');
+ this.cropContainer = this.element.getElement('div.crop-image-container');
+ this.preview = this.element.getElement('div.preview');
+ },
+
+ bindEvents: function() {
+ this.shareButton.addEvent('click', this.share.bind(this));
},
share: function(e) {
@@ -35,13 +41,22 @@
data[this.token.get('name')] = this.token.get('value');
this.request.addEvent('success', function(url) {
var shareUrl = 'http://myimg.at/shared_photo/' + self.image.id;
+ new Element('img', {src: url}).inject(self.preview.empty());
+ self.cropContainer.morph({height: 0});
self.croppedLink.set('href', url);
self.croppedLink.set('text', self.image.title);
self.embedURL.set('text', url);
self.embedTitle.set('text', self.image.title);
self.embedComments.set('text', shareUrl);
self.socials.empty();
- self.socials.set('html', '<a target="_blank" title="tweet this image" href="http://twitter.com/share?url=' + shareUrl + '&via=myimgat&text=' + self.image.title + '" class="twitter-share-button"><img src="/static/wall/img/tweetn.png" alt="tweet this image" /></a>');
+
+ var twitter = '<div class="social-item twitter"><a target="_blank" title="tweet this image" href="http://twitter.com/share?url=' + shareUrl + '&via=myimgat&text=' + self.image.title + '" class="twitter-share-button"><img src="/static/wall/img/tweetn.png" alt="tweet this image" /></a></div>';
+ var gplus = '<div class="social-item"><g:plusone href="url"></g:plusone></div>';
+ var fbLike = '<div class="social-item"><iframe src="http://www.facebook.com/plugins/like.php?app_id=102452659856143&amp;href=' + shareUrl + '&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:24px;" allowTransparency="true"></iframe></div>';
+ var fbSend = '<div class="social-item"><div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:send href="' + shareUrl + '" font="arial"></fb:send></div>';
+
+ self.socials.set('html', twitter + gplus + fbLike + fbSend);
+ gapi.plusone.go();
self.shareArea.fade('in');
}).post(data);
},
@@ -51,6 +66,8 @@
if (tab) {
this.showTab(tab);
}
+ this.preview.empty();
+ this.cropContainer.setStyle('height', 'auto');
this.element.addClass('show');
this.shareArea.fade('out');
return this;
@@ -3,6 +3,7 @@
{% block head %}
{% block css %}
<link href="{{ STATIC_URL }}wall/css/reset.css" rel="stylesheet" type="text/css" />
+ <link href="{{ STATIC_URL }}wall/css/defaults.css" rel="stylesheet" type="text/css" />
<link href="{{ STATIC_URL }}wall/css/header.css" rel="stylesheet" type="text/css" />
<link href="{{ STATIC_URL }}wall/css/overlay.css" rel="stylesheet" type="text/css" />
<link href="{{ STATIC_URL }}wall/css/popin.css" rel="stylesheet" type="text/css" />
@@ -11,7 +12,6 @@
<link href="{{ STATIC_URL }}wall/css/wall.css" rel="stylesheet" type="text/css" />
{% endblock %}
-
{% block open_graph %}
<meta property="og:title" content="MyImg.at"/>
<meta property="og:type" content="website"/>
@@ -9,7 +9,7 @@
</script>
{% for association in still_unassociated %}
- <span class="{{ association.class }}"><a href="{{ association.url }}">{{ association.label }}</a></span>
+ <a class="{{ association.class }}" href="{{ association.url }}">{{ association.label }}</a>
{% endfor %}
<span>{{ username }}</span>
@@ -12,14 +12,16 @@ <h2>Show, see, crop and share your photos easily!</h2>
<div id="crop-popin" class="crop-popin popin">
<div class="crop">
<h2>image title</h2>
- <div class="photo"></div>
- <a class="share-button" href="#">share photo</a>
+ <div class="crop-image-container">
+ <div class="photo"></div>
+ <a class="share-button" href="#">share photo</a>
+ </div>
+ <div class="preview"></div>
<div class="share-details">
<h3>Share this url: <a href="#" target="_blank" class="url"></a></h3>
<h3>Embed:</h3>
<p class="markup">&lt;a href=&quot;<span class="comment-page"></span>&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;img <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src=&quot;<span class="url"></span>&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alt=&quot;<span class="title"></span>&quot; /&gt;<br />&lt;/a&gt;</p>
- <div class="socials">
- </div>
+ <div class="socials"></div>
</div>
{% csrf_token %}
</div>
@@ -102,14 +102,12 @@ def save_cropped_photo(request, username=None):
fake_original
)
- cropped = CroppedPhoto.objects.create(
+ cropped, created = CroppedPhoto.objects.get_or_create(
original_photo=photo,
- url=url
+ url=url,
+ hash=CroppedPhoto.get_hash(url)
)
- cropped.set_hash()
- cropped.save()
-
return HttpResponse(request.build_absolute_uri('../' + cropped.get_absolute_url()))
def shortened_url(request, image_hash):
@@ -23,6 +23,10 @@
{% endblock %}
<script src="{{ STATIC_URL }}wall/js/analytics.js"></script>
+ <script type="text/javascript" src="https://apis.google.com/js/plusone.js">
+ {parsetags: 'explicit'}
+ </script>
+
</body>
</html>

0 comments on commit b173bb4

Please sign in to comment.