chore: updates pages path for posts app 8ae0216c
Steve · 2026-04-08 07:37 4 file(s) · +19 −7
.github/workflows/ci.yml +1 −4
7 7
8 8
jobs:
9 9
  check:
10 -
    name: Check & Build
10 +
    name: Check
11 11
    runs-on: ubuntu-latest
12 12
    steps:
13 13
      - uses: actions/checkout@v6
30 30
31 31
      - name: cargo check
32 32
        run: cargo check --workspace
33 -
34 -
      - name: cargo build
35 -
        run: cargo build --workspace
apps/posts/src/server.rs +16 −1
835 835
    .into_response()
836 836
}
837 837
838 +
const RESERVED_PAGE_SLUGS: &[&str] = &[
839 +
    "posts", "admin", "feed.xml", "custom-styles.css", "static", "files",
840 +
];
841 +
842 +
fn is_reserved_page_slug(slug: &str) -> bool {
843 +
    RESERVED_PAGE_SLUGS.contains(&slug)
844 +
}
845 +
838 846
async fn admin_create_page(
839 847
    _session: auth::AuthSession,
840 848
    State(state): State<Arc<AppState>>,
845 853
    let slug = attrs.slug.trim().to_string();
846 854
    if title.is_empty() || slug.is_empty() {
847 855
        return Redirect::to("/admin/pages/new?error=Title+and+slug+are+required").into_response();
856 +
    }
857 +
    if is_reserved_page_slug(&slug) {
858 +
        return Redirect::to("/admin/pages/new?error=That+slug+is+reserved").into_response();
848 859
    }
849 860
850 861
    match db::create_page(&state.db, &title, &slug, &form.content, attrs.is_published, 0) {
887 898
    let slug = attrs.slug.trim().to_string();
888 899
    if title.is_empty() || slug.is_empty() {
889 900
        return Redirect::to(&format!("/admin/pages/{}/edit?error=Title+and+slug+are+required", short_id))
901 +
            .into_response();
902 +
    }
903 +
    if is_reserved_page_slug(&slug) {
904 +
        return Redirect::to(&format!("/admin/pages/{}/edit?error=That+slug+is+reserved", short_id))
890 905
            .into_response();
891 906
    }
892 907
1234 1249
        .route("/posts", get(public_posts_list))
1235 1250
        .route("/posts/{slug}", get(public_post))
1236 1251
        .route("/custom-styles.css", get(serve_custom_css))
1237 -
        .route("/pages/{slug}", get(public_page))
1252 +
        .route("/{slug}", get(public_page))
1238 1253
        .route("/feed.xml", get(rss_feed))
1239 1254
        // Admin auth
1240 1255
        .route("/admin/login", get(get_login).post(post_login))
apps/posts/templates/admin_pages.html +1 −1
17 17
              <span class="status-badge {% if page.is_published %}status-published{% else %}status-draft{% endif %}">
18 18
                {% if page.is_published %}published{% else %}draft{% endif %}
19 19
              </span>
20 -
              <span class="admin-list-date">/pages/{{ page.slug }}</span>
20 +
              <span class="admin-list-date">/{{ page.slug }}</span>
21 21
              <span class="admin-list-date">order: {{ page.nav_order }}</span>
22 22
            </div>
23 23
          </div>
apps/posts/templates/page.html +1 −1
6 6
  {% else %}
7 7
    <meta property="og:image" content="{{ site_url }}/static/og.png">
8 8
  {% endif %}
9 -
  <meta property="og:url" content="{{ site_url }}/pages/{{ page.slug }}">
9 +
  <meta property="og:url" content="{{ site_url }}/{{ page.slug }}">
10 10
{% endblock %}
11 11
{% block content %}
12 12
  <div class="page-header">