Skip to content

Commit 95c8590

Browse files
PHP: Update Doctum and theme, add 1.x dev branch
1 parent a80d773 commit 95c8590

20 files changed

Lines changed: 3036 additions & 24033 deletions

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@ jobs:
3131
- name: Clone flarum/framework
3232
run: git clone https://github.com/flarum/framework.git flarum
3333

34-
- name: PHP > Use PHP 7.4
34+
- name: PHP > Use PHP 8.3
3535
if: ${{ matrix.language == 'php' }}
3636
uses: shivammathur/setup-php@v2
3737
with:
38-
php-version: '7.4'
38+
php-version: '8.3'
3939

4040
- name: PHP > Doctum cache
4141
uses: actions/cache@v3
4242
with:
4343
path: cache
4444
key: ${{ runner.os }}-doctum
4545

46-
- name: JS > Use Node.js 16.x
46+
- name: JS > Use Node.js 22.x
4747
if: ${{ matrix.language == 'js' }}
4848
uses: actions/setup-node@v3
4949
with:
50-
node-version: 16.x
50+
node-version: 22.x
5151

5252
- name: JS > Install dependencies
5353
if: ${{ matrix.language == 'js' }}
54-
run: npm ci
54+
run: yarn install --frozen-lockfile
5555

5656
- name: Build
5757
run: ./scripts/build-${{ matrix.language }}.sh

doctum-config.php

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,44 @@
1111
->name('*.php')
1212
->in("$flarum/src");
1313

14+
// Get all tags and find latest minor of each major version
15+
$tags = explode("\n", trim(shell_exec("git -C $flarum tag")));
16+
$latestMinors = [];
17+
18+
foreach ($tags as $tag) {
19+
if (preg_match('/^v?([0-9]+)\.([0-9]+)\.[0-9]+$/', $tag, $matches)) {
20+
$major = $matches[1];
21+
$minor = $matches[2];
22+
$key = "$major.$minor";
23+
24+
// Store or update if this tag is newer
25+
if (!isset($latestMinors[$key]) || version_compare($tag, $latestMinors[$key], '>')) {
26+
$latestMinors[$key] = $tag;
27+
}
28+
}
29+
}
30+
31+
unset($latestMinors['1.0']);
32+
unset($latestMinors['1.1']);
33+
unset($latestMinors['1.2']);
34+
1435
$versions = GitVersionCollection::create($flarum)
15-
->addFromTags(function ($version) {
16-
return preg_match('/^v?([0-9]+)\.([0-9]+)\.0$/', $version) && (preg_match('/^v1\.[0-2]/i', $version) === 0);
17-
})
18-
->add('main', 'main')
36+
->add('1.x', '1.x')
1937
->add('2.x', '2.x');
2038

39+
foreach ($latestMinors as $key => $tag) {
40+
$versions->add($tag, $tag);
41+
}
42+
2143
return new Doctum($iterator, array(
2244
'theme' => 'flarum',
2345
'versions' => $versions,
2446
'title' => 'Flarum API',
2547
'build_dir' => __DIR__ . '/docs/php/%version%/',
2648
'cache_dir' => __DIR__ . '/cache/php/%version%/',
2749
'template_dirs' => array(__DIR__.'/themes/flarum'),
28-
'remote_repository' => new GitHubRemoteRepository('flarum/main', $flarum),
50+
'remote_repository' => new GitHubRemoteRepository('flarum/framework', $flarum),
2951
'default_opened_level' => 1,
30-
'source_url' => 'https://github.com/flarum/main/',
52+
'source_url' => 'https://github.com/flarum/framework/',
3153
'source_dir' => 'src'
3254
));

doctum.phar

183 KB
Binary file not shown.

scripts/build-php.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
source $(dirname $0)/_vars.sh
44

5+
# Clean git state
6+
(cd $FLARUM_PATH && git checkout -q -- . && git clean -f -d)
7+
58
echo -e "${style}Generating $reset"
69

710
php "$REPO_PATH/doctum.phar" update doctum-config.php --force --no-progress --ignore-parse-errors
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ search_index|raw }}

