Skip to content

Commit

Permalink
Merge branch 'main' into better-url-working
Browse files Browse the repository at this point in the history
  • Loading branch information
martinthomson authored Aug 6, 2024
2 parents d2111f9 + 1601d51 commit 04851f0
Show file tree
Hide file tree
Showing 9 changed files with 476 additions and 103 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ jobs:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
cache: pip
- run: pip install -r requirements.txt
- run: python ./activities.py validate
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.swp
*~
/venv/
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,9 @@ and limit the discussion in the pull request
to the details of making the change to `activities.json`,
and accurately communicating the consensus in the issue.

Similarly, when changes to a proposal warrant an updated position and
there is sufficient consensus in subsequent comments on the issue,
make a pull request to document that updated consensus by changing `activities.json`.

Tips:
* Specification URLs should link to a living standard or editor’s draft if available.
9 changes: 6 additions & 3 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<!-- Please use only the specification title as the issue title. -->

## Request for Mozilla Position on an Emerging Web Specification

* Specification Title:
* Specification title:
* Specification or proposal URL (if available):
* Explainer URL (if available):
* Explainer URL (if available):
* Proposal author(s) (`@`-mention GitHub accounts):
* Caniuse.com URL (optional):
* Bugzilla URL (optional):
* Mozillians who can provide input (optional):
* Mozillians who can provide input (optional):
* WebKit standards-position:

