Permalink
Browse files

画像はCDN経由で。

  • Loading branch information...
1 parent 891ce38 commit 0bda0ee24eec82c08e9a51c32b7c28bef72c918e @nanto nanto committed May 23, 2011
Showing with 16 additions and 10 deletions.
  1. +1 −1 src/background/popup.js
  2. +3 −3 src/content/widget_embedder.js
  3. +1 −1 src/lib/02-Utils.js
  4. +5 −2 src/lib/15-UserManager.js
  5. +4 −1 src/lib/50-HatenaStar.js
  6. +2 −2 src/tests/test.js
View
@@ -838,7 +838,7 @@ var View = {
$('#url').text(Utils.truncate(url, 50)).attr('title', url).attr('href', url);
if (!$('#favicon').attr('src')) {
- var favicon= new URI('http://favicon.st-hatena.com');
+ var favicon= new URI('http://cdn-ak.favicon.st-hatena.com/');
favicon.param({url: url});
this.faviconEL.attr('src', favicon);
}
@@ -3,7 +3,7 @@
// XXX ToDo: Consider about namespaces.
const B_HTTP = 'http://b.hatena.ne.jp/';
-const B_STATIC_HTTP = 'http://b.st-hatena.com/';
+const B_STATIC_HTTP = 'http://cdn-ak.b.st-hatena.com/';
var SiteinfoRequestor = {
init: function SR_init() {
@@ -174,7 +174,7 @@ extend(WidgetEmbedder.prototype, {
const sharpEscapedURL = url.replace(/#/g, '%23');
const entryURL = getEntryURL(url);
const oldEntryURL = B_HTTP + 'entry/' + sharpEscapedURL;
- const imageAPIPrefix = B_STATIC_HTTP + 'entry/image/';
+ const imageAPIPrefix = 'http://b.st-hatena.com/entry/image/';
const oldImageAPIPrefix = B_HTTP + 'entry/image/';
const addURL = B_HTTP + 'my/add.confirm?url=' + encodeURIComponent(url);
const oldAddURL = B_HTTP + 'append?' + sharpEscapedURL;
@@ -229,7 +229,7 @@ extend(WidgetEmbedder.prototype, {
var url = link.href;
var sharpEscapedURL = url.replace(/#/g, '%23');
var img = E('img', {
- src: B_STATIC_HTTP + 'entry/image/' + sharpEscapedURL,
+ src: 'http://b.st-hatena.com/entry/image/' + sharpEscapedURL,
alt: WidgetEmbedder.messages.SHOW_ENTRY_TEXT,
style: 'display: none;',
});
View
@@ -3,7 +3,7 @@
var GLOBAL = this;
var B_HOST = 'b.hatena.ne.jp';
var B_HTTP = 'http://' + B_HOST + '/';
-var B_STATIC_HOST = 'b.st-hatena.com';
+var B_STATIC_HOST = 'cdn-ak.b.st-hatena.com';
var B_STATIC_HTTP = 'http://' + B_STATIC_HOST + '/';
var B_API_STATIC_HOST = 'api.b.st-hatena.com';
var B_API_STATIC_HTTP = 'http://' + B_API_STATIC_HOST + '/';
@@ -64,8 +64,11 @@ User.View = function(name) {
User.View.prototype = {
getProfileIcon: function(name, isLarge) {
- return sprintf('http://www.st-hatena.com/users/%s/%s/profile%s.gif',
- name.substring(0, 2), name, isLarge ? '' : '_s');
+ var n = 0;
+ for (var i = 0; i < name.length; i++)
+ n += name.charCodeAt(i);
+ return sprintf('http://cdn%d.www.st-hatena.com/users/%s/%s/profile%s.gif',
+ n % 5, name.substring(0, 2), name, isLarge ? '' : '_s');
},
get icon() {
return this.getProfileIcon(this.name);
View
@@ -2132,8 +2132,11 @@ Hatena.Star.User = new Ten.Class({
if (src) {
img.src = src;
} else {
+ var n = 0;
+ for (var i = 0; i < name.length; i++)
+ n += name.charCodeAt(i);
var pre = name.match(/^[\w-]{2}/)[0];
- img.src = 'http://www.st-hatena.com/users/' + pre + '/' + name + '/profile_s.gif';
+ img.src = 'http://cdn' + (n % 5) + '.www.st-hatena.com/users/' + pre + '/' + name + '/profile_s.gif';
}
img.setAttribute('alt', name);
img.setAttribute('title', name);
View
@@ -746,8 +746,8 @@ test('Model Bookmark/Tag', function(d) {
test('UserView', function(d) {
var view = new User.View('nagayama');
- equals(view.icon , 'http://www.st-hatena.com/users/na/nagayama/profile_s.gif');
- equals(view.largeIcon, 'http://www.st-hatena.com/users/na/nagayama/profile.gif');
+ ok(view.icon.match(/\/users\/na\/nagayama\/profile_s\.gif$/));
+ ok(view.largeIcon.match(/\/users\/na\/nagayama\/profile\.gif$/));
d.call();
}).

0 comments on commit 0bda0ee

Please sign in to comment.