-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
508 changed files
with
5,499 additions
and
18,165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
contact_links: | ||
- name: Blockly Forum | ||
- name: Ask a question ❓ | ||
url: https://groups.google.com/forum/#!forum/blockly | ||
about: The Blockly developer forum, where you can ask and answer questions. | ||
- name: Plugins and examples | ||
about: Go to the Blockly developer forum, where you can ask and answer questions. | ||
- name: Report issues with plugins and examples 🧩 | ||
url: https://github.com/google/blockly-samples/issues/new/choose | ||
about: File bugs or feature requests about plugins and samples in our blockly-samples repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
name: Welcome new contributors | ||
jobs: | ||
welcome: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- uses: actions/first-interaction@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
pr-message: > | ||
Welcome! It looks like this is your first pull request in Blockly, | ||
so here are a couple of tips: | ||
- You can find tips about contributing to Blockly and how to | ||
validate your changes on our | ||
[developer site](https://developers.google.com/blockly/guides/contribute/core#making_and_verifying_a_change). | ||
- All contributors must sign the Google Contributor License | ||
Agreement (CLA). If the google-cla bot leaves a comment on this | ||
PR, make sure you follow the instructions. | ||
- We use [conventional commits](https://www.conventionalcommits.org/) | ||
to make versioning the package easier. Make sure your commit | ||
message is in the [proper format](https://developers.google.com/blockly/guides/contribute/get-started/commits) | ||
or [learn how to fix it](https://developers.google.com/blockly/guides/contribute/get-started/commits#fixing_non-conventional_commits). | ||
- If any of the other checks on this PR fail, you can click on | ||
them to learn why. It might be that your change caused a test | ||
failure, or that you need to double-check the | ||
[style guide](https://developers.google.com/blockly/guides/contribute/core/style_guide). | ||
Thank you for opening this PR! A member of the Blockly team will review it soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,15 +15,15 @@ | |
limitations under the License. | ||
""" | ||
|
||
"""Store and retrieve XML with App Engine. | ||
"""Store and retrieve Blockly XML/JSON with App Engine. | ||
""" | ||
|
||
__author__ = "[email protected] (Quynh Neutron)" | ||
|
||
import cgi | ||
import hashlib | ||
from random import randint | ||
from google.cloud import ndb | ||
from random import randint | ||
from urllib.parse import unquote | ||
|
||
|
||
class Xml(ndb.Model): | ||
|
@@ -32,6 +32,7 @@ class Xml(ndb.Model): | |
xml_content = ndb.TextProperty() | ||
last_accessed = ndb.DateTimeProperty(auto_now=True) | ||
|
||
|
||
def keyGen(): | ||
# Generate a random string of length KEY_LEN. | ||
KEY_LEN = 6 | ||
|
@@ -40,8 +41,23 @@ def keyGen(): | |
return "".join([CHARS[randint(0, max_index)] for x in range(KEY_LEN)]) | ||
|
||
|
||
# Parse POST data (e.g. a=1&b=2) into a dictionary (e.g. {"a": 1, "b": 2}). | ||
# Very minimal parser. Does not combine repeated names (a=1&a=2), ignores | ||
# valueless names (a&b), does not support isindex or multipart/form-data. | ||
def parse_post(environ): | ||
fp = environ["wsgi.input"] | ||
data = fp.read().decode() | ||
parts = data.split("&") | ||
dict = {} | ||
for part in parts: | ||
tuple = part.split("=", 1) | ||
if len(tuple) == 2: | ||
dict[tuple[0]] = unquote(tuple[1]) | ||
return dict | ||
|
||
|
||
def xmlToKey(xml_content): | ||
# Store XML and return a generated key. | ||
# Store XML/JSON and return a generated key. | ||
xml_hash = int(hashlib.sha1(xml_content.encode("utf-8")).hexdigest(), 16) | ||
xml_hash = int(xml_hash % (2 ** 64) - (2 ** 63)) | ||
client = ndb.Client() | ||
|
@@ -65,7 +81,7 @@ def xmlToKey(xml_content): | |
|
||
|
||
def keyToXml(key_provided): | ||
# Retrieve stored XML based on the provided key. | ||
# Retrieve stored XML/JSON based on the provided key. | ||
# Normalize the string. | ||
key_provided = key_provided.lower().strip() | ||
# Check datastore for a match. | ||
|
@@ -80,20 +96,30 @@ def keyToXml(key_provided): | |
with client.context(): | ||
result.put() | ||
xml = result.xml_content | ||
# Add a poison line to prevent raw content from being served. | ||
xml = "{[(< UNTRUSTED CONTENT >)]}\n" + xml | ||
return xml | ||
|
||
|
||
def app(environ, start_response): | ||
forms = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) | ||
headers = [ | ||
("Content-Type", "text/plain") | ||
] | ||
if environ["REQUEST_METHOD"] != "POST": | ||
start_response("405 Method Not Allowed", headers) | ||
return ["Storage only accepts POST".encode("utf-8")] | ||
if ("CONTENT_TYPE" in environ and | ||
environ["CONTENT_TYPE"] != "application/x-www-form-urlencoded"): | ||
start_response("405 Method Not Allowed", headers) | ||
return ["Storage only accepts application/x-www-form-urlencoded".encode("utf-8")] | ||
|
||
forms = parse_post(environ) | ||
if "xml" in forms: | ||
out = xmlToKey(forms["xml"].value) | ||
out = xmlToKey(forms["xml"]) | ||
elif "key" in forms: | ||
out = keyToXml(forms["key"].value) | ||
out = keyToXml(forms["key"]) | ||
else: | ||
out = "" | ||
|
||
headers = [ | ||
("Content-Type", "text/plain") | ||
] | ||
start_response("200 OK", headers) | ||
return [out.encode("utf-8")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.