themes/flarum/layout/base.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</head>
3030

3131
{% block html %}
32-
<body id="{% block body_class '' %}" data-name="{% block page_id '' %}" data-root-path="{{ root_path }}">
32+
<body id="{% block body_class '' %}" data-name="{% block page_id '' %}" data-root-path="{{ root_path }}" data-search-index-url="{{ path('doctum-search.json') }}">
3333
{% block content '' %}
3434
</body>
3535
{% endblock %}

themes/flarum/layout/layout.twig

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,29 @@
6565
<form action="#" method="GET">
6666
<select id="version-switcher" class="form-control" name="version">
6767
{% for version in project.versions %}
68-
<option value="{{ path('../' ~ version) }}" data-version="{{ version }}">{{ version.longname }}</option>
68+
<option
69+
value="{{ project.getBaseUrl()|replace({'%version%': version}) ~ '/index.html' }}"
70+
data-version="{{ version }}" {{ version == project.version ? 'selected' : ''}}>{{ version.longname }}</option>
6971
{% endfor %}
7072
</select>
7173
</form>
7274
{% endif %}
7375
<script>
7476
$('option[data-version="'+window.projectVersion+'"]').prop('selected', true);
7577
</script>
78+
7679
<form id="search-form" action="{{ path('search.html') }}" method="GET">
7780
<span class="icon icon-search"></span>
78-
<input name="search" class="typeahead form-control" type="search" placeholder="Search">
81+
<input name="search"
82+
id="doctum-search-auto-complete"
83+
class="typeahead form-control"
84+
type="search"
85+
placeholder="{% trans 'Search' %}"
86+
spellcheck="false"
87+
autocorrect="off"
88+
autocomplete="off"
89+
autocapitalize="off">
90+
<div class="auto-complete-results" id="auto-complete-results"></div>
7991
</form>
8092
</div>
8193
{% endblock %}

themes/flarum/macros.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{%- endmacro %}
66

77
{% macro namespace_link(namespace) -%}
8-
<a href="{{ namespace_path(namespace) }}">{{ namespace|raw }}</a>
8+
<a href="{{ namespace_path(namespace) }}">{{ namespace == '' ? global_namespace_name() : namespace|raw }}</a>
99
{%- endmacro %}
1010

1111
{% macro class_link(class, absolute) -%}

themes/flarum/manifest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ static:
1717
'public/img/flarum_logo.svg': 'assets/img/flarum_logo.svg'
1818
'public/img/code.svg': 'assets/img/code.svg'
1919

20+
'js/autocomplete.min.js': 'js/autocomplete.min.js'
21+
2022
global:
2123
'index.twig': 'index.html'
2224
'doc-index.twig': 'doc-index.html'
@@ -27,6 +29,7 @@ global:
2729
'opensearch.twig': 'opensearch.xml'
2830
'search.twig': 'search.html'
2931
'sami.js.twig': 'sami.js'
32+
'doctum-search.json.twig': 'doctum-search.json'
3033

3134
namespace:
3235
'namespace.twig': '%s.html'

themes/flarum/namespace.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% extends "layout/layout.twig" %}
22
{% from "macros.twig" import breadcrumbs, render_classes, class_link, namespace_link, github_link %}
3-
{% block title %}{{ namespace|raw }} | {{ parent() }}{% endblock %}
3+
{% block title %}{{ namespace == '' ? global_namespace_name() : namespace|raw }} | {{ parent() }}{% endblock %}
44
{% block body_class 'namespace' %}
55
{% block page_id 'namespace:' ~ (namespace|replace({'\\': '_'})) %}
66

@@ -17,9 +17,9 @@
1717

1818
<div class="page-header">
1919
<h1>
20-
{{ namespace|raw }}
20+
{{ namespace == '' ? global_namespace_name() : namespace|raw }}
2121
&nbsp;
22-
{{ github_link(namespace, null, null, true) }}
22+
{{ namespace == '' ? '' : github_link(namespace, null, null, true) }}
2323
</h1>
2424
</div>
2525

0 commit comments

Comments
 (0)