Skip to content

Commit 5a58e7b

Browse files
committed
Merge branch 'testmode'
2 parents bf0b1d6 + 45f4e12 commit 5a58e7b

File tree

7 files changed

+98
-64
lines changed

7 files changed

+98
-64
lines changed

gulpfile.babel.js

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const rollup = require("rollup").rollup;
1414
const babel = require("rollup-plugin-babel");
1515
const terser = require("rollup-plugin-terser").terser;
1616
const replace = require("rollup-plugin-replace");
17-
const browser = require("browser-sync").create();
17+
const browser = require("browser-sync");
1818
const Vinyl = require("vinyl");
1919
const Buffer = require("buffer").Buffer;
2020
const del = require("del");
@@ -23,6 +23,9 @@ const createHash = require("crypto").createHash;
2323
const fs = require("fs");
2424
const basename = require("path").basename;
2525

26+
let js_file = "regexr.js";
27+
let css_file = "regexr.css";
28+
2629
// constants
2730
const isProduction = () => process.env.NODE_ENV === "production";
2831
const pkg = require("./package.json");
@@ -54,15 +57,14 @@ const serverCopyAndWatchGlob = [
5457

5558
// tasks
5659
gulp.task("serve", () => {
57-
browser.init({
58-
server: {baseDir: "./"},
59-
options: {ignored: "./dev/**/*"}
60+
browser({
61+
server: { baseDir: "./deploy/" },
6062
});
6163
});
6264

6365
gulp.task("watch", () => {
6466
gulp.watch("./dev/src/**/*.js", gulp.series("js", "browserreload"));
65-
gulp.watch("./index.html", gulp.series("browserreload"));
67+
gulp.watch("./index.html", gulp.series("dev-html", "browserreload"));
6668
gulp.watch("./dev/icons/*.svg", gulp.series("icons"));
6769
gulp.watch("./dev/inject/*", gulp.series("inject", "browserreload"));
6870
gulp.watch("./dev/sass/**/*.scss", gulp.series("sass"));
@@ -98,7 +100,7 @@ gulp.task("js", () => {
98100
bundleCache = bundle.cache;
99101
return bundle.write({
100102
format: "iife",
101-
file: "./deploy/regexr.js",
103+
file: `./deploy/${js_file}`,
102104
name: "regexr",
103105
sourcemap: !isProduction()
104106
})
@@ -120,7 +122,7 @@ gulp.task("sass-themes", gulp.parallel(themes.map(theme => `sass-${theme}`)));
120122

121123
const defaultSass = () => {
122124
const str = buildSass("default")
123-
.pipe(rename("regexr.css"))
125+
.pipe(rename(css_file))
124126
.pipe(gulp.dest("deploy"));
125127

126128
return isProduction()
@@ -134,8 +136,8 @@ gulp.task("sass", gulp.series(defaultSass, "sass-themes"));
134136
gulp.task("html", () => {
135137
return gulp.src("./index.html")
136138
.pipe(template({
137-
js_version: createFileHash("deploy/regexr.js"),
138-
css_version: createFileHash("deploy/regexr.css")
139+
js_file,
140+
css_file,
139141
}))
140142
.pipe(htmlmin({
141143
collapseWhitespace: true,
@@ -145,6 +147,29 @@ gulp.task("html", () => {
145147
.pipe(gulp.dest("build"));
146148
});
147149

150+
gulp.task("dev-html", () => {
151+
return gulp.src("./index.html")
152+
.pipe(template({
153+
js_file,
154+
css_file,
155+
}))
156+
.pipe(htmlmin({
157+
collapseWhitespace: true,
158+
conservativeCollapse: true,
159+
removeComments: true
160+
}))
161+
.pipe(gulp.dest("deploy"));
162+
});
163+
164+
165+
gulp.task("createFileHashes", (cb) => {
166+
const js_version = createFileHash(`deploy/regexr.js`);
167+
const css_version = createFileHash("deploy/regexr.css");
168+
js_file = `deploy/${js_version}.js`;
169+
css_file = `deploy/${css_version}.css`;
170+
cb();
171+
});
172+
148173
gulp.task("icons", () => {
149174
return gulp.src("dev/icons/*.svg")
150175
// strip fill attributes and style tags to facilitate CSS styling:
@@ -197,20 +222,38 @@ gulp.task("copy-server", () => {
197222
.pipe(gulp.dest("./build/"));
198223
});
199224

225+
gulp.task("rename-css", () => {
226+
return gulp.src("./build/deploy/regexr.css")
227+
.pipe(rename(basename(css_file)))
228+
.pipe(gulp.dest("./build/deploy/"));
229+
});
230+
231+
gulp.task("rename-js", () => {
232+
return gulp.src("./build/deploy/regexr.js")
233+
.pipe(rename(basename(js_file)))
234+
.pipe(gulp.dest("./build/deploy/"));
235+
});
236+
237+
gulp.task("clean-build", () => {
238+
return del([
239+
"./build/deploy/regexr.*",
240+
]);
241+
})
200242

201243
gulp.task("build", gulp.parallel("js", "sass"));
202244
gulp.task("server", gulp.series("copy-server", "watch-server"));
245+
gulp.task("rename", gulp.parallel("rename-css", "rename-js"));
203246

204247
gulp.task("default",
205-
gulp.series("build",
248+
gulp.series("build","dev-html",
206249
gulp.parallel("serve", "watch")
207250
)
208251
);
209252

210253
gulp.task("deploy",
211254
gulp.series(
212255
cb => (process.env.NODE_ENV = "production") && cb(),
213-
"clean", "build", "html", "copy"
256+
"clean", "build", "createFileHashes", "html", "copy", "rename", "clean-build"
214257
)
215258
);
216259

index.html

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
gtag('config', 'UA-3579542-6');
1414
</script>
1515

16-
<link rel="stylesheet" type="text/css" href="deploy/regexr.css?v=<%= css_version %>">
16+
<link rel="stylesheet" type="text/css" href="<%= css_file %>">
1717

1818
<!-- basic meta tags -->
1919
<meta name="title" content="RegExr: Learn, Build, & Test RegEx" />
@@ -78,7 +78,7 @@
7878
</a></li>
7979
</ul>
8080
</header>
81-
81+
8282
<div class="app">
8383
<aside class="sidebar">
8484
<div class="full">
@@ -117,11 +117,11 @@ <h1 class="label">Menu</h1>
117117
.native-js {
118118
background: linear-gradient(-30deg, #native_bg_color#E5, #native_bg_color#E5 45%, #native_bg_color# 45%) #fff;
119119
}
120-
120+
121121
.native-details {
122122
color: #native_color# !important;
123123
}
124-
124+
125125
.native-details:hover {
126126
color: #native_color_hover# !important;
127127
}
@@ -140,12 +140,12 @@ <h1 class="label">Menu</h1>
140140
</div>
141141
</div>
142142
</div>
143-
143+
144144
<div class="min">
145145
<ul class="list"></ul>
146146
</div>
147147
</aside>
148-
148+
149149
<div class="doc">
150150
<div class="blocker"></div>
151151
<section class="expression">
@@ -166,7 +166,7 @@ <h1>Expression</h1>
166166
</header>
167167
<article class="editor"><svg class="icon alert"><use xlink:href="#alert"></use></svg></article>
168168
</section>
169-
169+
170170
<section class="text">
171171
<header>
172172
<h1>
@@ -204,7 +204,7 @@ <h1>
204204
</div>
205205
</div>
206206
</section>
207-
207+
208208
<section class="tools">
209209
<header>
210210
<h1>Tools</h1>
@@ -224,12 +224,12 @@ <h1>Tools</h1>
224224
</div>
225225
</div>
226226
<div id="library" style="display:none;">
227-
227+
228228
<div id="tooltip" class="tooltip">
229229
<svg class="tip"><use xlink:href="#dropdown"></use></svg>
230230
<div class="content"></div>
231231
</div>
232-
232+
233233
<div id="tooltip-flavor">
234234
<header>
235235
<h1>RegEx Engine</h1>
@@ -238,7 +238,7 @@ <h1>RegEx Engine</h1>
238238
<hr>
239239
<ul class="list"></ul>
240240
</div>
241-
241+
242242
<div id="tooltip-flags">
243243
<header>
244244
<h1>Expression Flags</h1>
@@ -247,11 +247,11 @@ <h1>Expression Flags</h1>
247247
<hr>
248248
<ul class="list"></ul>
249249
</div>
250-
250+
251251
<div id="tooltip-testtypes">
252252
<ul class="list"></ul>
253253
</div>
254-
254+
255255
<div id="tooltip-signin">
256256
<div class="signin">
257257
<header>
@@ -283,7 +283,7 @@ <h1>Sign Out</h1>
283283
One moment...
284284
</div>
285285
</div>
286-
286+
287287
<div id="cheatsheet">
288288
<table class="cheatsheet">
289289
<tr><th colspan="2" data-id="charclasses">Character classes</th></tr>
@@ -293,23 +293,23 @@ <h1>Sign Out</h1>
293293
<tr><td>[abc]</td><td>any of a, b, or c</td></tr>
294294
<tr><td>[^abc]</td><td>not a, b, or c</td></tr>
295295
<tr><td>[a-g]</td><td>character between a & g</td></tr>
296-
296+
297297
<tr><th colspan="2" data-id="anchors">Anchors</th></tr>
298298
<tr><td>^abc$</td><td>start / end of the string</td></tr>
299299
<tr><td>\b \B</td><td>word, not-word boundary</td></tr>
300-
300+
301301
<tr><th colspan="2" data-id="escchars">Escaped characters</th></tr>
302302
<tr><td>\. \* \\</td><td>escaped special characters</td></tr>
303303
<tr><td>\t \n \r</td><td>tab, linefeed, carriage return</td></tr>
304304
<!-- <tr><td>\u00A9</td><td>unicode escaped &copy;</td></tr> -->
305-
305+
306306
<tr><th colspan="2" data-id="groups">Groups & Lookaround</th></tr>
307307
<tr><td>(abc)</td><td>capture group</td></tr>
308308
<tr><td>\1</td><td>backreference to group #1</td></tr>
309309
<tr><td>(?:abc)</td><td>non-capturing group</td></tr>
310310
<tr><td>(?=abc)</td><td>positive lookahead</td></tr>
311311
<tr><td>(?!abc)</td><td>negative lookahead</td></tr>
312-
312+
313313
<tr><th colspan="2" data-id="quants">Quantifiers & Alternation</th></tr>
314314
<tr><td>a* a+ a?</td><td>0 or more, 1 or more, 0 or 1</td></tr>
315315
<tr><td>a{5} a{2,}</td><td>exactly five, two or more</td></tr>
@@ -318,7 +318,7 @@ <h1>Sign Out</h1>
318318
<tr><td>ab|cd</td><td>match ab or cd</td></tr>
319319
</table>
320320
</div>
321-
321+
322322
<div id="community" class="community">
323323
<header>
324324
<div class="label name"></div>
@@ -346,7 +346,7 @@ <h1>Sign Out</h1>
346346
<div class="author"></div>
347347
<hr>
348348
</div>
349-
349+
350350
<div id="share">
351351
<!-- holds all the elements used in the Save & Share section -->
352352
<div id="share_main">
@@ -406,7 +406,7 @@ <h1>Sign Out</h1>
406406
</div>
407407
</div>
408408
</div>
409-
409+
410410
<div id="share_community">
411411
Edit or add extra information to help people find this expression.
412412
<div class="inputs">
@@ -442,8 +442,8 @@ <h1><input type="text" class="name" placeholder="Untitled Test"></input></h1>
442442
</article>
443443
</div>
444444
</div>
445-
446-
<script src="deploy/regexr.js?v=<%= js_version %>"></script>
445+
446+
<script src="<%= js_file %>"></script>
447447
<script id="phpinject">
448448
/** INJECTED BY PHP **/
449449
// first param false indicates a local init.

server/actions/account/login.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,16 @@ public function execute() {
3131
function tryLogin($type) {
3232
$session = new \core\Session($this->db, SESSION_NAME);
3333
$exception = null;
34+
$adapter = null;
3435

3536
$auth = new \core\Authentication();
3637
try {
3738
$adapter = $auth->connect($type);
38-
39-
if (!$adapter->isConnected()) {
40-
$adapter->authenticate();
41-
}
4239
} catch (\Exception $ex) {
4340
$exception = $ex;
4441
}
4542

46-
if ($adapter->isConnected()) {
43+
if (!is_null($adapter) && $adapter->isConnected()) {
4744
$userProfile = null;
4845

4946
try {

server/actions/regex/solve.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function runTests($tests, $pattern, $modifiers, $global, $requestId) {
7979
// Stop capturing warnings.
8080
restore_error_handler();
8181

82-
if ($match === 1) {
82+
if ($match > 0) {
8383
$testResults[] = [
8484
"id" => $id,
8585
"i" => $matches[0][0][1],

server/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"require": {
33
"respect/validation": "1.1.12",
4-
"hybridauth/hybridauth": "v3.0.0-rc.9"
4+
"hybridauth/hybridauth": "v3.2.0"
55
},
66
"require-dev": {
77
}

0 commit comments

Comments
 (0)