Model-config web apps: describe the app in configuration instead of writing code. Built on Polars and DuckDB.
posts_crud.yaml · 6.6 KB · 264 lines
| 1 | # DBBasic Blog Template - Posts |
| 2 | # A complete blogging platform with content management, SEO, and social features |
| 3 | |
| 4 | resource: posts |
| 5 | database: blog.db |
| 6 | |
| 7 | fields: |
| 8 | id: |
| 9 | type: primary_key |
| 10 | title: |
| 11 | type: string |
| 12 | required: true |
| 13 | searchable: true |
| 14 | max_length: 200 |
| 15 | ui: |
| 16 | placeholder: "Enter an engaging blog post title" |
| 17 | help_text: "Keep it under 60 characters for best SEO" |
| 18 | slug: |
| 19 | type: string |
| 20 | unique: true |
| 21 | max_length: 200 |
| 22 | ui: |
| 23 | help_text: "Auto-generated from title, used in URLs" |
| 24 | content: |
| 25 | type: text |
| 26 | required: true |
| 27 | ui: |
| 28 | component: rich_editor |
| 29 | toolbar: [bold, italic, link, image, code, quote] |
| 30 | height: 400 |
| 31 | excerpt: |
| 32 | type: text |
| 33 | max_length: 500 |
| 34 | ui: |
| 35 | component: textarea |
| 36 | rows: 3 |
| 37 | placeholder: "Brief summary for previews and SEO" |
| 38 | status: |
| 39 | type: select |
| 40 | options: [draft, published, scheduled, archived] |
| 41 | default: draft |
| 42 | required: true |
| 43 | ui: |
| 44 | variant: badge |
| 45 | colors: |
| 46 | draft: secondary |
| 47 | published: success |
| 48 | scheduled: warning |
| 49 | archived: dark |
| 50 | category_id: |
| 51 | type: foreign_key |
| 52 | references: categories |
| 53 | required: true |
| 54 | ui: |
| 55 | component: select |
| 56 | searchable: true |
| 57 | author_id: |
| 58 | type: foreign_key |
| 59 | references: users |
| 60 | required: true |
| 61 | ui: |
| 62 | default_current_user: true |
| 63 | featured_image: |
| 64 | type: file |
| 65 | accept: [jpg, jpeg, png, webp] |
| 66 | max_size: 5MB |
| 67 | ui: |
| 68 | preview: true |
| 69 | aspect_ratio: "16:9" |
| 70 | seo_title: |
| 71 | type: string |
| 72 | max_length: 60 |
| 73 | ui: |
| 74 | help_text: "Custom SEO title (defaults to post title)" |
| 75 | seo_description: |
| 76 | type: string |
| 77 | max_length: 160 |
| 78 | ui: |
| 79 | component: textarea |
| 80 | rows: 2 |
| 81 | help_text: "Meta description for search engines" |
| 82 | tags: |
| 83 | type: many_to_many |
| 84 | references: tags |
| 85 | ui: |
| 86 | component: tag_input |
| 87 | autocomplete: true |
| 88 | view_count: |
| 89 | type: integer |
| 90 | default: 0 |
| 91 | ui: |
| 92 | readonly: true |
| 93 | published_at: |
| 94 | type: timestamp |
| 95 | ui: |
| 96 | component: datetime_picker |
| 97 | help_text: "Leave blank to publish immediately" |
| 98 | created_at: |
| 99 | type: timestamp |
| 100 | auto_now_add: true |
| 101 | updated_at: |
| 102 | type: timestamp |
| 103 | auto_now: true |
| 104 | |
| 105 | # Hooks for automated blog functionality |
| 106 | hooks: |
| 107 | before_create: |
| 108 | - validate_post_content # Check content quality, readability |
| 109 | - generate_slug_from_title # Auto-create URL slug |
| 110 | - extract_excerpt_if_empty # Auto-generate excerpt from content |
| 111 | after_create: |
| 112 | - generate_seo_metadata # Create Open Graph tags, Twitter cards |
| 113 | - create_social_media_posts # Auto-post to configured social accounts |
| 114 | - notify_subscribers # Email notification to blog subscribers |
| 115 | before_update: |
| 116 | - preserve_published_date # Don't change published_at unless status changes |
| 117 | - validate_slug_uniqueness # Ensure slug conflicts don't break URLs |
| 118 | after_update: |
| 119 | - invalidate_post_cache # Clear cached versions |
| 120 | - update_sitemap # Refresh XML sitemap |
| 121 | - reindex_search # Update search index |
| 122 | before_delete: |
| 123 | - check_post_dependencies # Ensure no orphaned comments/references |
| 124 | - backup_post_content # Archive content before deletion |
| 125 | after_delete: |
| 126 | - cleanup_post_assets # Remove uploaded images |
| 127 | - update_category_counts # Recalculate post counts |
| 128 | - purge_cached_content # Remove from all caches |
| 129 | |
| 130 | # Permission system |
| 131 | permissions: |
| 132 | create: authenticated # Any logged-in user can create drafts |
| 133 | read: |
| 134 | published: public # Published posts are public |
| 135 | draft: owner_or_admin # Drafts only visible to author/admin |
| 136 | update: owner_or_admin # Authors can edit their own posts |
| 137 | delete: owner_or_admin # Authors can delete their own posts |
| 138 | |
| 139 | # RESTful API configuration |
| 140 | api: |
| 141 | base_path: /api/posts |
| 142 | enable_bulk: true |
| 143 | enable_export: true |
| 144 | rate_limiting: |
| 145 | read: 1000/hour |
| 146 | write: 100/hour |
| 147 | custom_endpoints: |
| 148 | - path: /published |
| 149 | method: GET |
| 150 | filter: {status: published} |
| 151 | - path: /by-category/{category_slug} |
| 152 | method: GET |
| 153 | join: categories |
| 154 | - path: /{slug}/increment-views |
| 155 | method: POST |
| 156 | action: increment_view_count |
| 157 | |
| 158 | # User interface configuration |
| 159 | interface: |
| 160 | # List view - shows all posts in a manageable table |
| 161 | list_display: [title, author, category, status, view_count, published_at] |
| 162 | list_filters: [status, category_id, author_id, created_at] |
| 163 | search_fields: [title, content, excerpt] |
| 164 | ordering: [-published_at, -created_at] |
| 165 | per_page: 20 |
| 166 | |
| 167 | # Form view - rich content creation interface |
| 168 | form_layout: |
| 169 | - section: "Content" |
| 170 | fields: [title, slug, content, excerpt] |
| 171 | columns: 1 |
| 172 | - section: "Publishing" |
| 173 | fields: [status, category_id, published_at] |
| 174 | columns: 3 |
| 175 | - section: "Media & SEO" |
| 176 | fields: [featured_image, seo_title, seo_description, tags] |
| 177 | columns: 2 |
| 178 | |
| 179 | # Detail view - public blog post display |
| 180 | detail_template: blog_post |
| 181 | detail_layout: |
| 182 | header: [title, author, published_at, category] |
| 183 | content: [featured_image, content] |
| 184 | sidebar: [tags, related_posts, social_share] |
| 185 | footer: [author_bio, comments] |
| 186 | |
| 187 | # Bootstrap UI theme configuration |
| 188 | ui: |
| 189 | theme: bootstrap |
| 190 | variant: blog |
| 191 | |
| 192 | # Component styling |
| 193 | components: |
| 194 | list: |
| 195 | variant: table-striped |
| 196 | hover: true |
| 197 | responsive: true |
| 198 | actions: [view, edit, delete, duplicate] |
| 199 | |
| 200 | form: |
| 201 | variant: horizontal |
| 202 | label_width: 3 |
| 203 | submit_button: |
| 204 | variant: primary |
| 205 | size: lg |
| 206 | text: "Publish Post" |
| 207 | cancel_button: |
| 208 | variant: outline-secondary |
| 209 | text: "Save Draft" |
| 210 | |
| 211 | detail: |
| 212 | variant: article |
| 213 | typography: true |
| 214 | syntax_highlighting: true |
| 215 | social_sharing: [twitter, facebook, linkedin, email] |
| 216 | |
| 217 | # Layout configuration |
| 218 | layout: |
| 219 | container: true |
| 220 | sidebar: true |
| 221 | header_nav: true |
| 222 | footer: true |
| 223 | |
| 224 | # Custom CSS classes |
| 225 | css_classes: |
| 226 | post_title: "display-4 font-weight-bold" |
| 227 | post_meta: "text-muted small" |
| 228 | post_content: "lead" |
| 229 | category_badge: "badge badge-primary" |
| 230 | tag_badge: "badge badge-outline-secondary" |
| 231 | |
| 232 | # SEO and social media integration |
| 233 | seo: |
| 234 | auto_generate: true |
| 235 | title_template: "{title} | My Awesome Blog" |
| 236 | description_template: "{excerpt}" |
| 237 | |
| 238 | open_graph: |
| 239 | type: article |
| 240 | image: "{featured_image}" |
| 241 | locale: en_US |
| 242 | |
| 243 | twitter_card: |
| 244 | type: summary_large_image |
| 245 | site: "@myblog" |
| 246 | |
| 247 | structured_data: |
| 248 | type: BlogPosting |
| 249 | author: "{author.name}" |
| 250 | publisher: "My Awesome Blog" |
| 251 | |
| 252 | # Analytics and tracking |
| 253 | analytics: |
| 254 | track_views: true |
| 255 | track_reading_time: true |
| 256 | track_social_shares: true |
| 257 | track_user_engagement: true |
| 258 | |
| 259 | # Related content |
| 260 | recommendations: |
| 261 | enable: true |
| 262 | algorithm: content_similarity |
| 263 | max_results: 5 |
| 264 | factors: [category, tags, author] |