### Other information

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _See [the dashboard](https://mozilla.github.io/standards-positions/) for Mozilla

This repo is where [Mozilla](https://mozilla.org/) decides and documents what it thinks about
emerging technical specifications for the Web. Typically they're draft documents in the
[IETF](https://ietf.org/), [W3C](https://w3.org/) (including the [WICG](https://wicg.github.io/)),
[IETF](https://ietf.org/), [W3C](https://w3.org/) (including the [WICG](https://wicg.io/)),
[WHATWG](https://whatwg.org/), and [Ecma TC39](https://github.com/tc39), but they could come from
elsewhere too.

Expand Down
449 changes: 380 additions & 69 deletions activities.json

Large diffs are not rendered by default.

53 changes: 34 additions & 19 deletions activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,20 @@ def get_meta(self, spec, names):
Takes a list of names that are tried in sequence; if none are present, None is returned.
"""
try:
name = names.pop(0)
except IndexError:
return None
try:
return spec.head.find("meta", attrs={"name": name})["content"].replace(
"\n", " "
)
except (TypeError, AttributeError):
return self.get_meta(spec, names)
for name in names:
try:
return spec.head.find("meta", attrs={"name": name})["content"].replace(
"\n", " "
)
except (TypeError, AttributeError):
pass
try:
return spec.head.find("meta", attrs={"property": name})[
"content"
].replace("\n", " ")
except (TypeError, AttributeError):
pass
return None

def parse(self, spec, url_string):
url = urlsplit(url_string)
Expand All @@ -510,16 +514,15 @@ def parse(self, spec, url_string):
self.html_url("rfc%s" % identifier.rsplit(":", 1)[1])
)
draft_name, draft_number = self.parse_draft_name(path_components[-1])
if draft_number:
raise BetterUrl(self.html_url(draft_name))
raise BetterUrl(self.html_url(draft_name))
elif path_components[1] in ["id", "pdf"]:
raise BetterUrl(self.html_url(path_components[2]))
else:
raise FetchError("I don't think that's a specification.")
elif url.netloc.lower() == "www.ietf.org" and path_components[1] == "id":
if path_components[1] in ["id", "pdf"]:
if path_components[1] in ["archive", "id", "pdf"]:
try:
draft_name = path_components[2].rsplit(".", 1)[0]
draft_name = path_components[-1].rsplit(".", 1)[0]
except ValueError:
draft_name = path_components[2]
draft_name = self.parse_draft_name(draft_name)[0]
Expand All @@ -528,14 +531,26 @@ def parse(self, spec, url_string):
raise FetchError("I don't think that's a specification.")
elif url.netloc.lower() == "datatracker.ietf.org":
if path_components[1] == "doc":
raise BetterUrl(self.html_url(path_components[2]))
draft_name, draft_number = self.parse_draft_name(path_components[-1])
if draft_number or path_components[2] != "html":
raise BetterUrl(self.html_url(draft_name))
elif path_components[1] in ["archive", "id", "pdf"]:
raise BetterUrl(self.html_url(path_components[-1]))
else:
raise FetchError("I don't think that's a specification.")
data = {}
data["title"] = self.get_meta(spec, ["DC.Title"]) or spec.head.title.string
data["title"] = self.get_meta(
spec, ["og:title", "DC.Title"]
) or spec.head.title.string.replace("\n", " ")
data["description"] = (
self.get_meta(
spec, ["description", "dcterms.abstract", "DC.Description.Abstract"]
spec,
[
"og:description",
"description",
"dcterms.abstract",
"DC.Description.Abstract",
],
)
or ""
)
Expand All @@ -562,8 +577,8 @@ def parse_draft_name(instr):
@staticmethod
def html_url(doc_name):
"Return the canonical URL for a document name."
path = "/".join(["html", doc_name])
return urlunsplit(["https", "tools.ietf.org", path, "", ""])
path = "/".join(["doc", "html", doc_name])
return urlunsplit(["https", "datatracker.ietf.org", path, "", ""])


# Map of URL hostnames to org-specific parsers.
Expand Down
37 changes: 29 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
mask: url(asset/MDN.svg) center no-repeat;
width: 1.20833em;
}

#showall { display: none; }
</style>
</head>
<body>
Expand Down Expand Up @@ -78,6 +80,7 @@ <h1><img src="asset/Mozilla.svg" style="height: 1.04em; vertical-align: -0.23em;
<div>
<a class="btn btn-primary" href="javascript:open_all()">Expand All</a>
<a class="btn btn-primary" href="javascript:close_all()">Collapse All</a>
<a class="btn btn-primary" href="javascript:show_all()" id="showall">Show All</a>
</div>

<table id="mozPositions" class="table table-hover dataTable">
Expand All @@ -104,11 +107,11 @@ <h3>legend</h3>
<p>The possible positions are:</p>

<dl class="dl-horizontal space">
<dt><button class="btn btn-success btn-xs">positive</button></dt><dd>Mozilla regards this work as a potential improvement to the web.</dd>
<dt><button class="btn btn-default btn-xs">neutral</button></dt><dd>Mozilla is not convinced of the merits of this work, but does not see any significant negative potential.</dd>
<dt><button class="btn btn-danger btn-xs">negative</button></dt><dd>Mozilla believes that pursuing this work in its current form would not be good for the web.</dd>
<dt><button class="btn btn-warning btn-xs">defer</button></dt><dd>Mozilla takes no position on this work.</dd>
<dt><button class="btn btn-dark btn-xs">under consideration</button></dt><dd>Mozilla has not taken a position on this work and is gathering more information.</dd>
<dt><button class="btn btn-success btn-xs position">positive</button></dt><dd>Mozilla regards this work as a potential improvement to the web.</dd>
<dt><button class="btn btn-default btn-xs position">neutral</button></dt><dd>Mozilla is not convinced of the merits of this work, but does not see any significant negative potential.</dd>
<dt><button class="btn btn-danger btn-xs position">negative</button></dt><dd>Mozilla believes that pursuing this work in its current form would not be good for the web.</dd>
<dt><button class="btn btn-warning btn-xs position">defer</button></dt><dd>Mozilla takes no position on this work.</dd>
<dt><button class="btn btn-dark btn-xs position">under consideration</button></dt><dd>Mozilla has not taken a position on this work and is gathering more information.</dd>
</dl>

</div>
Expand Down Expand Up @@ -224,16 +227,18 @@ <h3>legend</h3>
"searchable": true
},
{
"name": "mozPosition",
"data": "mozPosition",
"type": "enum-0",
"render": function (data, type, row, meta) {
if (type !== "display") {
return data;
}
if (data !== "" && ! status_styles.hasOwnProperty(data)) {
console.log("WARNING: unrecognised position '" + data + "' on " + row.name)
console.log("WARNING: unrecognised position '" + data + "' on " + row.name);
}
return "<button type='button' class='btn btn-" + status_styles[data] + " btn-xs'>" + data + "</button>"
return "<button type='button' class='btn btn-xs position btn-" + status_styles[data] +
"'>" + data + "</button>";
},
"orderable": true
},
Expand Down Expand Up @@ -329,6 +334,22 @@ <h3>legend</h3>
tr.classList.remove('shown');
}

window.filterPosition = function(e) {
e.preventDefault();
ptable.columns('mozPosition:name').search(e.target.innerText).draw();
// Calling .show() sets display to 'inline', which styles inconsistently.
$('#showall')[0].style.display = 'inline-block';
}
ptable.on('draw', function() {
$('button.position').click(window.filterPosition);
});
window.show_all = function(e) {
$('#mozPositions_filter input')[0].value = '';
// Reset both the global and per-column search.
ptable.search('').column('mozPosition:name').search('').draw();
$('#showall').hide();
}

// Work around bugs in both Chrome and Firefox relating to
// anchor scrolling and :target selection.
$('#mozPositions').on('order.dt', function() {
Expand All @@ -344,7 +365,7 @@ <h3>legend</h3>
}
}, 0);
}
} );
});

window.addEventListener("hashchange", function (event) {
var hash = location.hash.slice(1);
Expand Down
16 changes: 15 additions & 1 deletion pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# $ ln -s ../../hooks/pre-commit .git/pre-commit

root="$(git rev-parse --show-toplevel 2>/dev/null)"
venv="$root/venv"

# Some sanity checking.
hash python3 || exit 1
Expand All @@ -17,14 +18,27 @@ if [[ "$1" == "install" ]]; then
hook="$root"/.git/hooks/pre-commit
if [[ -e "$hook" ]]; then
echo "Hook already installed:"
ls -l "$hook"
ls -l "$hook"
else
ln -s ../../pre-commit "$hook"
echo "Installed git pre-commit hook at $hook"
fi
exit
fi

# venv setup
if [ ! -d "$venv" ]; then
echo "Setting up python venv"
python3 -m venv "$venv"
source "$venv/bin/activate"
pip3 install -r requirements.txt
elif [ requirements.txt -nt "$venv" ]; then
source "$venv/bin/activate"
pip3 install --upgrade --upgrade-stategy eager -r requirements.txt
else
source "$venv/bin/activate"
fi

exec 1>&2

# Perform validation.
Expand Down

0 comments on commit 04851f0

Please sign in to comment.