diff --git a/README_BOOK_CATALOG.md b/README_BOOK_CATALOG.md deleted file mode 100644 index 12f1ff3..0000000 --- a/README_BOOK_CATALOG.md +++ /dev/null @@ -1,155 +0,0 @@ -# Book Catalog Example - -A complete example demonstrating the sqlite-serve module with a read-only book catalog. - -## Features - -- **SQLite Database**: Stores book information (title, author, ISBN, year, genre, description, rating) -- **Multiple Views**: Different locations for browsing by category -- **Template Inheritance**: Global templates (header, footer, book_card) shared across all pages -- **Local Templates**: Category-specific styling and layouts -- **Responsive Design**: Modern, gradient-styled UI - -## Setup - -### 1. Create and populate the database - -```bash -chmod +x setup_book_catalog.sh -./setup_book_catalog.sh -``` - -This creates `book_catalog.db` with 10 sample technical books across three genres: -- Programming -- Databases -- Computer Science - -### 2. Build the module - -```bash -direnv exec "$PWD" cargo build -``` - -### 3. Start nginx - -```bash -./ngx_src/nginx-1.28.0/objs/nginx -c conf/book_catalog.conf -p . -``` - -### 4. Visit the catalog - -Open your browser to: -- http://localhost:8080/ (redirects to all books) -- http://localhost:8080/books/all -- http://localhost:8080/books/programming -- http://localhost:8080/books/databases -- http://localhost:8080/books/computer-science - -### 5. Stop nginx - -```bash -./ngx_src/nginx-1.28.0/objs/nginx -s stop -c conf/book_catalog.conf -p . -``` - -## Directory Structure - -``` -sqlite-serve/ -├── book_catalog.db # SQLite database -├── setup_book_catalog.sh # Database setup script -├── conf/ -│ └── book_catalog.conf # Nginx configuration -└── server_root/ - ├── global_templates/ # Shared templates - │ ├── header.hbs # Page header with navigation - │ ├── footer.hbs # Page footer - │ └── book_card.hbs # Reusable book card partial - └── books/ - ├── all/ - │ └── list.hbs # All books page - ├── programming/ - │ └── list.hbs # Programming books page - ├── databases/ - │ └── list.hbs # Database books page - └── computer-science/ - └── list.hbs # CS books page -``` - -## How It Works - -### Template Loading Order - -For each request, the module: - -1. **Loads global templates** from `server_root/global_templates/`: - - `header.hbs` - Page structure and navigation - - `footer.hbs` - Page footer - - `book_card.hbs` - Book display component - -2. **Loads local templates** from the location's directory: - - Each category has its own `list.hbs` with custom styling - - Local templates can override global ones - -3. **Renders the main template** with SQL query results - -### Template Usage - -**In list.hbs:** -```handlebars -{{> header}} - -
- {{#each results}} - {{> book_card}} - {{/each}} -
- -{{> footer}} -``` - -The `{{> header}}`, `{{> book_card}}`, and `{{> footer}}` are partials loaded from the global templates directory. - -### SQL Queries - -Each location runs a different SQL query: - -- **All books**: `SELECT * FROM books ORDER BY rating DESC, title` -- **Programming**: `SELECT * FROM books WHERE genre = 'Programming' ...` -- **Databases**: `SELECT * FROM books WHERE genre = 'Databases' ...` -- **Computer Science**: `SELECT * FROM books WHERE genre = 'Computer Science' ...` - -Results are passed to the template as a `results` array. - -## Customization - -### Adding More Books - -```bash -sqlite3 book_catalog.db -``` - -```sql -INSERT INTO books (title, author, isbn, year, genre, description, rating) -VALUES ('Your Book', 'Author Name', '978-XXXXXXXXXX', 2024, 'Programming', 'Description here', 4.5); -``` - -### Adding New Categories - -1. Create a new genre in the database -2. Add a location block in `book_catalog.conf` -3. Create a template directory under `server_root/books/` -4. Add the category to the navigation in `header.hbs` - -### Styling - -Each category's `list.hbs` contains embedded CSS. Modify the ` - -
-
-

📚

-

Book Collection

-
-
-

-

Top Rated

-
-
-

🔍

-

Browse All

-
-
- -

All Books in Collection

- -
- {{#each results}} - {{> book_card}} - {{/each}} -
- -{{> footer}} - diff --git a/server_root/books/computer-science/list.hbs b/server_root/books/computer-science/list.hbs deleted file mode 100644 index 0e686b8..0000000 --- a/server_root/books/computer-science/list.hbs +++ /dev/null @@ -1,107 +0,0 @@ -{{> header}} - - - -
-

🎓 Computer Science Books

-

Fundamental concepts, algorithms, and theoretical computer science

-
- -
- {{#each results}} - {{> book_card}} - {{/each}} -
- -{{#unless results}} -

No computer science books found.

-{{/unless}} - -{{> footer}} - diff --git a/server_root/books/databases/list.hbs b/server_root/books/databases/list.hbs deleted file mode 100644 index a8aad8b..0000000 --- a/server_root/books/databases/list.hbs +++ /dev/null @@ -1,107 +0,0 @@ -{{> header}} - - - -
-

🗄️ Database Books

-

Deep dive into database systems, design, and data management

-
- -
- {{#each results}} - {{> book_card}} - {{/each}} -
- -{{#unless results}} -

No database books found.

-{{/unless}} - -{{> footer}} - diff --git a/server_root/books/programming/list.hbs b/server_root/books/programming/list.hbs deleted file mode 100644 index 4c6ce74..0000000 --- a/server_root/books/programming/list.hbs +++ /dev/null @@ -1,107 +0,0 @@ -{{> header}} - - - -
-

💻 Programming Books

-

Books focused on programming languages, practices, and software development

-
- -
- {{#each results}} - {{> book_card}} - {{/each}} -
- -{{#unless results}} -

No programming books found.

-{{/unless}} - -{{> footer}} - diff --git a/server_root/global_templates/book_card.hbs b/server_root/global_templates/book_card.hbs deleted file mode 100644 index fcb32de..0000000 --- a/server_root/global_templates/book_card.hbs +++ /dev/null @@ -1,16 +0,0 @@ -
-
-

{{title}}

-
⭐ {{rating}}
-
-

by {{author}}

-

{{description}}

-
- {{genre}} - {{year}} - {{#if isbn}} - ISBN: {{isbn}} - {{/if}} -
-
- diff --git a/server_root/global_templates/footer.hbs b/server_root/global_templates/footer.hbs deleted file mode 100644 index 156cf94..0000000 --- a/server_root/global_templates/footer.hbs +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/server_root/global_templates/header.hbs b/server_root/global_templates/header.hbs deleted file mode 100644 index 587eeaf..0000000 --- a/server_root/global_templates/header.hbs +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - Book Catalog - - - -
-
-

📚 Book Catalog

-

Explore our collection of technical books

-
- -
- diff --git a/server_root/list.hbs b/server_root/list.hbs deleted file mode 100644 index 9ee6ddb..0000000 --- a/server_root/list.hbs +++ /dev/null @@ -1,122 +0,0 @@ -{{> header}} - - - -
-
-

📚

-

Book Collection

-
-
-

-

Top Rated

-
-
-

🔍

-

Browse All

-
-
- -

All Books in Collection

- -
- {{#each results}} - {{> book_card}} - {{/each}} -
- -{{> footer}} - diff --git a/server_root/people/person.hbs b/server_root/people/person.hbs deleted file mode 100644 index bcfa982..0000000 --- a/server_root/people/person.hbs +++ /dev/null @@ -1,4 +0,0 @@ -