Skip to content

Commit

Permalink
Turn the Blueprints Gallery more visible by making it a table
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Mar 20, 2024
1 parent dbf20b6 commit aef74ff
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ Ready to jump in?
* Browse Blueprints – See the current list of available Blueprints below.
* Create your first Blueprint – Get started by following the official guide on creating Blueprints.

## Available Blueprints
## Blueprints Gallery

* Latest Gutenberg plugin – [Preview](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/adamziel/blueprints/trunk/v1-examples/latest-gutenberg/blueprint.json) | [Source](https://github.com/adamziel/blueprints/blob/trunk/v1-examples/latest-gutenberg/blueprint.json)
> :information_source: Here's a list of all the Blueprints submitted to this repository:
| Title | Preview | Source |
| ----- | ------- | ------ |
| Latest Gutenberg plugin | [Preview](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/adamziel/blueprints/trunk/v1-examples/latest-gutenberg/blueprint.json) | [Source](https://github.com/adamziel/blueprints/blob/trunk/v1-examples/latest-gutenberg/blueprint.json) |

## Contributing your Blueprint

Expand Down Expand Up @@ -61,10 +64,6 @@ Here's an example:
}
```

## Important – Version 2 of Blueprints

It's important to note that [Version 2 of Blueprints](https://github.com/WordPress/blueprints/issues/6) is currently under discussion. While we're excited to launch this v1 community space to gather feedback, this feedback will directly inform the development of v2. Rest assured, all v1 Blueprints will continue to function even after the v2 rollout.

### Developer Tools

If you use an IDE like VSCode or PHPStorm, use the Blueprint JSON Schema for an autocompleted Blueprint development experience. Simply add the following line at the top of your blueprint.json file:
Expand All @@ -75,6 +74,10 @@ If you use an IDE like VSCode or PHPStorm, use the Blueprint JSON Schema for an
}
```

## Important – Version 2 of Blueprints

It's important to note that [Version 2 of Blueprints](https://github.com/WordPress/blueprints/issues/6) is currently under discussion. While we're excited to launch this v1 community space to gather feedback, this feedback will directly inform the development of v2. Rest assured, all v1 Blueprints will continue to function even after the v2 rollout.

## Needing Help?

If you have questions or need assistance, feel free to start a new issue in this repository: @TODO.
Expand Down
6 changes: 4 additions & 2 deletions README.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ Ready to jump in?
* Browse Blueprints – See the current list of available Blueprints below.
* Create your first Blueprint – Get started by following the official guide on creating Blueprints.

## Available Blueprints
## Blueprints Gallery

{BLUEPRINTS_LIST}
> :information_source: Here's a list of all the Blueprints submitted to this repository:

{BLUEPRINTS_TABLE}

## Contributing your Blueprint

Expand Down
42 changes: 33 additions & 9 deletions make_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,44 @@ def build_json_index():

build_json_index()

def build_markdown_index():
def build_markdown_table():
with open('index.json', 'r') as f:
index = json.load(f)
blueprints_list = []
# blueprints_list = []
# for path, meta in index.items():
# blueprints_list.append('* {0} – [Preview]({1}) | [Source]({2})\n'.format(
# meta.get('title', ''),
# 'https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/adamziel/blueprints/trunk/' + path,
# 'https://github.com/adamziel/blueprints/blob/trunk/' + path
# ))
blueprints_rows = [
['Title', 'Preview', 'Source']
]
for path, meta in index.items():
blueprints_list.append('* {0} – [Preview]({1}) | [Source]({2})\n'.format(
blueprints_rows.append([
meta.get('title', ''),
'https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/adamziel/blueprints/trunk/' + path,
'https://github.com/adamziel/blueprints/blob/trunk/' + path
))
# Replace "{BLUEPRINTS_LIST}" in README.md.template and save to README.md
'[Preview](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/adamziel/blueprints/trunk/{0})'.format(path),
'[Source](https://github.com/adamziel/blueprints/blob/trunk/{0})'.format(path)
])

widths = [max(map(len, col)) for col in zip(*blueprints_rows)]

def format_row(row):
formatted_row = ' | '.join((val.ljust(width) for val, width in zip(row, widths)))
return '| ' + formatted_row + ' |'

formatted_rows = [
format_row(blueprints_rows[0]),
format_row(['-' * len(cell) for cell in blueprints_rows[0]])
]
for row in blueprints_rows[1:]:
formatted_rows.append(format_row(row))
formatted_table = '\n'.join(formatted_rows)

# Replace "{BLUEPRINTS_TABLE}" in README.md.template and save to README.md
with open('README.md.template', 'r') as f:
template = f.read()
with open('README.md', 'w') as f:
f.write(re.sub(r'{BLUEPRINTS_LIST}', ''.join(blueprints_list), template))
f.write(re.sub(r'{BLUEPRINTS_TABLE}', ''.join(formatted_table), template))

build_markdown_index()
build_markdown_table()

0 comments on commit aef74ff

Please sign in to comment.