Skip to content

issue-56: Improve template preview#68

Merged
NicolasCARPi merged 9 commits into
masterfrom
toan-2026-01-12-fix-issue-56
Jan 19, 2026
Merged

issue-56: Improve template preview#68
NicolasCARPi merged 9 commits into
masterfrom
toan-2026-01-12-fix-issue-56

Conversation

@toan-nsc
Copy link
Copy Markdown
Contributor

@toan-nsc toan-nsc commented Jan 16, 2026

Closes #56
image
image
image

Summary by CodeRabbit

  • New Features
    • Added content moderation system: admins can now review, approve, reject, or flag records through a dedicated moderation queue with history tracking.
    • Restructured record display with improved metadata organization into logical sections: common info, main content, and extra fields.
    • Added record status indicators in user profiles showing approval status (Pending, Approved, Rejected).
    • Enhanced metadata rendering with improved visibility of datasets, comments, and organizational information.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

A major PR introducing a moderation system with database schema and API handlers, restructuring Go data models, implementing comprehensive RO-Crate metadata extraction and rendering via JavaScript, and updating record queries to enforce moderation status filtering.

Changes

Cohort / File(s) Summary
Moderation Backend
src/moderation.go, src/moderation_handler.go, src/sql/006_add_moderation.up.sql, src/sql/006_add_moderation.down.sql
New moderation subsystem with ModerationStatus types, ModerationAction tracking, PostgresModerationRepository for status and action persistence, HTTP handlers for queue display and record moderation via API, and SQL migrations to add moderation_status column and moderation_actions table with indexes.
Data Model Refactor
src/main.go, src/model.go
Moved core data structures (Record, RecordHistory, Category, User, App, page data types) from main.go to new model.go file; added admin capability detection to getProfile; wired moderation routes and repositories in main.
Record Data Extraction & Rendering
src/record-extractor.js, src/index.js, src/main.css
New record-extractor.js module with comprehensive RO-Crate parsing (metadata extraction, entity resolution, HTML rendering); enhanced index.js with structured record view rendering, moderation UI handlers, dataset/comment/organization card rendering, and fallback data support; minimal CSS cleanup for section dividers.
Record Query & Filtering
src/record_repository.go
Extended all paginated retrieval methods (GetAllPaginated, GetAllByCategoriesPaginated, GetAllByRorIDsPaginated, GetAllByOrcidPaginated, SearchPaginated) to filter by moderation_status = 'approved'; added initial moderation status assignment on record creation.
Template & UI Updates
src/templates/moderation.html, src/templates/profile.html, src/templates/record.html
New moderation.html queue interface with record cards, action buttons, and moderation history table; profile.html adds admin-only Moderation Queue link and per-entry Status column with moderation badges; record.html replaces header structure with modular Common Info, Main Text, and Extra Fields containers populated by extracted metadata.

Sequence Diagram(s)

sequenceDiagram
    actor Admin
    participant Browser
    participant ModerationHandler
    participant ModerationRepository
    participant Database

    Admin->>Browser: Click approve/reject button
    Browser->>ModerationHandler: POST /api/v1/moderation/{id}<br/>(action, reason)
    ModerationHandler->>ModerationHandler: Verify admin session
    ModerationHandler->>ModerationRepository: SetRecordStatus(recordId, status)
    ModerationRepository->>Database: UPDATE records SET moderation_status
    Database-->>ModerationRepository: Status updated
    ModerationHandler->>ModerationRepository: LogModerationAction(action)
    ModerationRepository->>Database: INSERT moderation_actions
    Database-->>ModerationRepository: Action logged
    ModerationHandler-->>Browser: JSON response {status}
    Browser->>Browser: Show toast notification
    Browser->>Browser: Reload page
Loading
sequenceDiagram
    participant Browser
    participant RecordTemplate
    participant IndexJS
    participant RecordExtractor
    participant DOM

    RecordTemplate->>Browser: Load with ro-crate-data & fallback-data
    Browser->>IndexJS: Execute initializeRoCrateViewer()
    IndexJS->>RecordExtractor: extractRecordData(roCrateData)
    RecordExtractor->>RecordExtractor: Parse entities, resolve authors,<br/>extract metadata fields
    RecordExtractor-->>IndexJS: Structured data {commonInfo,<br/>mainText, extraFields}
    IndexJS->>IndexJS: applyFallbackData(extracted, fallback)
    IndexJS->>DOM: renderCommonInfoBlock()
    IndexJS->>DOM: renderMainTextBlock()
    IndexJS->>DOM: renderExtraFieldsBlock()
    IndexJS->>DOM: renderOtherMetadata()
    DOM-->>Browser: Populated containers display
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 A moderation hop through the data,
Records sorted—approved or flagged,
RO-Crates unwrapped with care divine,
Extractors and handlers now align,
Admin powers guard what's shipped—hooray! 🎪



📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between faae64a and 54ad8e1.

📒 Files selected for processing (13)
  • src/index.js
  • src/main.css
  • src/main.go
  • src/model.go
  • src/moderation.go
  • src/moderation_handler.go
  • src/record-extractor.js
  • src/record_repository.go
  • src/sql/006_add_moderation.down.sql
  • src/sql/006_add_moderation.up.sql
  • src/templates/moderation.html
  • src/templates/profile.html
  • src/templates/record.html

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@toan-nsc toan-nsc requested a review from NicolasCARPi January 16, 2026 11:07
@NicolasCARPi NicolasCARPi merged commit 13f837c into master Jan 19, 2026
2 checks passed
@NicolasCARPi NicolasCARPi deleted the toan-2026-01-12-fix-issue-56 branch January 19, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve template preview

3 participants