Skip to content

Commit 61ef72d

Browse files
committed
add magicycles widget and bug fixes
1 parent 78645e7 commit 61ef72d

File tree

9 files changed

+56
-12
lines changed

9 files changed

+56
-12
lines changed

ajax.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def get_posts_by_tag(name, page=1, per_page=10):
790790
HOT_TAGS_CACHE_KEY = "hot_tags_count:%d"
791791

792792

793-
def get_hot_tags(count=16):
793+
def get_hot_tags(count=12):
794794
"""get hot tags.
795795
Args:
796796
count: tags count

model/model_bae.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def __init__(self, name):
555555
def post_ids(self):
556556
if not self._post_id_list:
557557
return []
558-
return [id for id in self._post_id_list.split(",") if id and id.strip()]
558+
return [long(id) for id in self._post_id_list.split(",") if id and id.strip()]
559559

560560
@post_ids.setter
561561
def post_ids(self, value):
@@ -577,7 +577,9 @@ def remove_post_id(self, post_id):
577577
self.save()
578578

579579
def get_posts(self, page=1, per_page=10):
580-
ids = self.post_ids[(page-1)*per_page:page*per_page]
580+
posts_list = map(long, set(self.post_ids))
581+
posts_list.sort(reverse=True)
582+
ids = posts_list[(page-1)*per_page:page*per_page]
581583
return [post for post in DBPost.get_by_ids(ids) if post and post.public]
582584

583585
@classmethod

model/model_gae.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,9 @@ def remove_post_id(self, post_id):
550550
self.save()
551551

552552
def get_posts(self, page=1, per_page=10):
553-
ids = self._post_id_list[(page-1)*per_page:page*per_page]
553+
posts_list = map(long, set(self._post_id_list))
554+
posts_list.sort(reverse=True)
555+
ids = posts_list[(page-1)*per_page:page*per_page]
554556
return [post for post in DBPost.get_by_ids(ids) if post and post.public]
555557

556558
@classmethod

static/js/main.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ Date.prototype.format = function(format) {
8383

8484
var players_settings = {
8585
youku: {
86-
link: /<a.+href="http.+v.youku.com\/v_show\/id_(\S+)\.html.*".*>.*<\/a>/gm,
86+
link: /<a.+href="http:\/\/v.youku.com\/v_show\/id_(\S+)\.html.*".*>.*<\/a>/gm,
8787
player: function(match){
8888
return '<div><iframe class="video_player"' +
8989
'src="http://player.youku.com/embed/{0}?wmode=transparent" '.format(match[1]) +
9090
'frameborder=0 allowfullscreen wmode="transparent"></iframe></div>'
9191
}
9292
},
9393
xiami: {
94-
link: /<a.+href="http.+www.xiami.com\/song\/(\d+).*".*>.*<\/a>/gm,
94+
link: /<a.+href="http:\/\/www.xiami.com\/song\/(\d+).*".*>.*<\/a>/gm,
9595
player: function(match){
9696
var s = '<div><embed src="http://www.xiami.com/widget/0_{0}/singlePlayer.swf" ' +
9797
'type="application/x-shockwave-flash" width="257" height="33" ' +
@@ -100,7 +100,7 @@ Date.prototype.format = function(format) {
100100
}
101101
},
102102
xiami_album: {
103-
link: /<a.+href="http.+www.xiami.com\/album\/(\d+).*".*>.*<\/a>/gm,
103+
link: /<a.+href="http:\/\/www.xiami.com\/album\/(\d+).*".*>.*<\/a>/gm,
104104
player: function(match){
105105
var s = '<div><embed src="http://www.xiami.com/widget/' +
106106
'0_{0}_235_346_FF8719_494949/albumPlayer.swf" ' +
@@ -110,28 +110,37 @@ Date.prototype.format = function(format) {
110110
}
111111
},
112112
youtube: {
113-
link: /<a.+href="http.+www.youtube.com\/watch\?.*v=([^\s&]+).*".*>.*<\/a>/gm,
113+
link: /<a.+href="http:\/\/www.youtube.com\/watch\?.*v=([^\s&]+).*".*>.*<\/a>/gm,
114114
player: function(match){
115115
return '<div><iframe class="video_player" ' +
116116
'src="http://www.youtube.com/embed/{0}?wmode=transparent" '.format(match[1]) +
117117
'frameborder="0" allowfullscreen wmode="transparent"></iframe></div>'
118118
}
119119
},
120120
ku6: {
121-
link: /<a.+href="http.+v.ku6.com\/show\/(\S+)\.html.*".*>.*<\/a>/gm,
121+
link: /<a.+href="http:\/\/v.ku6.com\/show\/(\S+)\.html.*".*>.*<\/a>/gm,
122122
player: function(match){
123123
return '<div><embed src="http://player.ku6.com/refer/{0}/v.swf" '.format(match[1]) +
124124
'class="video_player" allowscriptaccess="always" wmode="transparent"' +
125125
'allowfullscreen="true" type="application/x-shockwave-flash" flashvars="from=ku6"></embed></div>'
126126
}
127127
},
128128
qq: {
129-
link: /<a.+href="http.+v.qq.com\/.+vid=([^\s&\/]+).*".*>.*<\/a>/gm,
129+
link: /<a.+href="http:\/\/v.qq.com\/.+vid=([^\s&\/]+).*".*>.*<\/a>/gm,
130130
player: function(match){
131131
return '<div><embed src="http://static.video.qq.com/TPout.swf?vid={0}&auto=0" '.format(match[1]) +
132132
'allowFullScreen="true" quality="high" class="video_player" wmode="transparent"' +
133133
'align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed></div>'
134134
}
135+
},
136+
magicycles: {
137+
link: /<a.+href="http:\/\/www.magicycles.com\/(riders|routes)\/([^\s\/]+)".*>.*<\/a>/gm,
138+
player: function(match){
139+
return '<div class="magicycles_widget">' +
140+
'<iframe class="magicycles_widget"' +
141+
' src="http://www.magicycles.com/{0}/{1}/widget" '.format(match[1], match[2]) +
142+
' scrolling="no" frameborder="0" allowfullscreen wmode="transparent"></iframe></div>';
143+
}
135144
}
136145
};
137146
$.create_player = function(text){

static/styles/default.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ code {
570570
width: 460px;
571571
height: 380px;
572572
}
573+
.magicycles_widget {
574+
width: 100%;
575+
height: 90px;
576+
}
573577
@media (min-width: 1200px) {
574578
.affix {
575579
position: fixed;
@@ -596,7 +600,11 @@ code {
596600
margin: auto;
597601
}
598602
.video_player {
599-
width: 260px;
603+
width: auto;
600604
height: 220px;
601605
}
606+
.magicycles_widget {
607+
width: auto;
608+
height: auto;
609+
}
602610
}

templates/_list.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
$(".post-author", $post).text(post.author.nickname);
6262
$(".post-viewed", $post).html(post.stats.view_count);
6363
$(".share", $post).html('<i class="icon-share"></i>{0}'.format(post.stats.share_count));
64+
$(".share", $post).unbind("click");
6465
$(".share", $post).click(function(){
6566
show_share(post);
6667
});

templates/_timeline.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
$(".post-category", $post).attr("href","/"+post.category.url).append(post.category.name);
4747
$(".post-viewed", $post).html(post.stats.view_count);
4848
$(".share", $post).html('<i class="icon-share"></i>{0}'.format(post.stats.share_count));
49+
$(".share", $post).unbind("click");
4950
$(".share", $post).click(function(){
5051
show_share(post);
5152
});

templates/admin.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,18 @@
145145
});
146146
});
147147

148-
148+
{% if user.is_owner() %}
149+
$("#flush_cache").click(function(){
150+
$.json_action("admin/memcache",
151+
{action: $.toJSON("flush_all")},
152+
function(resp){
153+
bootbox.alert("{{ _("Deleted") }}");
154+
},function(err){
155+
bootbox.alert(err);
156+
});
157+
return false;
158+
});
159+
{% endif %}
149160
});
150161
</script>
151162
{% endblock %}
@@ -210,6 +221,12 @@
210221
value="{{ settings.ga_tracking_id or "" }}"/>
211222
</div>
212223
</div>
224+
<div class="control-group">
225+
<label class="control-label">{{ _("Memcache") }}</label>
226+
<div class="controls">
227+
<button class="btn btn-danger" id="flush_cache">{{ _("Flush Cache") }}</button>
228+
</div>
229+
</div>
213230
</form>
214231
</div>
215232
<div class="tab-pane fade"

templates/tags.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
$(".post-author", $post).text(post.author.nickname);
5151
$(".post-viewed", $post).html(post.stats.view_count);
5252
$(".share", $post).html('<i class="icon-share"></i>{0}'.format(post.stats.share_count));
53+
$(".share", $post).unbind("click");
54+
$(".share", $post).click(function(){
55+
show_share(post);
56+
});
5357
$(".stats[name=like_count]", $post).html('<i class="icon-thumbs-up"></i>{0}'.format(post.stats.like_count));
5458
$(".stats[name=unlike_count]", $post).html('<i class="icon-thumbs-down"></i>{0}'.format(post.stats.unlike_count));
5559
$(".comment", $post).html('<i class="icon-comment"></i>{0}'.format(post.stats.comment_count));

0 commit comments

Comments
 (0)