[M] Change in code/re2[abseil]: Give the app a little polish.

1 view
Skip to first unread message

Paul Wankadia (Gerrit)

unread,
Aug 26, 2022, 8:27:02 AM8/26/22
to Paul Wankadia, re2...@googlegroups.com

Paul Wankadia has uploaded this change for review.

View Change

Give the app a little polish.

Change-Id: I884018730d04527e3606696d77a4f88a916c5aa9
---
M app/app.ts
M app/app.yaml
M app/index.html
3 files changed, 94 insertions(+), 103 deletions(-)

diff --git a/app/app.ts b/app/app.ts
index 8f34b9e..4b9e7bd 100644
--- a/app/app.ts
+++ b/app/app.ts
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.

import {css, html, LitElement, render} from 'lit';
-import {customElement, state} from 'lit/decorators.js';
+import {customElement} from 'lit/decorators.js';

import /*default*/ loadModule from './_re2';
import {Info, MainModule} from './_re2';
@@ -16,111 +16,91 @@

@customElement('re2-dev')
export class RE2Dev extends LitElement {
- @state() private _info: Info|null = null;
-
- private _update(pattern: string) {
- if (pattern) {
- this._info = _re2.getInfo(pattern);
- } else {
- this._info = null;
- }
- this.requestUpdate();
- }
+ private _pattern: string = '';
+ private _info: Info|null = null;

constructor() {
super();
- var pattern: string = decodeURIComponent(window.location.hash.slice(1));
- this._update(pattern);
- }
-
- static override styles = css`
- .error {
- color: red;
- font-family: monospace;
- font-weight: bold;
- white-space: pre-line;
- }
-
- .info {
- color: darkgreen;
- font-family: monospace;
- font-weight: bold;
- white-space: pre-line;
- }
- `;
-
- override render() {
- return html`
- <div>
- <input type="text" size="64" @change=${this._onChange}/>
- </div>
- ${this._renderInfo(this._info)}
- `;
+ this._pattern = decodeURIComponent(window.location.hash.slice(1));
+ this._info = this._pattern ? _re2.getInfo(this._pattern) : null;
+ this.requestUpdate();
}

private _onChange = (e: Event) => {
- var pattern: string = (e.target as HTMLInputElement).value;
- this._update(pattern);
- window.location.hash = '#' + encodeURIComponent(pattern);
+ this._pattern = (e.target as HTMLInputElement).value;
+ this._info = this._pattern ? _re2.getInfo(this._pattern) : null;
+ this.requestUpdate();
+ window.location.hash = '#' + encodeURIComponent(this._pattern);
};

- private _renderInfo(info: Info|null) {
- if (info === null) {
- return html`
- `;
- } else if (info.error) {
- return html`
- <div>
- pattern:
- <span class="info">${info.pattern}</span>
- </div>
- <div>
- error:
- <span class="error">${info.error}</span>
- </div>
- `;
- } else {
- return html`
- <div>
- pattern:
- <span class="info">${info.pattern}</span>
- </div>
- <div>
- prefix:
- <span class="info">${info.prefix}</span>
- _foldcase:
- <span class="info">${info.prefix_foldcase}</span>
- </div>
- <div>
- accel_prefix:
- <span class="info">${info.accel_prefix}</span>
- _foldcase:
- <span class="info">${info.accel_prefix_foldcase}</span>
- </div>
- <div>
- num_captures:
- <span class="info">${info.num_captures}</span>
- </div>
- <div>
- is_one_pass:
- <span class="info">${info.is_one_pass}</span>
- </div>
- <div>
- can_bit_state:
- <span class="info">${info.can_bit_state}</span>
- </div>
- <div>
- bytecode:
- <br/>
- <span class="info">${info.bytecode}</span>
- </div>
- <div>
- bytemap:
- <br/>
- <span class="info">${info.bytemap}</span>
- </div>
- `;
+ static override styles = css`
+.code {
+ font-family: monospace;
+ white-space: pre-line;
+}
+`;
+
+ override render() {
+ var fragments = [];
+ fragments.push(html`
+<div>
+ <input type="text" size="48" @change=${this._onChange} .value=${this._pattern}>
+</div>
+`);
+
+ if (this._info === null) {
+ return html`${fragments}`;
}
+
+ if (this._info.error) {
+ fragments.push(html`
+<br>
+<div>
+ error:
+ <span class="code">${this._info.error}</span>
+</div>
+`);
+ return html`${fragments}`;
+ }
+
+ fragments.push(html`
+<br>
+<div>
+ pattern:
+ <span class="code">${this._info.pattern}</span>
+ <br>
+ prefix:
+ <span class="code">${this._info.prefix}</span>
+ ·
+ _foldcase:
+ <span class="code">${this._info.prefix_foldcase}</span>
+ <br>
+ accel_prefix:
+ <span class="code">${this._info.accel_prefix}</span>
+ ·
+ _foldcase:
+ <span class="code">${this._info.accel_prefix_foldcase}</span>
+ <br>
+ num_captures:
+ <span class="code">${this._info.num_captures}</span>
+ <br>
+ is_one_pass:
+ <span class="code">${this._info.is_one_pass}</span>
+ <br>
+ can_bit_state:
+ <span class="code">${this._info.can_bit_state}</span>
+ <br>
+ <br>
+ bytecode:
+ <br>
+ <span class="code">${this._info.bytecode}</span>
+ <br>
+ bytemap:
+ <br>
+ <span class="code">${this._info.bytemap}</span>
+</div>
+`);
+ return html`${fragments}`;
}
}

diff --git a/app/app.yaml b/app/app.yaml
index a45e5b5..62150fb 100644
--- a/app/app.yaml
+++ b/app/app.yaml
@@ -1,12 +1,10 @@
-runtime: python27
-api_version: 1
-threadsafe: true
-
+runtime: python310
handlers:
- url: /
+ secure: always
static_files: deploy/index.html
upload: deploy/index.html
-
- url: /(.*)
+ secure: always
static_files: deploy/\1
upload: deploy/(.*)
diff --git a/app/index.html b/app/index.html
index a0d2100..d229e56 100644
--- a/app/index.html
+++ b/app/index.html
@@ -1 +1,5 @@
-<!DOCTYPE html><meta charset="utf-8"><script type="module" src="app.js"></script>
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>:root { color-scheme: dark light; }</style>
+<script type="module" src="app.js"></script>

To view, visit change 60450. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: re2
Gerrit-Branch: abseil
Gerrit-Change-Id: I884018730d04527e3606696d77a4f88a916c5aa9
Gerrit-Change-Number: 60450
Gerrit-PatchSet: 1
Gerrit-Owner: Paul Wankadia <jun...@google.com>
Gerrit-MessageType: newchange

Perry Lorier (Gerrit)

unread,
Aug 26, 2022, 9:14:33 AM8/26/22
to Paul Wankadia, Randall Bosetti, re2...@googlegroups.com

Attention is currently required from: Paul Wankadia.

Patch set 1:Code-Review +1

View Change

    To view, visit change 60450. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: re2
    Gerrit-Branch: abseil
    Gerrit-Change-Id: I884018730d04527e3606696d77a4f88a916c5aa9
    Gerrit-Change-Number: 60450
    Gerrit-PatchSet: 1
    Gerrit-Owner: Paul Wankadia <jun...@google.com>
    Gerrit-Reviewer: Perry Lorier <per...@google.com>
    Gerrit-CC: Randall Bosetti <r...@google.com>
    Gerrit-Attention: Paul Wankadia <jun...@google.com>
    Gerrit-Comment-Date: Fri, 26 Aug 2022 13:14:29 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Paul Wankadia (Gerrit)

    unread,
    Aug 26, 2022, 9:14:55 AM8/26/22
    to Paul Wankadia, Perry Lorier, Randall Bosetti, re2...@googlegroups.com

    Patch set 1:Code-Review +2

    View Change

      To view, visit change 60450. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: re2
      Gerrit-Branch: abseil
      Gerrit-Change-Id: I884018730d04527e3606696d77a4f88a916c5aa9
      Gerrit-Change-Number: 60450
      Gerrit-PatchSet: 1
      Gerrit-Owner: Paul Wankadia <jun...@google.com>
      Gerrit-Reviewer: Paul Wankadia <jun...@google.com>
      Gerrit-Reviewer: Perry Lorier <per...@google.com>
      Gerrit-CC: Randall Bosetti <r...@google.com>
      Gerrit-Comment-Date: Fri, 26 Aug 2022 13:14:49 +0000

      Paul Wankadia (Gerrit)

      unread,
      Aug 26, 2022, 9:15:00 AM8/26/22
      to Paul Wankadia, Perry Lorier, Randall Bosetti, re2...@googlegroups.com

      Paul Wankadia submitted this change.

      View Change


      Approvals: Paul Wankadia: Looks good to me, approved Perry Lorier: Looks good to me, but someone else must approve
      Give the app a little polish.

      Change-Id: I884018730d04527e3606696d77a4f88a916c5aa9
      Reviewed-on: https://code-review.googlesource.com/c/re2/+/60450
      Reviewed-by: Perry Lorier <per...@google.com>
      Reviewed-by: Paul Wankadia <jun...@google.com>

      ---
      M app/app.ts
      M app/app.yaml
      M app/index.html
      3 files changed, 97 insertions(+), 103 deletions(-)

      To view, visit change 60450. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: re2
      Gerrit-Branch: abseil
      Gerrit-Change-Id: I884018730d04527e3606696d77a4f88a916c5aa9
      Gerrit-Change-Number: 60450
      Gerrit-PatchSet: 2
      Gerrit-Owner: Paul Wankadia <jun...@google.com>
      Gerrit-Reviewer: Paul Wankadia <jun...@google.com>
      Gerrit-Reviewer: Perry Lorier <per...@google.com>
      Gerrit-CC: Randall Bosetti <r...@google.com>
      Gerrit-MessageType: merged
      Reply all
      Reply to author
      Forward
      0 new messages