Tumblr — getting the 8 digit reblog code on home page (nearly there…)

旧巷老猫 提交于 2019-12-04 21:43:48

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:

<a href="{ReblogURL}">Reblog</a> 

...to your theme?

View the Source code at: http://cicerontheme.tumblr.com/

1. $('a.likeLink').click(function() {
2.     var post = $(this).closest('.post');
3.     var id = post.attr('id');
4.    var oath = post.attr('rel').slice(-8);
5.    var like = 'http://www.tumblr.com/like/'+oath+'?id='+id;
6.    $('#likeit').attr('src', like);
7. });

Explanation of the code:

  1. Add an event handler to the anchor with class likeLink
  2. Uses the JQuery .closest method to find the closest element with class post (which, in fact, is an anchor, see source)
  3. Get the ten-digit tumblr ID from the ID attribute of the anchor (using .attr('id')
  4. Get the rel attribute of the anchor, and use .slice(-8) to get the last 8 characters
  5. Create link
  6. Set the src attribute of the <iframe> with ID likeit (see source). This causes a request to http://www.tumblr.com/like/..... Hack?

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!