Skip to content

Commit

Permalink
Final prep for v5 launch (Kong#128)
Browse files Browse the repository at this point in the history
* Version number and changelog scroll

* Fixed CodeMirror tooltip css

* AUtocomplete dropdown styling

* Docker Ubuntu build and some tweaks

* Fix SSL verificatioN

* Don't show SSL data

* Update README

* Fixed URL paste handler

* Import from curl improvements

* Minor things
  • Loading branch information
gschier authored Apr 4, 2017
1 parent 253cdfe commit 10564b5
Show file tree
Hide file tree
Showing 24 changed files with 226 additions and 97 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
build
dist
coverage
81 changes: 81 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributing to this project

Please take a moment to review this document in order to make the contribution
process easy and effective for everyone involved.

## Using the issue tracker

The [issue tracker](/issues) is the preferred channel for [bug reports](#bug-reports),
[features requests](#feature-requests) and [submitting pull requests](#pull-requests).

Please respect the following restrictions:

- Please **do not** use the issue tracker for personal support requests (email
[[email protected]](mailto:[email protected])).

- Please **do not** derail or troll issues. Keep the discussion on topic and
respect the opinions of others.

## Bug Reports

A bug is a _demonstrable problem_ that is caused by the code in the repository.
Good bug reports are extremely helpful - thank you!

Guidelines for bug reports:

1. **Use the GitHub issue search** — check if the issue has already been
reported.

2. **Check if the issue has been fixed** — try to reproduce it using the
latest `master` or development branch in the repository.

3. **Demonstrate the problem** — provide clear steps that can be reproduced.

A good bug report should not leave others needing to chase you up for more
information. Please try to be as detailed as possible in your report. What is
your environment? What steps will reproduce the issue? What OS experienced the
problem? What would you expect to be the outcome? All these details will help
to fix any potential bugs.

## Feature Requests

Feature requests are welcome. But take a moment to find out whether your idea
fits with the scope and aims of the project. It's up to *you* to make a strong
case to convince the project's developers of the merits of this feature. Please
provide as much detail and context as possible.

## Pull Requests

Good pull requests (patches, improvements, new features) are a fantastic
help. They should remain focused in scope and avoid containing unrelated
commits.

**Please ask first** before embarking on any significant pull request (e.g.
implementing features, refactoring code, porting to a different language),
otherwise you risk spending a lot of time working on something that might
not get accepted into the project.

**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
license your work under the same license as that used by the project.

## Development Overview and Setup

```bash
# Install and use correct Node version
nvm install

# Actually use correct version
nvm use

# Install dependencies
npm install
```

When you run the development environment, it will start both a dev server and an Electron
instance. The dev server is part of Webpack and is used to control hot module replacement
of UI components. This means that, if you change a component file, you will not need to
refresh the app to see the change. It will inject the new component immediately.

```bash
npm run dev
```
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:14.04

RUN mkdir -p /insomnia
WORKDIR /insomnia
COPY . /insomnia

RUN sudo apt-get update

RUN sudo apt-get install -y \
curl libcurl4-openssl-dev build-essential \
git-all icnsutils graphicsmagick xz-utils

RUN curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - && sudo apt-get install -y nodejs
42 changes: 19 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
# Insomnia REST Client [![Build Status](https://travis-ci.com/getinsomnia/app.svg?branch=master)](https://travis-ci.com/getinsomnia/app) [![Build status](https://ci.appveyor.com/api/projects/status/7b5a82uxbidpnkoa/branch/master?svg=true)](https://ci.appveyor.com/project/gschier/insomnia/branch/master)
# Insomnia REST Client

Insomnia is a cross-platform _REST client_, built on top of [Electron](http://electron.atom.io/).
[![Insomnia REST Client](https://img.shields.io/badge/maintainer-Insomnia-purple.svg?colorB=6e60cc)](https://insomnia.rest)
[![Build status](https://ci.appveyor.com/api/projects/status/7b5a82uxbidpnkoa/branch/master?svg=true)](https://ci.appveyor.com/project/gschier/insomnia/branch/master)
[![license](https://img.shields.io/github/license/getinsomnia/importers.svg)]()

![Insomnia REST Client Screenshot](https://insomnia.rest/images/docs/promo.png?bust=1)
Insomnia is a cross-platform _REST client_, built on top of [Electron](http://electron.atom.io/).

## Setup
![Insomnia REST Client Screenshot](https://insomnia.rest/images/docs/promo.png)

```bash
# Install and use correct Node version
nvm install
## Bugs and Feature Requests

# Install dependencies
npm install
```
Have a bug or a feature request? Please first read the
[issue guidelines](CONTRIBUTING.md#using-the-issue-tracker) and search for existing and
closed issues. If your problem or idea is not addressed yet, [please open a new issue](/issues).

## Run Development
## Contributing

When you run the development environment, it will start both a dev server and an Electron
instance. The dev server is part of Webpack and is used to control hot module replacement
of UI components. This means that, if you change a component file, you will not need to
refresh the app to see the change. It will inject the new component immediately.
Please read through our [contributing guidelines](CONTRIBUTING.md). Included are directions
for opening issues, coding standards, and notes on development.

```bash
npm run dev
```
More over, if your pull request contains JavaScript patches or features, you must
include relevant unit tests.

## Build to Folder
Editor preferences are available in the [editor config](.editorconfig) for easy use in
common text editors. Read more and download plugins at <http://editorconfig.org>.

Build all assets into `./build/`
## License

```bash
npm run build
```
[GNU AGPLv3](LICENSE) &copy; [Insomnia](https://insomnia.rest)
8 changes: 7 additions & 1 deletion app/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ export function _actuallySendCurl (renderedRequest, workspace, settings) {
curl.setOpt(Curl.option.CUSTOMREQUEST, renderedRequest.method);
curl.setOpt(Curl.option.FOLLOWLOCATION, settings.followRedirects);
curl.setOpt(Curl.option.POSTREDIR, settings.followRedirects ? 2 ^ 3 : 0);
curl.setOpt(Curl.option.SSL_VERIFYPEER, settings.validateSSL ? 1 : 0);
curl.setOpt(Curl.option.SSL_VERIFYHOST, settings.validateSSL ? 2 : 0);
curl.setOpt(Curl.option.TIMEOUT_MS, settings.timeout); // 0 for no timeout
curl.setOpt(Curl.option.VERBOSE, true); // True so debug function works
Expand All @@ -188,6 +187,13 @@ export function _actuallySendCurl (renderedRequest, workspace, settings) {
curl.setOpt(Curl.option.DEBUGFUNCTION, (infoType, content) => {
const name = Object.keys(Curl.info.debug).find(k => Curl.info.debug[k] === infoType);

if (
infoType === Curl.info.debug.SSL_DATA_IN ||
infoType === Curl.info.debug.SSL_DATA_OUT
) {
return 0;
}

// Ignore the possibly large data messages
if (infoType === Curl.info.debug.DATA_OUT) {
if (content.length < 2000) {
Expand Down
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "insomnia",
"version": "5.0.1",
"version": "5.0.0",
"productName": "Insomnia",
"longName": "Insomnia REST Client",
"description": "A simple and beautiful REST API client",
Expand All @@ -14,7 +14,7 @@
"electron-squirrel-startup": "~1.0.0",
"hkdf": "0.0.2",
"httpsnippet": "1.16.5",
"insomnia-importers": "~1.3.0",
"insomnia-importers": "~1.3.1",
"jsonpath": "~0.2.9",
"mkdirp": "~0.5.1",
"nedb": "~1.8.0",
Expand Down
14 changes: 12 additions & 2 deletions app/ui/components/codemirror/code-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ class CodeEditor extends PureComponent {
this.codeMirror.on('keydown', this._codemirrorKeyDown);
this.codeMirror.on('focus', this._codemirrorFocus);
this.codeMirror.on('blur', this._codemirrorBlur);
this.codeMirror.on('paste', this._codemirrorValueChanged);
this.codeMirror.on('paste', this._codemirrorPaste);

this.codeMirror.setCursor({line: -1, ch: -1});

if (!this.codeMirror.getOption('indentWithTabs')) {
this.codeMirror.setOption('extraKeys', {
Tab: cm => {
const spaces = Array(this.codeMirror.getOption('indentUnit') + 1).join(' ');
const spaces = (new Array(this.codeMirror.getOption('indentUnit') + 1)).join(' ');
cm.replaceSelection(spaces);
}
});
Expand Down Expand Up @@ -458,6 +458,15 @@ class CodeEditor extends PureComponent {
}
}

_codemirrorPaste (cm, e) {
if (this.props.onPaste) {
this.props.onPaste(e);
}

// Notify of change right away
this._codemirrorValueChanged();
}

/**
* Wrapper function to add extra behaviour to our onChange event
*/
Expand Down Expand Up @@ -628,6 +637,7 @@ CodeEditor.propTypes = {
onKeyDown: PropTypes.func,
onMouseLeave: PropTypes.func,
onClick: PropTypes.func,
onPaste: PropTypes.func,
render: PropTypes.func,
getRenderContext: PropTypes.func,
getAutocompleteConstants: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ CodeMirror.defineExtension('isHintDropdownActive', function () {
);
});

CodeMirror.defineExtension('closeHint', function () {
if (this.state.completionActive) {
this.state.completionActive.close();
}
});

CodeMirror.defineOption('environmentAutocomplete', null, (cm, options) => {
if (!options) {
return;
Expand Down Expand Up @@ -77,14 +83,16 @@ CodeMirror.defineOption('environmentAutocomplete', null, (cm, options) => {
container: hintsContainer,
closeCharacters: COMPLETION_CLOSE_KEYS,
completeSingle: false,
// closeOnUnfocus: false, // Good for debugging (inspector)
extraKeys: {
'Tab': (cm, widget) => {
// Override default behavior and don't select hint on Tab
widget.close();
return CodeMirror.Pass;
}
}

// Good for debugging
// closeOnUnfocus: false
});
}

Expand Down Expand Up @@ -124,7 +132,7 @@ CodeMirror.defineOption('environmentAutocomplete', null, (cm, options) => {
cm.on('keydown', (cm, e) => {
// Only operate on one-letter keys. This will filter out
// any special keys (Backspace, Enter, etc)
if (e.key.length > 1) {
if (e.metaKey || e.ctrlKey || e.altKey || e.key.length > 1) {
return;
}

Expand Down Expand Up @@ -344,16 +352,11 @@ function renderHintMatch (li, self, data) {
let html = `
<label class="label" title="${title}">${char}</label>
<div class="name">${markedName}</div>
<div class="value" title=${data.displayValue}>
${data.displayValue || ''}
</div>
`;

if (data.displayValue) {
html += `
<div class="value" title=${data.displayValue}>
${data.displayValue}
</div>
`;
}

li.innerHTML = html;
li.className += ` type--${data.type}`;
}
14 changes: 9 additions & 5 deletions app/ui/components/codemirror/extensions/nunjucks-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ async function _highlightNunjucksTags (render) {
el.setAttribute('data-error', 'off');
el.setAttribute('data-template', tok.string);

(async function () {
await _updateElementText(renderString, el, tok.string);
})();

const mark = this.markText(start, end, {
__nunjucks: true, // Mark that we created it
__template: tok.string,
handleMouseEvents: false,
replacedWith: el
});

(async function () {
await _updateElementText(renderString, mark, tok.string);
})();

activeMarks.push(mark);

el.addEventListener('click', async () => {
Expand Down Expand Up @@ -203,7 +203,9 @@ async function _highlightNunjucksTags (render) {
}
}

async function _updateElementText (render, el, text) {
async function _updateElementText (render, mark, text) {
const el = mark.replacedWith;

try {
const str = text.replace(/\\/g, '');
const tagMatch = str.match(/{% *([^ ]+) *.*%}/);
Expand Down Expand Up @@ -234,12 +236,14 @@ async function _updateElementText (render, el, text) {
el.title = await render(str);
}
el.setAttribute('data-error', 'off');
mark.changed();
} catch (err) {
const fullMessage = err.message.replace(/\[.+,.+]\s*/, '');
let message = fullMessage;
const label = el.querySelector('label');
label.innerHTML = `<i class="fa fa-exclamation-triangle"></i>${label.innerHTML}`;
el.title = message;
el.setAttribute('data-error', 'on');
mark.changed();
}
}
4 changes: 4 additions & 0 deletions app/ui/components/codemirror/one-line-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class OneLineEditor extends PureComponent {
onChange,
placeholder,
render,
onPaste,
getRenderContext,
getAutocompleteConstants,
mode: syntaxMode,
Expand All @@ -263,6 +264,7 @@ class OneLineEditor extends PureComponent {
id={id}
mode={syntaxMode}
placeholder={placeholder}
onPaste={onPaste}
onBlur={this._handleEditorBlur}
onKeyDown={this._handleKeyDown}
onFocus={this._handleEditorFocus}
Expand Down Expand Up @@ -293,6 +295,7 @@ class OneLineEditor extends PureComponent {
onMouseEnter={this._handleInputMouseEnter}
onMouseLeave={this._handleInputMouseLeave}
onDragEnter={this._handleInputDragEnter}
onPaste={onPaste}
onFocus={this._handleInputFocus}
onKeyDown={this._handleInputKeyDown}
/>
Expand All @@ -312,6 +315,7 @@ OneLineEditor.propTypes = {
onKeyDown: PropTypes.func,
onFocus: PropTypes.func,
onChange: PropTypes.func,
onPaste: PropTypes.func,
render: PropTypes.func,
getRenderContext: PropTypes.func,
getAutocompleteConstants: PropTypes.func,
Expand Down
2 changes: 1 addition & 1 deletion app/ui/components/modals/changelog-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ChangelogModal extends PureComponent {
}

return (
<Modal ref={this._setModalRef} {...this.props}>
<Modal tall ref={this._setModalRef} {...this.props}>
<ModalHeader>Insomnia Changelog</ModalHeader>
<ModalBody className="pad changelog">
{html}
Expand Down
2 changes: 1 addition & 1 deletion app/ui/components/modals/nunjucks-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class NunjucksModal extends PureComponent {
let editor = null;
let title = '';
if (defaultTemplate.indexOf('{{') === 0) {
title = 'Variable Reference';
title = 'Variable';
editor = (
<VariableEditor
onChange={this._handleTemplateChange}
Expand Down
Loading

0 comments on commit 10564b5

Please sign in to comment.