Skip to content

Commit fc2112c

Browse files
committed
Meta stuff. Mostly readme + build script changes.
1 parent 0f97eb2 commit fc2112c

File tree

5 files changed

+240
-29
lines changed

5 files changed

+240
-29
lines changed

CONTRIBUTING.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Contribution Guide
2+
3+
Please take a moment to review this document in order to make the contribution
4+
process easy and effective for everyone involved.
5+
6+
Following these guidelines helps to communicate that you respect the time of
7+
the developers managing and developing this open source project. In return,
8+
they should reciprocate that respect in addressing your issue or assessing
9+
patches and features.
10+
11+
12+
## Using the issue tracker
13+
14+
The issue tracker is the preferred channel for [bug reports](#bugs),
15+
[features requests](#features) and [submitting pull
16+
requests](#pull-requests), but please respect the following restrictions:
17+
18+
* Please **do not** use the issue tracker for personal support requests (use
19+
[Stack Overflow](http://stackoverflow.com) or IRC).
20+
21+
* Please **do not** derail or troll issues. Keep the discussion on topic and
22+
respect the opinions of others.
23+
24+
25+
<a name="bugs"></a>
26+
## Bug reports
27+
28+
A bug is a _demonstrable problem_ that is caused by the code in the repository.
29+
Good bug reports are extremely helpful - thank you!
30+
31+
Guidelines for bug reports:
32+
33+
1. **Use the GitHub issue search** &mdash; check if the issue has already been
34+
reported.
35+
36+
2. **Check if the issue has been fixed** &mdash; try to reproduce it using the
37+
latest `master` or development branch in the repository.
38+
39+
3. **Isolate the problem** &mdash; create a [reduced test
40+
case](http://css-tricks.com/6263-reduced-test-cases/) and a live example.
41+
42+
A good bug report shouldn't leave others needing to chase you up for more
43+
information. Please try to be as detailed as possible in your report. What is
44+
your environment? What steps will reproduce the issue? What browser(s) and OS
45+
experience the problem? What would you expect to be the outcome? All these
46+
details will help people to fix any potential bugs.
47+
48+
Example:
49+
50+
> Short and descriptive example bug report title
51+
>
52+
> A summary of the issue and the browser/OS environment in which it occurs. If
53+
> suitable, include the steps required to reproduce the bug.
54+
>
55+
> 1. This is the first step
56+
> 2. This is the second step
57+
> 3. Further steps, etc.
58+
>
59+
> `<url>` - a link to the reduced test case
60+
>
61+
> Any other information you want to share that is relevant to the issue being
62+
> reported. This might include the lines of code that you have identified as
63+
> causing the bug, and potential solutions (and your opinions on their
64+
> merits).
65+
66+
67+
<a name="features"></a>
68+
## Feature requests
69+
70+
Feature requests are welcome. But take a moment to find out whether your idea
71+
fits with the scope and aims of the project. It's up to *you* to make a strong
72+
case to convince the project's developers of the merits of this feature. Please
73+
provide as much detail and context as possible.
74+
75+
76+
<a name="pull-requests"></a>
77+
## Pull requests
78+
79+
Good pull requests - patches, improvements, new features - are a fantastic
80+
help. They should remain focused in scope and avoid containing unrelated
81+
commits.
82+
83+
**Please ask first** before embarking on any significant pull request (e.g.
84+
implementing features, refactoring code, porting to a different language),
85+
otherwise you risk spending a lot of time working on something that the
86+
project's developers might not want to merge into the project.
87+
88+
Please adhere to the coding conventions used throughout a project (indentation,
89+
accurate comments, etc.) and any other requirements (such as test coverage).
90+
91+
Follow this process if you'd like your work considered for inclusion in the
92+
project:
93+
94+
1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
95+
and configure the remotes:
96+
97+
```bash
98+
# Clone your fork of the repo into the current directory
99+
git clone git@github.com:<YOUR_USERNAME>/luminous.git
100+
# Navigate to the newly cloned directory
101+
cd luminous
102+
# Assign the original repo to a remote called "upstream"
103+
git remote add upstream https://github.com/imgix/luminous
104+
```
105+
106+
2. If you cloned a while ago, get the latest changes from upstream:
107+
108+
```bash
109+
git checkout <dev-branch>
110+
git pull upstream <dev-branch>
111+
```
112+
113+
3. Create a new topic branch (off the main project development branch) to
114+
contain your feature, change, or fix:
115+
116+
```bash
117+
git checkout -b <topic-branch-name>
118+
```
119+
120+
4. Commit your changes in logical chunks. Please adhere to these [git commit
121+
message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
122+
or your code is unlikely be merged into the main project. Use Git's
123+
[interactive rebase](https://help.github.com/articles/interactive-rebase)
124+
feature to tidy up your commits before making them public.
125+
126+
5. Locally merge (or rebase) the upstream development branch into your topic branch:
127+
128+
```bash
129+
git pull [--rebase] upstream <dev-branch>
130+
```
131+
132+
6. Push your topic branch up to your fork:
133+
134+
```bash
135+
git push origin <topic-branch-name>
136+
```
137+
138+
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
139+
with a clear title and description.
140+
141+
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
142+
license your work under the same license as that used by the project.
143+
144+
145+
<a name="developing"></a>
146+
### Developing
147+
148+
1. `npm install`
149+
2. Write code (change files under `./src`, **not** `./dist`)
150+
3. Write tests
151+
4. `npm run build && npm test`
152+
5. Repeat steps 2-4 as necessary

LICENSE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2016 Zebrafish Labs
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice,
8+
this list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,65 @@
1-
# imgix.js
1+
![imgix logo](https://assets.imgix.net/imgix-logo-web-2014.pdf?page=2&fm=png&w=120)
22

3-
## Resources
3+
# imgix.js [![Build Status](https://travis-ci.org/imgix/imgix.js.svg?branch=master)](https://travis-ci.org/imgix/imgix.js) [![Slack Status](http://slack.imgix.com/badge.svg)](http://slack.imgix.com)
4+
5+
Responsive images in the browser, simplified. Pure JavaScript with zero dependencies. About 2 KB minified and gzipped.
6+
7+
* [Overview / Resources](#overview-and-resources)
8+
* [Installation](#installation)
9+
* [Usage](#usage)
10+
* [`ix-src`](#ix-src)
11+
* [`ix-path` and `ix-params`](#ix-path-and-ix-params)
12+
* [`picture` tags](#picture-tags)
13+
* [Browser Support](#browser-support)
14+
* [Development / Meta](#development-and-meta)
15+
16+
17+
<a name="overview-and-resources"></a>
18+
## Overview / Resources
419

520
* [Srcset and sizes by Eric Portis](https://ericportis.com/posts/2014/srcset-sizes/). A seminal article on `srcset`, `sizes`, and `picture`. Explains why they're necessary, and how they work together.
621
* [Using imgix with `<picture>`](https://docs.imgix.com/tutorials/using-imgix-picture-element). Discusses the differences between art direction and resolution switching, and provides examples of how to accomplish art direction with imgix.
722
* [Responsive Images with `srcset` and imgix](https://docs.imgix.com/tutorials/responsive-images-srcset-imgix). A look into how imgix can work with `srcset` and `sizes` to serve the right image.
823

924

10-
## Installation & Usage
25+
<a name="installation"></a>
26+
## Installation
1127

1228
There are several ways to install imgix.js. The appropriate method depends on your project.
1329

14-
1. `npm install --save imgix.js`
15-
2. `bower install --save imgix.js`
16-
3. [Download the latest release of imgix.js](https://github.com/imgix/imgix.js/releases/latest), and extract `dist/imgix.js` or `dist/imgix.min.js` to your project.
30+
1. **npm**: `npm install --save imgix.js`
31+
2. **Bower**: `bower install --save imgix.js`
32+
3. **Manual**: [Download the latest release of imgix.js](https://github.com/imgix/imgix.js/releases/latest), and use `dist/imgix.js` or `dist/imgix.min.js`.
1733

18-
After you've included imgix.js on your page, you just have to run it (you'll probably want to put this at the bottom of your page, just before the `</body>` tag):
34+
After you've included imgix.js on your page, you just have to run it (you'll probably want to put this at the bottom of your page, just before the `</body>` tag). This code will scan the page for `img` and `source` tags that need to be processed, and initialize them:
1935

2036
``` html
2137
<script src="imgix.js"></script>
2238
<script>
39+
// Specify your imgix host. For these docs, we'll use `assets.imgix.net`.
40+
imgix.config.host = 'assets.imgix.net';
41+
// Find and initialize all uninitialized `img` or `source` tags with
42+
// `ix-src` or `ix-path` attributes.
2343
imgix.init();
2444
</script>
2545
```
2646

27-
Now that everything's set, you can start creating responsive images. There are a few ways to do this. First of all, you can use an `img` tag with the `ix-src` attribute:
47+
By setting the `imgix.config.host` value to your imgix hostname, you enable the use of `ix-path` and `ix-params` to define images, instead of having to manually type URLs out in `imgix-src`. This has several advantages:
48+
49+
1. `ix-params` automatically URL/Base64 encodes your specified params, as appropriate.
50+
2. `ix-params` is a JSON string, which is easier to read than a URL, and can be generated by other tools if necessary.
51+
3. Not having to re-type `https://my-source.imgix.net` helps keep your code DRY.
52+
53+
54+
<a name="usage"></a>
55+
## Usage
56+
57+
Now that everything's installed and set up, you can start adding responsive images to the page. There are a few ways to do this.
58+
59+
<a name="ix-src"></a>
60+
### `ix-src`
61+
62+
The simplest way to use imgix.js is to create an `img` tag with the `ix-src` attribute:
2863

2964
``` html
3065
<img
@@ -53,23 +88,11 @@ This will generate HTML something like the following:
5388

5489
Since imgix can generate as many derivitive resolutions as needed, imgix.js calculates them programmatically, using the dimensions you specify (note that the `w` and `h` params scale appropriately to maintain the correct aspect ratio). All of this information has been placed into the `srcset` and `sizes` attributes. Because of this, imgix.js no longer needs to watch or change the `img` tag, as all responsiveness will be handled automatically by the browser.
5590

56-
If you set the `imgix.config.host` value to your imgix hostname, you can use `ix-path` and `ix-params` to define images, instead of having to manually type URLs out in `imgix-src`. This has several advantages:
5791

58-
1. `ix-params` automatically URL/Base64 encodes your specified params, as appropriate.
59-
2. `ix-params` is a JSON string, which is easier to read than a URL, and can be generated by other tools if necessary.
60-
3. Not having to re-type `https://my-source.imgix.net` helps keep your code DRY.
61-
62-
Here's an example of how to set that up:
63-
64-
``` html
65-
<script src="imgix.js"></script>
66-
<script>
67-
imgix.config.host = 'assets.imgix.net';
68-
imgix.init();
69-
</script>
70-
```
92+
<a name="ix-path-and-ix-params"></a>
93+
### `ix-path` and `ix-params`
7194

72-
And here's how the previous example would be written out using `ix-path` and `ix-params` instead of `ix-src`:
95+
Here's how the previous example would be written out using `ix-path` and `ix-params` instead of `ix-src`. Regardless of which method you choose, the end result in-browser will be the same.
7396

7497
``` html
7598
<img ix-path="unsplash/hotairballoon.jpg" ix-params='{
@@ -80,18 +103,28 @@ And here's how the previous example would be written out using `ix-path` and `ix
80103
}' alt="A hot air balloon on a sunny day">
81104
```
82105

83-
Regardless of which method you choose, the end result in-browser will be the same.
106+
<a name="picture-tags"></a>
107+
### `picture` tags
84108

109+
If you need art directed images, imgix.js plays nicely with the `picture` tag. This allows you to specify more advanced responsive images, by changing things such as the crop and aspect ratio for different screens.
85110

86-
### Browser Compatibility Notes
111+
TODO
112+
113+
114+
<a name="browser-support"></a>
115+
### Browser Support
87116

88117
* If you are using [Base64 variant params](https://docs.imgix.com/apis/url#base64-variants) and need IE <= 9 support, we recommend using a polyfill for `atob`/`btoa`, such as [Base64.js](https://github.com/davidchambers/Base64.js).
89118
* By default, browsers that don't support [`srcset`](http://caniuse.com/#feat=srcset), [`sizes`](http://caniuse.com/#feat=srcset), or [`picture`](http://caniuse.com/#feat=picture) will gracefully fall back to the default `img` `src` when appropriate. If you want these browsers to display responsive images in these cases instead, we recommend using [Picturefill](https://github.com/scottjehl/picturefill).
90119

120+
<a name="development-and-meta"></a>
121+
## Development / Meta
122+
123+
Drift was made by [imgix](http://imgix.com). It's licensed under the BSD 2-Clause license (see the [license file](https://github.com/imgix/imgix.js/blob/master/LICENSE.md) for more info). Any contribution is absolutely welcome, but please review the [contribution guidelines](https://github.com/imgix/imgix.js/blob/master/CONTRIBUTING.md) before getting started.
91124

92-
## Development
125+
Here's a quick intro to getting started with development on imgix.js:
93126

94127
1. `npm install`
95128
2. Write code
96129
3. `npm run build && npm test`
97-
4. Repeat #2 and #3 as necessary
130+
4. Repeat steps 2 and 3 as necessary

dist/imgix.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"scripts": {
1010
"test": "./node_modules/jasmine/bin/jasmine.js",
11-
"build": "mkdir -p dist && browserify ./src/imgix.js > ./dist/imgix.js"
11+
"build": "mkdir -p dist && ./node_modules/browserify/bin/cmd.js ./src/imgix.js > ./dist/imgix.js && ./node_modules/uglify-js/bin/uglifyjs ./dist/imgix.js --mangle > ./dist/imgix.min.js"
1212
},
1313
"repository": {
1414
"type": "git",
@@ -26,6 +26,7 @@
2626
"gulp": "^3.9.1",
2727
"gulp-rename": "^1.2.2",
2828
"gulp-uglify": "^1.5.3",
29-
"jasmine": "^2.4.1"
29+
"jasmine": "^2.4.1",
30+
"uglify-js": "^2.6.2"
3031
}
3132
}

0 commit comments

Comments
 (0)