Let's set up a mirror
We'll need to do the following things:
- install nodejs if you haven't already, from nodejs.org
- download flickrmirror and unzip it. It will make a directory called "flickrmirror-master" when you unpack it, so don't make a new dir called "flickrmirror" and then unpack it in that =)
- have a Flickr API key and secret. If you don't have these, a non-commercial API key is free over at Flickr's API page.
If you have (done) all these things, we can get started setting up a flickr mirror.
make sure all the dependencies are installed
$:flickrmirror-master> npm install
set up an .env file
$:flickrmirror-master> copy env.dist .env
first-time run
$:flickrmirror-master> node app
This will guide you through the first-time user registration process. Fill in your human-readable username, an email adress that you use for Persona (if you use one) or otherwise just a valid email address that you use, and your Flickr API key and secret. You also get to choose the level of permission the Flickr Mirror will have: read only, read and write, or read-write-delete permissions. After filling these in, you will be prompted to open a URL in your browser so that you can authorise the app with your chosen permissions. Copy the authentication code over to the installer, and it should add your user information as first user, then run the Flickr Mirror.
Of course, it won't have anything to show yet, so shut it down using ctrl-c, and then perform a downsync step:
first-time downsyncing
$:flickrmirror-master> node app --downsync
The downsync process will grab all the methods that Flickr exposes, first, after which
it will start to download all your Flickr data. While it is doing so, it's a good idea to
copy-paste those three export variables into your .env
file.
Sit back: all your stuff is downloading to your own drive for you do do with as you please.
updating to your latest data on Flickr
Simply rerun the --downsync
process to have FlickrMirror download all the new
stuff you put on Flickr since the last time you downsynced.
$:flickrmirror-master> node app --downsync
updating from a previous version
Download the latest version of flickrmirror and unpack it to the same place, telling your unpacker to overwrite all older files. Then in the flickrmirror dir, update the dependencies:
$:flickrmirror-master> npm update
You will NOT have to update your .env
file, just leave that the way it was.
Also? done. That's all you need to do to update to the latest version.
Updating from 0.1.x to 0.2.x
The codebase was significantly changed between versions 1 and 2, so if you
are upgrading from 1 to 2, you will have to set up a new user according to
the new user registration system, and you will need to recopy the env.dist
file to .env
file.
Let's serve that mirror up!
locally hosting your mirror
$:flickrmirror-master> node app
Open a browser and point it to http://localhost:3000 and presto. Your own mirror of your own Flickr data.
hosting your mirror "for reals"
You have a choice of hosting services that let you run node.js, but most are a bit more effort than you might like. I went with Digital Ocean, because unlike most places they have a $5 a month plan, which offers more than I need for my mirror for $60 a year, with the best way to interact with your files: ssh
Let's pretend you've found your ideal host, letting you run your own processes for cheaps, and you have ssh access to your box. These are the steps required to set up your flickr mirror remotely:
- if not already installed, install nodejs/npm using the OS's package manager
- if not already installed, install git using the OS's package manager
With those dependencies fulfilled, clone the flickrmirror repo, install its npm
dependencies, set up your .env
and start downsyncing:
$> git clone https://github.com/Pomax/flickrmirror.git $> cd flickrmirror $> npm install
If you want to use the same .env
that you used locally, copy your local
.env
file over using whatever means your host lets you use (scp, winscp, a web
console, what have you). make sure it ends up in the flickrmirror
directory!
After that, start your downsync process:
$> node app --downsync
if this runs slowly, the downsync process can be run multiple times concurrently, so if you're using an ssh client, simply spawn five of them and run this five times simultaneously.
once this is done, you can start your mirror using node app
, done!
Of course, the level of "done"ness depends on your hosting. With digital ocean all
I have to do is make sure the PORT
in my .env
is set to 80,
and running node app
through a screen session. Depending on the host you
go with, your mileage may vary.
The default look
The default style is similar to the "old style" Flickr. It uses the "photostream + collections" view, mostly because that's what I was using.
The initial view
When viewing a collection
When viewing a set
When viewing individual photos
When clicking through to the lightbox version
Changing the look and feel
This app uses nunjucks for templating, and stylus for less verbose, arguably easier to write stylesheets. The main things of importance are:
./routes/index.js
and the route section in ./app.js
. These
set up the routes that the app knows how to take. The parameters
section
in ./routes/index.js
lets you add magical variables-from-a-URL functionality
so you can add in your own custom route variables.
./views
houses all the templates. The main template is layout.html
,
and the rest kind of extends it with their own body blocks.
Just open up layout.html
and index.html
to get a sense of how
stuff works together. All the templating variables come from the res.render
calls
that you can see in the ./routes/index.js
file.
./public/stylesheets
has some .styl
files in it. You don't have
to use stylus files, you can use plain CSS, too. You'll be pointing to .css
files
in your html files anyway: stylus converts the .styl
files to .css
files when you run the server.
help, help, I'm stuck on this
Drop me a line. If you're using FlickrMirror, I'll be interested in finding out what works for you, and making it easy for you to do that thing.
What's left to do?
in-browser install
There are no technical reasons not to do the authorisation/mirror process through the browser. The modules are all there, it's just a matter of having the time to implement a nicer experience vs. spending that same time on improving the functionality
more data
No videos at the moment
social?
No "contacts" or "favourites" at the moment, so if you want to link through to your friends and family's real flickr pages, or other people's stuff (which flickrmirror won't download) from your mirror, you can't do that right now.
This is amazing, how can I help out?
file bugs
Seriously. Use it, find bugs or incompletions, file them over at the github repo please. They help.
submit pull requests
100% welcome. If you think have the chops to whip up a patch for something that's not in it right now, submit a pull request, and I'll review it, and hopefully merge it in.