Skip to content

Commit

Permalink
Merge pull request #17 from rosswintle/pr/14-1
Browse files Browse the repository at this point in the history
Add additional features - copy of PR/14
  • Loading branch information
rosswintle authored May 2, 2022
2 parents f677830 + fd45864 commit 1a6eac3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PHP features are listed in `features.js`. Hopefully the format of this makes sen
* the whole thing is a JSON array
* each entry is an object with the following properties:
* `name`: The name of the feature - plain text only
* `description`: A description of the feature - HTML is allowed, but may not be styled. `<code>` tags are fine.
* `description`: A description of the feature - HTML is allowed, but may not be styled. `<code>` tags are fine and backticks will be converted to code tags.
* `keywords`: An array of strings. These are used when searching, so add strings that people may use to search for this feature.
* `added`: A string for the version of PHP that the feature was added. Must be in the format `X.Y`, e.g. `7.0`. Use `0.0` if this is not known or appropriate.
* `deprecated`: A string for the version of PHP that the feature was deprecated. Must be in the format `X.Y`, e.g. `8.0`. Use `null` if this is not know or appropriate.
Expand Down
58 changes: 34 additions & 24 deletions features.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
const features = [
{
name: 'Fibers (Fiber class, Fiber exceptions)',
description: 'Lightweight concurrency for PHP. Fibers represent full-stack, interruptible functions. Fibers may be suspended from anywhere in the call-stack, pausing execution within the fiber until the fiber is resumed at a later time.',
keywords: [
'class', 'types', 'functionality', 'concurrency', 'interruptible', 'functions'
],
added: '8.1',
deprecated: null,
removed: null,
resources: [
{
name: 'PHP.Watch Introduction to Fibers (php.watch)',
url: 'https://php.watch/versions/8.1/fibers'
}, {
name: 'Fibres overview and documentation (php.net)',
url: 'https://www.php.net/manual/en/language.fibers.php'
}
]
},
{
name: 'Enums',
description: 'Enums are a way to define a set of named constants.',
Expand Down Expand Up @@ -544,51 +563,42 @@ const features = [
]
},
{
name: 'FILTER_FLAG_SCHEME_REQUIRED',
description: 'Filter flag for `filter_var()`',
name: 'FILTER_FLAG_SCHEME_REQUIRED constant',
description: 'Filter flag for `filter_var()` for use with `FILTER_VALIDATE_URL`',
keywords: [
'filter', 'constant', 'deprecated', 'removed'
'filters', 'constants', 'deprecated', 'removed', 'urls', 'validation'
],
added: '0.0',
deprecated: '7.3.0',
removed: '8.0',
resources: [
{
name: 'Validate filters',
name: 'Validate filters (php.net)',
url: 'https://www.php.net/manual/en/filter.filters.validate.php'
},
{
name: 'Filter flags (php.net)',
url: 'https://www.php.net/manual/en/filter.filters.flags.php'
}
]
},
{
name: 'FILTER_FLAG_HOST_REQUIRED',
description: 'Filter flag for `filter_var()`',
name: 'FILTER_FLAG_HOST_REQUIRED constant',
description: 'Filter flag for `filter_var()` for use with `FILTER_VALIDATE_URL`',
keywords: [
'filter', 'constant', 'deprecated', 'removed'
'filters', 'constants', 'deprecated', 'removed', 'urls', 'validation'
],
added: '0.0',
deprecated: '7.3.0',
removed: '8.0',
resources: [
{
name: 'Validate filters',
name: 'Validate filters (php.net)',
url: 'https://www.php.net/manual/en/filter.filters.validate.php'
}
]
},
{
name: 'Fibers (Fiber class, Fiber exceptions)',
description: 'Lightweight concurrency for PHP',
keywords: [
'class', 'types', 'new feature', 'functionality', 'concurrency'
],
added: '8.1',
resources: [
},
{
name: 'PHP.Watch Introduction to Fibers',
url: 'https://php.watch/versions/8.1/fibers'
}, {
name: 'PHP Documentation',
url: 'https://www.php.net/manual/en/language.fibers.php'
name: 'Filter flags (php.net)',
url: 'https://www.php.net/manual/en/filter.filters.flags.php'
}
]
}
Expand Down
12 changes: 11 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h2 x-text="feature.name" class="text-lg mb-4 font-bold"></h2>
<div class="flex">
<!-- Feature top panel, left column -->
<div class="w-3/4 pr-4">
<p x-html="feature.description" class="mb-6"></p>
<p x-html="formatAsHtml(feature.description)" class="mb-6"></p>
<h3 class="font-bold text-l mb-2">Resources</h3>
<ul x-show="feature?.resources?.length > 0" class="list-disc list-inside text-sm mb-4">
<template x-for="resource in feature.resources">
Expand Down Expand Up @@ -184,6 +184,16 @@ <h3 class="font-bold text-l mb-2">Resources</h3>
featuresHaving(featureKeyword) {
const versions = features.filter(feature => this.featureMatches(feature, featureKeyword));
return versions;
},

/*
* This does some basic formatting.
*
* - backticks are converted to <code></code>
*/
formatAsHtml(rawString) {
htmlString = rawString.replace(/`(.*?)`/g, '<code>$1</code>');
return htmlString;
}
}
});
Expand Down

0 comments on commit 1a6eac3

Please sign in to comment.