From 82d0323f589b40abbb7df340dda2a95371235efd Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 20 Feb 2019 09:28:14 -0800 Subject: [PATCH] Progress of file picker --- scripts/allFileNames.js | 59 ------------------------ scripts/createSearchIndex.js | 23 +++++++++- src/App.css | 18 ++++++++ src/FocusedSkin.js | 37 +++++++++++++-- src/Readme.js | 89 ------------------------------------ src/redux/actionCreators.js | 8 ++++ src/redux/epics.js | 64 ++++++++++++++++++++++++-- src/redux/selectors.js | 20 +++++++- src/redux/store.js | 75 +----------------------------- todo.md | 16 ++++--- 10 files changed, 166 insertions(+), 243 deletions(-) delete mode 100644 scripts/allFileNames.js delete mode 100644 src/Readme.js diff --git a/scripts/allFileNames.js b/scripts/allFileNames.js deleted file mode 100644 index 056b896a..00000000 --- a/scripts/allFileNames.js +++ /dev/null @@ -1,59 +0,0 @@ -var glob = require("glob"); -const path = require("path"); -var { exec } = require("child_process"); -const _ = require("lodash"); - -function allSkinPaths() { - return new Promise((resolve, reject) => { - glob( - path.join( - __dirname, - "../../webamp/experiments/automatedScreenshots/skins/", - "**/*.wsz" - ), - function(err, files) { - if (err != null) { - reject(err); - return; - } - resolve(files); - } - ); - }); -} - -async function filenamesForSkin(skinPath) { - const paths = await new Promise((resolve, reject) => { - exec(`zipinfo -1 ${skinPath}`, function(error, stdout, stderr) { - if (error != null) { - //reject(error); - //return; - } - resolve(stdout); - }); - }); - return paths.split("\n"); -} - -async function allFilenames() { - const skins = await allSkinPaths(); - const paths = _.flatten( - await Promise.all( - skins.map(skin => { - return filenamesForSkin(skin); - }) - ) - ); - - const fileNames = paths.map(p => path.basename(p).toLowerCase()); - const uniqueFileNames = {}; - for (fileName of fileNames) { - uniqueFileNames[fileName] = - uniqueFileNames[fileName] == null ? 1 : uniqueFileNames[fileName] + 1; - } - const entries = Object.entries(uniqueFileNames); - const sorted = _.sortBy(entries, ([filename, count]) => count); - console.log(JSON.stringify(sorted, null, 2)); -} - -allFilenames(); diff --git a/scripts/createSearchIndex.js b/scripts/createSearchIndex.js index ec435a16..1c2f1364 100644 --- a/scripts/createSearchIndex.js +++ b/scripts/createSearchIndex.js @@ -5,6 +5,19 @@ const { getSkinMetadata } = require("./utils"); const client = algoliasearch("HQ9I5Z6IM5", "f5357f4070cdb6ed652d9c3feeede89f"); const index = client.initIndex("Skins"); +function tuncate(str, len) { + const overflow = str.length - len; + if (overflow < 0) { + return str; + } + + const half = Math.floor((len - 1) / 2); + + const start = str.slice(0, half); + const end = str.slice(-half); + return `${start} ########### ${end}`; +} + async function buildSkinIndex(hash) { const textMetadata = await getSkinMetadata(hash, "extracted-data"); return { @@ -12,7 +25,7 @@ async function buildSkinIndex(hash) { md5: hash, fileName: skins[hash].fileName, emails: textMetadata.emails, - readmeText: textMetadata.raw.slice(0, 1000) + readmeText: tuncate(textMetadata.raw, 4800) }; } @@ -24,6 +37,12 @@ const indexesPromise = Promise.all( async function go() { const indexes = await indexesPromise; + const large = indexes.filter(index => { + return index.readmeText.length > 4790; + }); + large.map(l => { + return l.fileName; + }); return new Promise((resolve, reject) => { index.saveObjects(indexes, function(err, content) { @@ -33,4 +52,4 @@ async function go() { }); } -go().then(content => console.log(content)); +go(); // .then(content => console.log("Updated index for:", content.length)); diff --git a/src/App.css b/src/App.css index 4c34d484..46717544 100644 --- a/src/App.css +++ b/src/App.css @@ -146,6 +146,10 @@ body.webamp-loaded #webamp { opacity: 1; } +.skin img { + box-shadow: inset 0px 0px 10px rgba(0, 0, 0, 0.5); +} + .screenshot { height: 100%; opacity: 0; @@ -216,3 +220,17 @@ body.overlay-open .overlay { margin: 80px auto; line-height: 1.4em; } + +.readme { + background: white; +} + +.readme pre { + padding: 10px; + width: 100%; + height: 100%; + white-space: pre-wrap; + margin: 0; + font-size: 12px; + box-sizing: border-box; +} diff --git a/src/FocusedSkin.js b/src/FocusedSkin.js index 95fd6db0..ef0e2a36 100644 --- a/src/FocusedSkin.js +++ b/src/FocusedSkin.js @@ -1,12 +1,12 @@ import React from "react"; import { connect } from "react-redux"; import WebampComponent from "./WebampComponent"; -// import Readme from "./Readme"; +import FileExplorer from "./FileExplorer"; import DownloadLink from "./DownloadLink"; import * as Utils from "./utils"; import * as Selectors from "./redux/selectors"; import * as Actions from "./redux/actionCreators"; -import { SCREENSHOT_HEIGHT, SCREENSHOT_WIDTH } from "./constants"; +import { SCREENSHOT_HEIGHT, SCREENSHOT_WIDTH, SKIN_WIDTH } from "./constants"; import { delay } from "rxjs/operators"; import { Subject, combineLatest, timer, fromEvent } from "rxjs"; import Disposable from "./Disposable"; @@ -136,7 +136,20 @@ class FocusedSkin extends React.Component { loaded={this.handleWebampLoaded} /> - {/**/} + { + + } )}
Download - {"]"} {"["} + {"] ["} + { + this.props.openFileExplorer(); + e.preventDefault(); + }} + > + Readme + + {"] ["} { @@ -234,12 +257,16 @@ class FocusedSkin extends React.Component { const mapStateToProps = state => ({ hash: Selectors.getSelectedSkinHash(state), - initialPosition: Selectors.getSelectedSkinPosition(state) + initialPosition: Selectors.getSelectedSkinPosition(state), + fileExplorerOpen: Selectors.getFileExplorerOpen(state) }); const mapDispatchToProps = dispatch => ({ selectRelativeSkin(offset) { dispatch(Actions.selectRelativeSkin(offset)); + }, + openFileExplorer() { + dispatch(Actions.openFileExplorer()); } }); diff --git a/src/Readme.js b/src/Readme.js deleted file mode 100644 index 0df1c9a5..00000000 --- a/src/Readme.js +++ /dev/null @@ -1,89 +0,0 @@ -import React from "react"; -import { connect } from "react-redux"; -import * as Actions from "./redux/actionCreators"; - -class Readme extends React.Component { - _renderFocusedFile() { - if (this.props.focusedFile == null) { - return; - } - - const { ext, fileName, content } = this.props.focusedFile; - if (content == null) { - return; - } - - switch (ext) { - case "txt": - return ( -