You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by db...@apache.org on 2015/08/20 01:40:53 UTC
docs commit: Added plugin search js from cordova-registry-web
Repository: cordova-docs
Updated Branches:
refs/heads/cordova-website 7ce8ade50 -> 769333297
Added plugin search js from cordova-registry-web
Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/76933329
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/76933329
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/76933329
Branch: refs/heads/cordova-website
Commit: 7693332975047f66cb0d4b6598549cbafc57450c
Parents: 7ce8ade
Author: riknoll <ri...@microsoft.com>
Authored: Wed Aug 19 13:21:06 2015 -0700
Committer: riknoll <ri...@microsoft.com>
Committed: Wed Aug 19 13:21:06 2015 -0700
----------------------------------------------------------------------
.gitignore | 1 +
_dev.yml | 1 +
_prod.yml | 1 +
gulpfile.js | 54 +++-
package.json | 9 +
www/static/react-src/app.js | 321 +++++++++++++++++++++
www/static/react-src/blacklisted-plugins.json | 8 +
www/static/react-src/official-plugins.json | 26 ++
www/static/react-src/platformbutton.jsx | 15 +
www/static/react-src/plugin.jsx | 71 +++++
www/static/react-src/pluginlist.jsx | 82 ++++++
www/static/react-src/searchbar.jsx | 59 ++++
www/static/react-src/supportedplatforms.jsx | 83 ++++++
13 files changed, 728 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 01c31fd..f116d60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,5 +5,6 @@ _defaults.yml
www/_data/languages.yml
node_modules
www/static/css
+www/static/react
Gemfile.lock
settings.json
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/_dev.yml
----------------------------------------------------------------------
diff --git a/_dev.yml b/_dev.yml
index b5be687..75e82ec 100644
--- a/_dev.yml
+++ b/_dev.yml
@@ -1,5 +1,6 @@
exclude:
- static/css-src
+ - static/react-src
- docs/de
- docs/es
- docs/fr
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/_prod.yml
----------------------------------------------------------------------
diff --git a/_prod.yml b/_prod.yml
index 1cbc5ac..c97b100 100644
--- a/_prod.yml
+++ b/_prod.yml
@@ -2,3 +2,4 @@ baseurl: "/use-the-force-luke"
destination: deploy
exclude:
- static/css-src
+ - static/react-src
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/gulpfile.js
----------------------------------------------------------------------
diff --git a/gulpfile.js b/gulpfile.js
index d2bbf3c..9bb93e0 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -13,6 +13,14 @@ var buffer = require("vinyl-buffer");
var browsersync = require("browser-sync");
var header = require("gulp-header");
+var concat = require('gulp-concat');
+var gutil = require('gulp-util');
+var browserify = require('browserify');
+var argv = require('yargs').argv;
+var reactify = require('reactify');
+var uglify = require('gulp-uglify');
+var envify = require('envify');
+
// constants
var CONFIG_FILES = ["_config.yml", "_defaults.yml"];
var DEV_FLAGS = ["--config", CONFIG_FILES.concat(["_dev.yml"]).join(","), "--trace"];
@@ -31,6 +39,9 @@ var LANGUAGES_FILE = path.join(DATA_DIR, "languages.yml");
var DOCS_DIR = path.join(SOURCE_DIR, "docs");
var CSS_SRC_DIR = path.join(SOURCE_DIR, "static", "css-src");
var CSS_OUT_DIR = path.join(SOURCE_DIR, "static", "css");
+var REACT_SRC_DIR = path.join(SOURCE_DIR, "static", "react-src");
+var REACT_OUT_DIR = path.join(SOURCE_DIR, "static", "react");
+var JS_OUT_DIR = path.join(SOURCE_DIR, "static", "js")
var BIN_DIR = path.join("tools", "bin");
// helpers
@@ -74,11 +85,21 @@ gulp.task("watch", function () {
);
gulp.watch(
[
+ path.join(REACT_SRC_DIR, "**", "*.js"),
+ path.join(REACT_SRC_DIR, "**", "*.jsx"),
+ path.join(REACT_SRC_DIR, "**", "*.json"),
+ ],
+ {interval: WATCH_INTERVAL},
+ ["scripts-dev", "regen-dev"]
+ );
+ gulp.watch(
+ [
"*.yml",
path.join(DATA_DIR, "**", "*.yml"),
path.join(SOURCE_DIR, "**", "*.html"),
path.join(SOURCE_DIR, "**", "*.md"),
- path.join(SOURCE_DIR, "**", "*.js"),
+ path.join(JS_OUT_DIR, "**", "*.js"),
+ path.join(REACT_OUT_DIR, "*.js"),
path.join(CSS_OUT_DIR, "**", "*.css"),
],
{interval: WATCH_INTERVAL},
@@ -94,7 +115,7 @@ gulp.task("regen-dev", ["gen-dev"], function () {
browsersync.reload();
});
-gulp.task("build-dev", ["configs", "styles"], function () {
+gulp.task("build-dev", ["configs", "styles", "scripts-dev"], function () {
gulp.run("gen-dev");
});
@@ -102,7 +123,7 @@ gulp.task("gen-prod", function (done) {
exec("jekyll.bat", ["build"].concat(PROD_FLAGS), done);
});
-gulp.task("build-prod", ["configs", "styles"], function (done) {
+gulp.task("build-prod", ["configs", "styles", "scripts-prod"], function (done) {
gulp.run("gen-prod");
});
@@ -140,6 +161,32 @@ gulp.task("styles", function() {
.pipe(gulp.dest(CSS_OUT_DIR));
});
+gulp.task("scripts-dev", function() {
+ return browserify(path.join(REACT_SRC_DIR, 'app.js'), { debug: true })
+ .transform(reactify)
+ .transform(envify)
+ .bundle()
+ .on('error', gutil.log)
+ .pipe(vstream('app.js'))
+ .pipe(buffer())
+ .pipe(gulp.dest(REACT_OUT_DIR));
+});
+
+gulp.task("scripts-prod", function() {
+ // This is needed for envify to remove debug only code from REACT
+ process.env.NODE_ENV = 'production';
+ browserify(path.join(REACT_SRC_DIR, 'app.js'), { debug: false })
+ .transform(reactify)
+ .transform(envify)
+ .bundle()
+ .on('error', gutil.log)
+ .pipe(vstream('app.js'))
+ .pipe(buffer())
+ .pipe(uglify()) // minify only if not debug build.
+ .on('error', gutil.log)
+ .pipe(gulp.dest(REACT_OUT_DIR));
+});
+
// convenience tasks
gulp.task("link-bugs", function (done) {
exec(bin("linkify-bugs.sh"), [path.join(SOURCE_DIR, "_posts")], done);
@@ -150,6 +197,7 @@ gulp.task("clean", function () {
fse.remove(DEPLOY_DIR);
fse.remove(path.join(DATA_DIR, "toc", "*-generated.yml"));
fse.remove(CSS_OUT_DIR);
+ fse.remove(REACT_OUT_DIR);
fse.remove(LANGUAGES_FILE);
fse.remove(DEFAULTS_FILE);
});
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 6ad9113..1111c42 100644
--- a/package.json
+++ b/package.json
@@ -14,8 +14,12 @@
"author": "Apache Software Foundation",
"license": "Apache Version 2.0",
"dependencies": {
+ "baconjs": "^0.7.70",
"browser-sync": "^2.8.0",
+ "browserify": "^10.2.4",
"cheerio": "^0.17.0",
+ "classnames": "^2.1.2",
+ "envify": "^3.4.0",
"esrever": "^0.1.0",
"fs-extra": "^0.11.1",
"gulp": "^3.9.0",
@@ -24,12 +28,17 @@
"gulp-less": "^3.0.3",
"gulp-run": "^1.6.8",
"gulp-sass": "^2.0.4",
+ "gulp-uglify": "^1.2.0",
+ "gulp-util": "^3.0.5",
"jodoc": "git://github.com/kant2002/jodoc-js",
"js-yaml": "^3.2.2",
"less": "^2.5.1",
"node-dir": "^0.1.6",
"optimist": "^0.6.1",
"q": "^1.4.1",
+ "react": "^0.13.3",
+ "react-tools": "^0.13.3",
+ "reactify": "^1.1.1",
"shelljs": "^0.3.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/www/static/react-src/app.js
----------------------------------------------------------------------
diff --git a/www/static/react-src/app.js b/www/static/react-src/app.js
new file mode 100644
index 0000000..3264567
--- /dev/null
+++ b/www/static/react-src/app.js
@@ -0,0 +1,321 @@
+var React = window.React = require('react'), // assign it to window for react chrome extension
+ SearchBar = require('./searchbar.jsx'),
+ PluginList = require('./pluginlist.jsx'),
+ App = {};
+
+var timer = null;
+var Constants = {
+ DownloadCountBatch: 100,
+ NpmSearchInitialSize: 500
+}
+
+window.addEventListener('popstate', function(e) {
+ if(e.state) {
+ var appInstance = React.render(<App />, document.getElementById('container'));
+ appInstance.loadFilterText(e.state.filterText);
+ }
+});
+
+var App = React.createClass({
+ getInitialState: function() {
+ var q = App.getURLParameter('q');
+ if (q) {
+ return {
+ plugins: [],
+ filterText: q,
+ placeHolderText: 'Loading...',
+ searchResults: []
+ }
+ } else {
+ return {
+ plugins: [],
+ filterText: '',
+ placeHolderText: 'Loading...',
+ searchResults: []
+ };
+ }
+ },
+ handleUserInput: function(filterText) {
+ /* Routing logic */
+ var filterTextLowerCase = filterText.toLowerCase();
+ delay(function(){
+ window.history.pushState({"filterText":filterTextLowerCase}, "", "?q=" + filterTextLowerCase);
+ ga('send', 'pageview', '/index.html?q=' + filterTextLowerCase);
+ }, 2000 );
+
+ this.setState({
+ filterText: filterText,
+ searchResults: App.filterPlugins(this.state.plugins, filterText)
+ });
+ },
+ addCondition: function(condition) {
+ this.setState(function(previousState, currentProps) {
+ if(previousState.filterText.indexOf(condition) > -1) {
+ return {
+ filterText: previousState.filterText,
+ plugins: previousState.plugins
+ };
+ }
+ else {
+ return {
+ filterText: previousState.filterText.trim() + ' ' + condition + ' ',
+ plugins: previousState.plugins
+ };
+ }
+ });
+ },
+ loadFilterText : function(filterText) {
+ this.setState(function(previousState, currentProps) {
+ return {
+ filterText: filterText,
+ plugins: previousState.plugins
+ };
+ });
+ },
+ statics: {
+ getURLParameter : function(name) {
+ return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)
+ ||[,""])[1].replace(/\+/g, '%20'))||null;
+ },
+ shallowCopy: function(src) {
+ var dst = {};
+ for(var i in src) {
+ if(src.hasOwnProperty(i)) {
+ dst[i] = src[i];
+ }
+ }
+ return dst;
+ },
+ tagOfficialPlugins: function() {
+
+ },
+ filterPlugins: function(plugins, filter) {
+ var contains = function(values, pluginInfo) {
+ var allValuesPresent = true;
+ if(values.length == 0) {
+ return allValuesPresent;
+ }
+ if(!pluginInfo) {
+ return false;
+ }
+ values.forEach(function(value) {
+ var valuePresent = false;
+ for(var index=0; index < pluginInfo.length; index++) {
+ if(pluginInfo[index] && pluginInfo[index].toLowerCase().indexOf(value) > -1) {
+ valuePresent = true;
+ }
+ }
+ if(!valuePresent) {
+ allValuesPresent = false;
+ }
+ });
+ return allValuesPresent;
+ }
+ var populateFilters = function(filterText) {
+ var searchStrings = filterText.split(" ");
+ var filters = [];
+ filters['platforms'] = [];
+ filters['authors'] = [];
+ filters['licenses'] = [];
+ filters['searchWords'] = [];
+
+ searchStrings.forEach(function(searchString) {
+ var keywords = searchString.split(":");
+ if(keywords.length == 1) {
+ var param = keywords[0].trim();
+ if(param) {
+ filters['searchWords'].push(param);
+ }
+ }
+ else if(keywords[1].trim()) {
+ var param = keywords[1].trim();
+ switch(keywords[0]) {
+ case 'platform':
+ filters['platforms'].push(param);
+ break;
+ case 'author':
+ filters['authors'].push(param);
+ break;
+ case 'license':
+ filters['licenses'].push(param);
+ break;
+ default:
+ filters['searchWords'].push(searchString);
+ }
+ }
+ else {
+ filters['searchWords'].push(searchString);
+ }
+ });
+ return filters;
+ }
+ var results = [];
+ var filters = populateFilters(filter);
+ for (var i = 0; i < plugins.length; i++) {
+ var plugin = plugins[i];
+ var fullPluginText = plugin.name.concat(plugin.author, plugin.keywords, plugin.license, plugin.description);
+ if(contains(filters['platforms'], plugin.keywords)
+ && contains(filters['authors'], plugin.author)
+ && contains(filters['licenses'], plugin.license)
+ && contains(filters['searchWords'], fullPluginText)) {
+ results.push(plugin);
+ }
+ };
+ return results;
+ }
+ },
+ componentDidMount: function() {
+ var plugins = [],
+ officialPlugins = require('./official-plugins.json').plugins,
+ blacklistedPlugins = require('./blacklisted-plugins.json').plugins,
+ pluginCount = 0,
+ self = this,
+ queryHost = "http://npmsearch.com/query",
+ queryFields = "fields=name,keywords,license,description,author,modified,homepage,version",
+ queryKeywords = "q=keywords:%22ecosystem:cordova%22",
+ queryInitialSize = Constants.NpmSearchInitialSize;
+
+ xhrRequest(queryHost + "?" + queryFields + "&" + queryKeywords + "&size=" + queryInitialSize + "&start=0&sort=rating:desc", function(xhrResult) {
+ plugins = xhrResult.results;
+ pluginCount = xhrResult.total;
+ if (pluginCount <= queryInitialSize) {
+ processPlugins.bind(self, officialPlugins, plugins)();
+ } else {
+ xhrRequest(queryHost + "?" + queryFields + "&" + queryKeywords + "&size=" + (pluginCount - queryInitialSize) + "&start=" + queryInitialSize + "&sort=rating:desc", function(xhrResult) {
+ plugins = [].concat(plugins, xhrResult.results);
+ processPlugins.bind(self, officialPlugins, plugins)();
+ }, function() { console.log('xhr err'); });
+ }
+ }, function() { console.log('xhr err'); });
+
+ var getDownloadCount = function(plugins, that) {
+ var packageNames = "";
+ for(var index=0; index < plugins.length; index++) {
+ packageNames += plugins[index].name + ",";
+ if(index % Constants.DownloadCountBatch === 0 || index === plugins.length -1) {
+ xhrRequest("https://api.npmjs.org/downloads/point/last-month/" + packageNames, function(xhrResult) {
+ for(var j = 0; j < plugins.length; j++) {
+ if(xhrResult[plugins[j].name]) {
+ plugins[j] = App.shallowCopy(plugins[j]);
+ plugins[j].downloadCount = xhrResult[plugins[j].name].downloads;
+ }
+ }
+
+ // If we were unable to do server side sorting because
+ // we requested in multiple batches, do it in the client
+ if(plugins.length > Constants.NpmSearchInitialSize) {
+ plugins.sort(function(p1, p2) {
+ return p2.downloadCount - p1.downloadCount;
+ });
+ }
+
+ that.setState({
+ plugins: plugins,
+ searchResults: App.filterPlugins(plugins, this.state.filterText)
+ });
+ }.bind(self), function() { console.log('xhr err'); });
+ packageNames = "";
+ }
+ }
+ }
+
+ function processPlugins(officialPlugins, plugins) {
+ var pluginCount = plugins.length,
+ dateNow = new Date(),
+ oneDay = 1000*60*60*24;
+
+ officialPlugins.forEach(function(plugin) {
+ for (var i = 0; i < plugins.length; i++) {
+ // Check if plugin name is in official list
+ if (plugins[i].name[0] === plugin) {
+ plugins[i].isOfficial = true;
+ return;
+ }
+ };
+ });
+
+ for(var i = plugins.length -1; i >= 0 ; i--)
+ {
+ for(var j = 0; j < blacklistedPlugins.length; j++)
+ {
+ if(plugins[i].name[0] === blacklistedPlugins[j])
+ {
+ plugins.splice(i, 1);
+ break;
+ }
+ }
+ }
+
+ for (var i = 0; i < plugins.length; i++) {
+ // Calculate last time plugin is modified (in days)
+ plugins[i].modified = Math.ceil((dateNow - new Date(plugins[i].modified)) / oneDay);
+ };
+
+ if (this.isMounted()) {
+ var q = App.getURLParameter('q');
+ if(q) {
+ this.setState({
+ plugins: plugins,
+ filterText: q,
+ placeHolderText: 'Search ' + pluginCount + ' plugins...',
+ searchResults: App.filterPlugins(plugins, q)
+ });
+ }
+ else {
+ this.setState({
+ plugins: plugins,
+ placeHolderText: 'Search ' + pluginCount + ' plugins...',
+ searchResults: plugins
+ });
+ }
+ getDownloadCount(plugins,this);
+ }
+ }
+ },
+ render: function() {
+ return (
+ <div>
+ <div id="headblock">
+ <div id="topcontent">
+ <div id="pluggy"></div>
+ <div id="discovermessage"><h1>Search Cordova Plugins</h1></div>
+ </div>
+ <SearchBar
+ initialValue={this.state.filterText}
+ placeHolderText={this.state.placeHolderText}
+ onUserInput={this.handleUserInput}
+ />
+ </div>
+ <PluginList plugins={this.state.searchResults} />
+ </div>
+ );
+ }
+});
+
+App.start = function() {
+ React.render(<App />, document.getElementById('container'));
+};
+
+function delay(callback, ms){
+ clearTimeout (timer);
+ timer = setTimeout(callback, ms);
+}
+
+function xhrRequest(url, success, fail) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == XMLHttpRequest.DONE ) {
+ if(xhr.status == 200){
+ success(JSON.parse(xhr.responseText));
+ return;
+ } else {
+ fail();
+ return;
+ }
+ }
+ }.bind(this)
+ xhr.open("GET", url, true);
+ xhr.send();
+}
+
+module.exports = window.App = App;
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/www/static/react-src/blacklisted-plugins.json
----------------------------------------------------------------------
diff --git a/www/static/react-src/blacklisted-plugins.json b/www/static/react-src/blacklisted-plugins.json
new file mode 100644
index 0000000..946e82e
--- /dev/null
+++ b/www/static/react-src/blacklisted-plugins.json
@@ -0,0 +1,8 @@
+{
+ "plugins" : [
+ "cordova-wp8",
+ "cordova-wp8-testtest",
+ "cordova-app-hello-world",
+ "delete-this"
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/www/static/react-src/official-plugins.json
----------------------------------------------------------------------
diff --git a/www/static/react-src/official-plugins.json b/www/static/react-src/official-plugins.json
new file mode 100644
index 0000000..d220cfb
--- /dev/null
+++ b/www/static/react-src/official-plugins.json
@@ -0,0 +1,26 @@
+{
+ "plugins" : [
+ "cordova-plugin-battery-status",
+ "cordova-plugin-camera",
+ "cordova-plugin-console",
+ "cordova-plugin-contacts",
+ "cordova-plugin-device",
+ "cordova-plugin-device-motion",
+ "cordova-plugin-device-orientation",
+ "cordova-plugin-dialogs",
+ "cordova-plugin-file",
+ "cordova-plugin-file-transfer",
+ "cordova-plugin-geolocation",
+ "cordova-plugin-globalization",
+ "cordova-plugin-inappbrowser",
+ "cordova-plugin-legacy-whitelist",
+ "cordova-plugin-media",
+ "cordova-plugin-media-capture",
+ "cordova-plugin-ms-appinsights",
+ "cordova-plugin-network-information",
+ "cordova-plugin-splashscreen",
+ "cordova-plugin-statusbar",
+ "cordova-plugin-vibration",
+ "cordova-plugin-whitelist"
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/www/static/react-src/platformbutton.jsx
----------------------------------------------------------------------
diff --git a/www/static/react-src/platformbutton.jsx b/www/static/react-src/platformbutton.jsx
new file mode 100644
index 0000000..66b007b
--- /dev/null
+++ b/www/static/react-src/platformbutton.jsx
@@ -0,0 +1,15 @@
+var React = require('react');
+
+var PlatformButton = React.createClass({
+ onClick: function() {
+ var appInstance = React.render(<App />, document.getElementById('container'));
+ appInstance.addCondition("platform:" + this.props.platform);
+ },
+ render: function() {
+ return (
+ <li className = "clickable" onClick={this.onClick}> {this.props.platform} </li>
+ );
+ }
+});
+
+module.exports = PlatformButton;
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/www/static/react-src/plugin.jsx
----------------------------------------------------------------------
diff --git a/www/static/react-src/plugin.jsx b/www/static/react-src/plugin.jsx
new file mode 100644
index 0000000..0c5cb2f
--- /dev/null
+++ b/www/static/react-src/plugin.jsx
@@ -0,0 +1,71 @@
+var React = require('react'),
+ SupportedPlatforms = require('./supportedplatforms.jsx'),
+ classNames = require('classnames');
+
+var Plugin = React.createClass({
+ shouldComponentUpdate: function(nextProps, nextState) {
+ return this.props.plugin !== nextProps.plugin;
+ },
+ render: function() {
+ if(!this.props.plugin) {
+ // Empty card with loading wheel
+ return (
+ <li>
+ <div className="pluginCard">
+ <div style={{ textAlign: 'center', height: 10 + "rem"}}>
+ <span style={{ display: 'inline-block', height: 100 + "%", verticalAlign: 'middle'}} />
+ <img style={{verticalAlign: 'middle'}} src="img/loading.gif" />
+ </div>
+ </div>
+ </li>
+ )
+ }
+
+ var license = this.props.plugin.license;
+ if (license && license.length > 1) {
+ license = license[0];
+ }
+ var downloadField;
+ var npmLink = 'https://www.npmjs.com/package/' + this.props.plugin.name;
+
+ var classes = classNames({
+ 'pluginCard': true,
+ 'featuredPlugin': this.props.plugin.isOfficial
+ });
+
+ if(this.props.plugin.downloadCount) {
+ var downloadCount = this.props.plugin.downloadCount.toLocaleString();
+ downloadField = <p><small> {downloadCount} downloads last month</small></p>;
+ }
+
+ return (
+ <li>
+ <div className={classes}>
+ <div className="primaryContent">
+ <div className="header">
+ <h3><a href={npmLink} onClick={trackOutboundLink.bind(this, npmLink)} target="_blank">{this.props.plugin.name}</a></h3>
+ <small className="pluginVersion">v{this.props.plugin.version}</small>
+ <small> by </small>
+ <small className="pluginAuthor">{this.props.plugin.author}</small>
+ </div>
+ <div className="pluginDesc">{this.props.plugin.description}</div>
+ </div>
+ <div className="secondaryContent">
+ <SupportedPlatforms keywords={this.props.plugin.keywords}/>
+ <div className="extraInfo">
+ <p><small><strong>License:</strong> {license}</small></p>
+ {downloadField}
+ <p><small><em>Last updated {this.props.plugin.modified} days ago</em></small></p>
+ </div>
+ </div>
+ </div>
+ </li>
+ )
+ }
+});
+
+function trackOutboundLink(url) {
+ ga('send', 'event', 'outbound', 'click', url);
+}
+
+module.exports = Plugin;
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/www/static/react-src/pluginlist.jsx
----------------------------------------------------------------------
diff --git a/www/static/react-src/pluginlist.jsx b/www/static/react-src/pluginlist.jsx
new file mode 100644
index 0000000..0868979
--- /dev/null
+++ b/www/static/react-src/pluginlist.jsx
@@ -0,0 +1,82 @@
+var React = require('react'),
+ Plugin = require('./plugin.jsx');
+
+var InitialPageLength = 10;
+var PageExtensionLength = 20;
+
+/*
+ States site loaded
+ */
+var PluginList = React.createClass({
+ getInitialState: function() {
+ return { bootstrapped: false }
+ },
+ componentWillReceiveProps: function() {
+ // Recieving a set of plugins
+ this.setState({
+ bootstrapped: true,
+ searchPage: 0
+ });
+ },
+ increaseSearchResults: function() {
+ this.setState({ searchPage: this.state.searchPage + 1 });
+ },
+ render: function() {
+ if (!this.state.bootstrapped) {
+ var emptyPluginList = [];
+
+ for (var i = 0; i < InitialPageLength; i++) {
+ emptyPluginList.push(<Plugin key={i}/>)
+ };
+
+ return (
+ <div className="contentwrap">
+ <ul className="pluginList">
+ {emptyPluginList}
+ </ul>
+ </div>
+ )
+ } else {
+ var plugins = this.props.plugins;
+ var showMore = null, visiblePlugins = [];
+ if (plugins.length - this.state.searchPage * PageExtensionLength > InitialPageLength) {
+ showMore =
+ <div className="pluginCard" onClick={this.increaseSearchResults} style={{cursor: 'pointer'}}>
+ <div style={{ display: 'table', width:100 + '%', minHeight: 5 + 'rem'}}>
+ <div style={{ display: 'table-cell', verticalAlign: 'middle'}}>
+ <div style={{textAlign: 'center'}}>Show More</div>
+ </div>
+ </div>
+ </div>;
+ }
+
+ if (plugins.length === 0) {
+ return (
+ <div className="contentwrap">
+ <div className="pluginEmptyMessage">
+ No plugins found. Learn how to <a href="http://cordova.apache.org/docs/en/edge/guide_hybrid_plugins_index.md.html#Plugin%20Development%20Guide">create one</a>
+ </div>
+ </div>
+ );
+ } else {
+ for (var i = 0; i < InitialPageLength + this.state.searchPage * PageExtensionLength; i++) {
+ if (plugins[i]) {
+ visiblePlugins.push(<Plugin plugin={plugins[i]} key={i}/>);
+ } else {
+ break;
+ }
+ };
+ return (
+ <div className="contentwrap">
+ <ul className="pluginList">
+ {visiblePlugins}
+ </ul>
+ {showMore}
+ </div>
+ );
+ }
+ }
+ }
+});
+
+module.exports = PluginList;
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/www/static/react-src/searchbar.jsx
----------------------------------------------------------------------
diff --git a/www/static/react-src/searchbar.jsx b/www/static/react-src/searchbar.jsx
new file mode 100644
index 0000000..75a4569
--- /dev/null
+++ b/www/static/react-src/searchbar.jsx
@@ -0,0 +1,59 @@
+var Bacon = require('baconjs').Bacon;
+
+var SearchBar = React.createClass({
+ propTypes: {
+ initialValue: React.PropTypes.string.isRequired,
+ placeHolderText: React.PropTypes.string.isRequired,
+ onUserInput: React.PropTypes.func.isRequired
+ },
+
+ getInitialState: function() {
+ return { textValue: this.props.initialValue }
+ },
+
+ handleChange: function(event) {
+ this.setState({ textValue: event.target.value });
+ },
+
+ componentDidMount: function() {
+ var self = this,
+ delay = 200, // in ms
+ inputElem = React.findDOMNode(this.refs.filterTextInput);
+
+ // Convert keydown events to stream
+ var text = Bacon.fromEvent(inputElem, 'keydown')
+ .debounce(delay)
+ .map(function(event) {
+ return event.target.value;
+ })
+ .skipDuplicates();
+
+ var textObservable = text.flatMapLatest(function(query) {
+ return Bacon.once(query);
+ });
+
+ textObservable.onValue(function(val) {
+ self.props.onUserInput(val);
+ });
+ },
+
+ render: function() {
+ return (
+ <div className="contentwrap">
+ <div id="search">
+ <input
+ className="searchBox"
+ type="search"
+ autoComplete="off"
+ placeholder={this.props.placeHolderText}
+ value={this.state.textValue}
+ onChange={this.handleChange}
+ ref="filterTextInput"
+ />
+ </div>
+ </div>
+ );
+ }
+});
+
+module.exports = SearchBar;
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/76933329/www/static/react-src/supportedplatforms.jsx
----------------------------------------------------------------------
diff --git a/www/static/react-src/supportedplatforms.jsx b/www/static/react-src/supportedplatforms.jsx
new file mode 100644
index 0000000..f6de778
--- /dev/null
+++ b/www/static/react-src/supportedplatforms.jsx
@@ -0,0 +1,83 @@
+var React = require('react'),
+ PlatformButton = require('./platformbutton.jsx')
+
+var SupportedPlatforms = React.createClass({
+ getInitialState: function() {
+ return {
+ moreClicked: false
+ };
+ },
+ onClick: function() {
+ this.setState({
+ moreClicked: true
+ });
+ },
+ render: function() {
+ var keywords = this.props.keywords;
+ var sortedMajorPlatforms = [{present:false, text: "Android"}, {present:false, text: "iOS"}, {present:false, text: "Windows"}, {present:false, text: "Blackberry10"}];
+ var majorPlatformsSupported = [];
+ var otherPlatformsSupported = [];
+ // remove windows8 & windows dupe
+ if (keywords.indexOf('cordova-windows') > -1 && keywords.indexOf('cordova-windows8') > -1) {
+ keywords.splice(keywords.indexOf('cordova-windows8'), 1);
+ }
+ keywords.forEach(function(keyword) {
+ switch (keyword) {
+ case 'cordova-firefoxos':
+ otherPlatformsSupported.push(<PlatformButton platform="FirefoxOS" />);
+ break;
+ case 'cordova-android':
+ sortedMajorPlatforms[0].present = true;
+ break;
+ case 'cordova-amazon-fireos':
+ otherPlatformsSupported.push(<PlatformButton platform="FireOS" />);
+ break;
+ case 'cordova-ubuntu':
+ otherPlatformsSupported.push(<PlatformButton platform="Ubuntu" />);
+ break;
+ case 'cordova-ios':
+ sortedMajorPlatforms[1].present = true;
+ break;
+ case 'cordova-blackberry10':
+ sortedMajorPlatforms[3].present = true;
+ break;
+ case 'cordova-wp8':
+ otherPlatformsSupported.push(<PlatformButton platform="Windows Phone 8" />);
+ break;
+ case 'cordova-windows8':
+ case 'cordova-windows':
+ sortedMajorPlatforms[2].present = true;
+ break;
+ case 'cordova-browser':
+ otherPlatformsSupported.push(<PlatformButton platform="Browser" />);
+ break;
+ }
+ });
+
+ sortedMajorPlatforms.forEach(function(platform) {
+ if(platform.present) {
+ majorPlatformsSupported.push(<PlatformButton platform={platform.text} />)
+ }
+ });
+ while(majorPlatformsSupported.length < 4 && otherPlatformsSupported.length > 0) {
+ majorPlatformsSupported.push(otherPlatformsSupported.shift());
+ }
+
+ var moreButton;
+ if(otherPlatformsSupported.length > 0 && !this.state.moreClicked) {
+ moreButton = <li className="clickable" onClick={this.onClick}>...</li>
+ }
+ if (!this.state.moreClicked) {
+ otherPlatformsSupported = null;
+ }
+ return (
+ <ul className="supportedPlatforms">
+ {majorPlatformsSupported}
+ {moreButton}
+ {otherPlatformsSupported}
+ </ul>
+ );
+ }
+});
+
+module.exports = SupportedPlatforms;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org