Giter VIP home page Giter VIP logo

tumblrplate's Introduction

tumblrplate

A boilerplate template for easy creation of Tumblr themes

tumblrplate owes an obvious, significant debt to HTML5 Boilerplate, and it heavily lifts from normalize.css as well. Proper in-project attribution with source links will follow once the structure starts making sense.

##Notable exclusions

The tumblrplate at first appears like it's neglecting some critical code. The unique nature of the Tumblr ecosystem and infrastructure adds some wrinkles to typical front-end coding.

###Doctype

Tumblr automatically slaps <!DOCTYPE html> at the start of every page served, whether you specified one or not. This seems to be a security thing; it also prepends the text for its anti-phishing warning immediately afterward, in order to load it as soon as possible.

As such, specifying a doctype in your Tumblr theme is a waste of bytes. Notably, the official Optica theme is guilty of this, so it's possible I'm missing something.

###Charset encoding

Tumblr already specifies UTF-8 in its server headers, which always trump a meta specification. This tumblr-wide standard is presumably for XSS prevention and to protect against any malformed charsets.

Optica also specifies UTF-8 again in its meta tags, so I wonder if they know something I don't.

###X-UA-Compatible

Similarly, Tumblr's server headers specify IE=Edge and Chrome=1 automatically.

##Notable changes

Tumblr refrains from injecting some code if it sees you already have it.

###Open Graph tags

Tumblr's automatic OG tags promote Tumblr itself, especially its apps. Nothing wrong with that, but having them promote your users' blogs is a selling point if I ever heard one.

It's possible to mostly disable them by specifying empty OG Name & URL tags, but that ends up being spectacularly nonfunctional.

###Twitter Cards

Same deal as Open Graph. Psuedo-disabling them isn't quite as worrisome as that, since Twitter is known to fall back on OG tags. However, I'm not sure if malformed Twitter tags prevent that fallback. To be safe, the same blog-central treatment is used.

##Notable additions

Of course, 5 tweaks does not a boilerplate make. Here's what tumblrplate proposes as a good standard:

### lang attribute

Using Tumblr's language selection blocks, tumblrplate will automatically insert the correct language code into your pages' language attribute. Given how confusing looking up language codes is, this one is best left up to the Tumblr system and the selection of languages it supports.

###DNS Prefetch

By default, Tumblr inserts a DNS prefetch meta tag explicitly disallowing it. My guess is that this prevents browsers from prefetching what they assume are different subdomains, but in actuality are just long reblog chains of conversations between tumblr users with the same IP.

However, the disallow tag only turns off the default behavior of prefetching arbitrary links on the page, so if we want to specifically target some URLs, we can. I've added secure.asssets.tumblr.com and static.tumblr.com; both near-universal subdomains for Tumblr blogs, as they host the images, fonts, scripts, and other files that make up Tumblr themes and infrastructure. assets.tumblr.com is not included, as tumblr automatically serves a script hosted there as the first thing on any blog page.

==========

Of course, more to come.

tumblrplate's People

Contributors

tigt avatar

Stargazers

Kam Black avatar

Watchers

James Cloos avatar  avatar

tumblrplate's Issues

<html> lang attribute conflict with inserted Tumblr code

Tumblr prepends the following code to all served pages:

<!DOCTYPE html>
<script>var __pbpa = true;</script><script>var translated_warning_string = 'Warning: Never enter your Tumblr password unless \u201chttps://www.tumblr.com/login\u201d\x0ais the address in your web browser.\x0a\x0aYou should also see a green \u201cTumblr, Inc.\u201d identification in the address bar.\x0a\x0aSpammers and other bad guys use fake forms to steal passwords.\x0a\x0aTumblr will never ask you to log in from a user\u2019s blog.\x0a\x0aAre you absolutely sure you want to continue?';</script><script type="text/javascript" language="javascript" src="http://assets.tumblr.com/assets/scripts/pre_tumblelog.js?_v=a3e5e7f1b487e101133066aadcff3cde"></script>

...Before the <html> tag. I've heard browsers deal with code like this by sighing and constructing a set of "phantom" <html> and <head> tags. Clearly it's not too much of a problem, as Tumblr has been serving pages forever, but I'm concerned that the software and APIs that rely on the lang attribute may get tripped up on this.

Possible options include stuffing the language in a <meta>, which seems like it could work while flouting validation. (Of course, the inserted script automatically screws that up anyway.) I only worry about its deprecation.

Using the DOM inspector in Chrome & Firefox doesn't show anything too amiss... but am I missing something?

Tumblr image sizes/Apple touch icon sizes Mismatch

Tumblr's avatars are output in 128x128 and 512x512 pixels, if uploaded at those sizes or higher. (There are smaller versions, but they're irrelevant here.)

The new hi-res iPads ask for 152x152 pixels. 512 may be an anagram, but it's way too large for this purpose; I wouldn't be surprised if the iPad just rejected it. But does it allow the 128px version either? Furthermore, not everyone has a 512px avatar: Tumblr only autoscales them up to 128.

There isn't a version found at the blog's root, either. This sounds like a silly supposition of mine, but seeing as tumblr stuffs robots.txt, a favicon.ico fallback, sitemap.xml/sitemap1.xml/sitemap-pages.xml, rss.xml, podcast.xml, and crossdomain.xml all in each blog's root, I figured it was worth a shot.

I'll have to test after I find someone with a newer iPad.

While I'm at it, I wonder if I can specify a startup image. Probably a question for a mobile version of the tumblrplate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.