Code Monkey home page Code Monkey logo

responsive_mockups's Introduction

Responsive Mockups via PhantomJS 2.0

Small PhantomJS based script that allows you to automatically create mockup graphics, providing only a URL.

mockup 1 mockup 2 mockup 3

How To

  • Clone this repo
  • Edit example.js to choose mockup template and target url
  • Call phantomjs example.js (for an example with a single URL)
  • Or call phantomjs example-mobile-multiple.js (for an example with multiple URLs)

Requirements

The only external requirement is PhantomJS in version >= 2.0.0.

brew install phantomjs

Double check the version of PhantomJS

phantomjs -v

Known issues with SSL

PhantomJS seems to have problems with some SSL certficates. In case you get errors like Unable to load the address for layer [...] - you can get a more verbose output by running PhantomJS in debug mode, e.g. phantomjs --debug=true example.js.

If the output says something like SSL Error: "The issuer certificate of a locally looked up certificate could not be found", but you still want to take screenshots via HTTPS, you can deactivate SSL checks using phantomjs --ignore-ssl-errors=true example.js.

Please be aware that this disables SSL certificate validations, so don't pass credentials or other data to the script that would require a verified secure connection.

Credits for provided mockup templates

At the moment this script includes two mockup templates of pixeden.com:

The awesome people at pixeden.com gave me permission to even include the PSD files so you can tweak the mockups to fit your needs. ❤️

How can I customize the templates?

For now, mockups are based on two files: a PSD (that's the graphical template) and a metadata.js JavaScript file that contains information which resolutions to take for the screenshots and where to place them in the mockup. Based on the PSD, there are also exported "layers" that will be used to render the mockup.

Just have a look at the templates in the /templates folder, the information in the metadata.js file will map to the pixel coordinates in the PSD.

If you move or scale a device in the PSD template, you have to update the pixel coordinates in the metadata.js file and you will have to export the layers (mobile.png, tablet.png, desktop.png) again.

Additionally, keep in mind that the resulting image is just another screenshot of a html page with a canvas tag. This minimal html file is called render.html and is also contained in every template folder. So you can not only affect the appearance by modifying the PSD, you can also customize the render.html page, e.g. by HTML, CSS or even additional stuff you draw on the canvas with JS.

responsive_mockups's People

Contributors

dinuks avatar fabrik42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

responsive_mockups's Issues

Webfont support?

Hi again,

after doing some 20 minute google research earlier there seems to be no support in PhantomJS 2.0 for webfonts (in my case, I use typekit for virtually all my projects). This seems to be quite the showstopper for responsive_mockups - but mabye I am overlooking something?

best wishes
Chris

how I do put this code?

hi I have googling how to handle transparent background on phantomjs and found this one but still don't know where I put this code on responsive mockups

page.evaluate(function(){
document.body.bgColor='white';
});

Transparency

Hi Christian,

thank you for this neat script, I'm planning to use it to create all mockups for my new website but I've ran into an issue: When there is no background-color on certain elements, phantomjs correctly renders them with transparency. This causes a problem however with responsive_mockups as there is stuff in the template files already. I was able to fix this by having a white background inside each device in these files (which I think is a safe assumption to make).

I'll submit a pull request on this when I get to it...

responsive_mockups should wait for the page to be actually loaded before taking a screenshot

In order to generate any kind of output I had to increase the setTimeout in the index.js to around 5 seconds. While my websites most certainly don't need 5 seconds to fully load, I believe this has something to do with typekits preferred way of prevents FOUCs - by having the page fade in only after all webfonts have loaded. Maybe some config option for such cases might help here; it doesn't seem to be struggling with images, even larger ones.

Thanks gain for your work with this script, Christian! I'm really looking forward to putting it to good use.

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.