汤博勒 —在主页上获取 8 位转发代码(几乎就在那里......)
我见过两个网站通过黑客手段在其主页上添加了“点赞”和“转发”按钮。
这似乎是最好的参考: http://cicerontheme.tumblr.com/
不知何故,他们设法获取转发 URL,如何获取,我不知道。我一直在翻阅他们的代码,我发现的只是类似按钮:
$('a.likeLink').click(function() {
var post = $(this).closest('.post');
var id = post.attr('id');
var oath = post.attr('rel').slice(-8);
var like = 'http://www.tumblr.com/like/'+oath+'?id='+id;
$('#likeit').attr('src', like);
});
这个堆栈溢出讨论但同样,没有触及问题的关键,到底如何获得转发网址。
我已经浏览了脚本资源,但没有找到任何个人脚本,只有来自 tumblr 的脚本、我的 chrome 扩展等。他们从哪里得到它?
在上面粘贴的“like”代码中,他们很容易获得帖子 ID,您只需使用 Tumblrs {Permalink},但转发 URL 是从 rel 属性中获取的。
希望有人可以帮忙!
谢谢。
I've seen two sites in the wild which manage to get Like and Reblog buttons on their homepages via hacks.
This seems to be the best one to reference: http://cicerontheme.tumblr.com/
Somehow, they manage to get the reblog URL, how, i have no idea. I've been rummaging through their code and all I find is this for the like button:
$('a.likeLink').click(function() {
var post = $(this).closest('.post');
var id = post.attr('id');
var oath = post.attr('rel').slice(-8);
var like = 'http://www.tumblr.com/like/'+oath+'?id='+id;
$('#likeit').attr('src', like);
});
It's discussed a little in this Stack overflow discussion but again, does not get to the crux of the matter, how the heck to get the reblog url.
I've gone through the script resources and havent found any personal scripts, just scripts from tumblr, my chrome extensions, etc. Where are they getting it from?!
In the "like" code pasted above, they get the post ID easily enough, you just have to use Tumblrs {Permalink}, but the reblog url is taken from the rel attribute.
Hoping someone can help!
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看源代码:http://cicerontheme.tumblr.com/
代码说明:
likeLink
的锚点的处理程序.closest
方法查找具有类post
的最近元素(实际上,它是一个锚点,参见来源)ID
属性的十位 tumblr ID(使用.attr('id')
rel
属性,并使用.slice(-8)
获取最后 8 个字符的
src
属性likeit
(参见源)。这会导致请求http://www.tumblr.com/like/....
。View the Source code at: http://cicerontheme.tumblr.com/
Explanation of the code:
likeLink
.closest
method to find the closest element with classpost
(which, in fact, is an anchor, see source)ID
attribute of the anchor (using.attr('id')
rel
attribute of the anchor, and use.slice(-8)
to get the last 8 characterssrc
attribute of the<iframe>
with IDlikeit
(see source). This causes a request tohttp://www.tumblr.com/like/....
. Hack?很确定这不是 JS 的事情 - 当您查看链接的网站的源代码时,转发链接已经存在(这意味着,它们不是动态插入的)。
我认为 Ciceron 主题实际上正在生成转发链接 - 您是否尝试过添加:
...到您的主题?
Pretty sure this isn't a JS thing — when you view the source of the site you linked, the reblog links are already there (meaning, they aren't being dynamically inserted).
I think the the Ciceron theme is actually generating reblog links - have you tried adding:
...to your theme?
在您的 tumblr 仪表板上,每个帖子都有一个“转发”图标。如果您单击此按钮,该帖子的转发网址肯定会出现在地址栏中吗?当然,这意味着为每个帖子手动添加 url,但这是我找到的默认 tumblr 控件的唯一替代方案。
“关注”和“仪表板”是标准的 a href 命令,但我仍在寻找一种为“喜欢”功能提供简单文本链接的方法,以便我可以完全取消默认控件。
From your tumblr dashboard, each post has a 'reblog' icon. Surely if you click this, that post's reblog url will appear in the addres bar? Of course, this means adding the url manually for each post, but it's the only alternative I've found to the default tumblr controls.
'Follow' and 'Dashboard' are bog standard a href commands, but I'm still looking for a way to have a simple text link for the 'like' functionality, so that I can do away with the default controls altogether.
使用“转发密钥”受到 Tumblr 的认可,并鼓励在某些开发人员情况下使用,就像您提到的那样。
Tumblr 有一个API 和内部主题开发选项来利用转发键。这是一个巧妙的技巧,但需要明确的是,它不是黑客,因为 Tumblr 确实有意、鼓励并希望这个工具被使用并为每个人提供帮助。
请参阅有关“转发密钥”帖子用法的具体 API 文章:
https://www.tumblr.com/docs/en/api/v2#reblogging
当您使用 Tumblr API 以编程方式发布到您的 Tumblr 博客时,您会收到带有“转发密钥”的响应。您可以创建一个脚本来显示您自己的 tumblr 帖子的转发网址,而不是用于创建新帖子的共享按钮。这可以帮助您在 tumblr 上本地化到您自己的来源,并为 SEO 发送更好的“规范链接”功能。
在 Tumblr 内部主题中,您可以使用{ReblogURL} 显示转发网址,或创建一个“赞”按钮。
您可以通过多种方式正确使用它,但也有很多不允许的方式,即使这是您“可以”做的简单或明显的事情。最重要的是,善待其他用户,不要做其他用户不喜欢的事情(隐藏点击等)。
您可以在此处了解 Tumblr 服务条款:
https://www.tumblr.com/policy/en/terms-of-service
我提到了 API,它有自己的一小部分规则,它链接在服务条款中。您可以阅读Tumblr 应用程序开发人员和 API 许可协议:
https://www.tumblr.com/docs/api_agreement
The use of the "reblog key" is sanctioned by Tumblr, and encouraged in some developer situations just like the ones that you have mentioned.
Tumblr has an API and Internal Theme Development Options to utilitze the reblog key. It's a neat trick, but to be clear it's not a hack, as Tumblr does intend, encourage, and hope that this tool is used and helpful for everyone.
See the specific API article on "reblog key" post usage:
https://www.tumblr.com/docs/en/api/v2#reblogging
When you use the Tumblr API to post programmatically to your Tumblr blog, you are given a response with the "reblog key". You can create a script that could display a reblog url of your own tumblr post, instead of a share button that would create a new post. This could help you localize on tumblr to your own source, and send better "Canonical Link" power for SEO.
In themes internal to Tumblr, you could use {ReblogURL} to display the reblog url, or create a like button.
There are potentially a lot of ways you can use this properly, but there are also a lot of ways that are not allowed, even if it's and easy or obvious thing you "could" to do. Most of all, be nice to other users and don't do something other users wouldn't like (hidden clicks, etc).
You can make yourself aware of Tumblr Terms of Service here:
https://www.tumblr.com/policy/en/terms-of-service
I mentioned the API which has it's own little section of rules, it's linked within the Terms of Service. You can read the Tumblr Application Developer and API License Agreement:
https://www.tumblr.com/docs/api_agreement