diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..a6996bf --- /dev/null +++ b/.babelrc @@ -0,0 +1,10 @@ +{ + 'presets': [ + 'es2015', + 'stage-0', + 'stage-1', + 'stage-2', + 'stage-3' + ], + 'plugins': ['transform-runtime', 'transform-decorators-legacy'] +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2cf7aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +build/ +node_modules/ diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..7aefc82 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v5.6.0 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9b4caf2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Blockchain of Things Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c24b132 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +identifier=com.blockchainofthings.PawExtensions.UrlPathParamDynValue +extensions_dir=$(HOME)/Library/Containers/com.luckymarmot.Paw/Data/Library/Application Support/com.luckymarmot.Paw/Extensions/ + +build: + npm run build + cp README.md LICENSE ./build/$(identifier)/ + +clean: + rm -Rf ./build/ + +install: clean build + mkdir -p "$(extensions_dir)$(identifier)/" + cp -r ./build/$(identifier)/* "$(extensions_dir)$(identifier)/" + +test: + npm test + +archive: build + cd ./build/; zip -r UrlPathParamDynValue.zip "$(identifier)/" diff --git a/README.md b/README.md new file mode 100644 index 0000000..9c7d56f --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# URL Path Parameter Paw Extension + +This is a Dynamic Value Paw extension that can be used to add parameters to the URL path. + +## Use + +Just add the Dynamic Value to the URL, specify a name for the parameter and its value. The value you enter +is automatically URL-encoded, and the name of the parameter is shown on the URL input field instead of the actual value, which +makes the URL more readable and clean. It also helps for an easier identification of the different parameters that are found +in the URL. + +## Development + +### Prerequisites + +```shell +nvm install +nvm use +npm install +``` + +### Build + +```shell +npm run build +``` + +### Install + +```shell +make install +``` + +### Test + +```shell +npm test +``` + +## License + +This Paw Extension is released under the [MIT License](LICENSE). Feel free to fork, and modify! + +Copyright © 2017 Blockchain of Things Inc. diff --git a/package.json b/package.json new file mode 100644 index 0000000..8d6a82d --- /dev/null +++ b/package.json @@ -0,0 +1,42 @@ +{ + "name": "UrlPathParamDynValue", + "version": "1.0.0", + "main": "src/UrlPathParamDynValue.js", + "license": "MIT", + "homepage": "https://github.com/blockchainofthings/Paw-UrlPathParamDynValue", + "dependencies": { + "babel-plugin-transform-flow-strip-types": "6.3.15", + "babel-polyfill": "6.3.14", + "babel-runtime": "6.3.19", + "immutable": "3.7.6" + }, + "devDependencies": { + "babel-core": "6.4.0", + "babel-loader": "6.2.0", + "babel-plugin-rewire": "1.0.0-beta-3", + "babel-plugin-transform-decorators": "6.3.13", + "babel-plugin-transform-decorators-legacy": "1.3.2", + "babel-plugin-transform-runtime": "6.3.13", + "babel-preset-es2015": "6.3.13", + "babel-preset-stage-0": "6.3.13", + "babel-preset-stage-1": "6.3.13", + "babel-preset-stage-2": "6.3.13", + "babel-preset-stage-3": "6.3.13", + "babel-register": "6.3.13", + "chai": "3.4.1", + "mocha": "2.3.4", + "path": "0.12.7", + "webpack": "1.12.9" + }, + "scripts": { + "build": "rm -rf dist/ && BUILD_ENV=build ./node_modules/.bin/webpack --bail --display-error-details", + "test": "exit 0" + }, + "options": { + "mocha": "./node_modules/.bin/mocha --require mocha --compilers js:babel-register --reporter spec" + }, + "repository": { + "type": "git", + "url": "https://github.com/blockchainofthings/Paw-UrlPathParamDynValue.git" + } +} diff --git a/src/UrlPathParamDynValue.js b/src/UrlPathParamDynValue.js new file mode 100644 index 0000000..e9fb715 --- /dev/null +++ b/src/UrlPathParamDynValue.js @@ -0,0 +1,26 @@ +/** + * Created by claudio on 25/02/17. + */ + +@registerDynamicValueClass +class UrlPathParamDynValue { + + static identifier = 'com.blockchainofthings.PawExtensions.UrlPathParamDynValue'; + static title = 'URL Path Parameter'; + static inputs = [ + DynamicValueInput('paramName', 'Parameter Name', "String"), + DynamicValueInput('paramValue', 'Value', "String") + ]; + + evaluate(context) { + return encodeURIComponent(this.paramValue); + } + + title(context) { + return 'Param'; + } + + text(context) { + return this.paramName; + } +} diff --git a/webpack.config.babel.js b/webpack.config.babel.js new file mode 100644 index 0000000..069562a --- /dev/null +++ b/webpack.config.babel.js @@ -0,0 +1,34 @@ +import webpack from 'webpack'; +import path from 'path'; + +const name = 'UrlPathParamDynValue'; + +const production = process.env.NODE_ENV === 'production'; + +const config = { + target: 'web', + entry: [ + 'immutable', + './src/UrlPathParamDynValue.js' + ], + output:{ + path: path.join(__dirname, + './build/com.blockchainofthings.PawExtensions.UrlPathParamDynValue'), + pathInfo: true, + publicPath: '/build/', + filename: name+'.js' + }, + module: { + loaders: [ + { + loader: 'babel-loader', + include: [ + path.resolve(__dirname, 'src') + ], + test: /\.jsx?$/ + } + ] + } +}; + +module.exports = config;