• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
devto

devto

adportal

Unlisted
Like
adportal
Home
Code
20
api
7
controllers
3
models
2
public
6
services
5
tests
1
utils
3
views
4
README.md
REFACTORING-PHASE1.md
REFACTORING-PHASE2.md
REFACTORING-PHASE3.md
REFACTORING-PHASE4.md
REFACTORING-PHASE5.md
REFACTORING.md
TEMPLATE-FIX.md
devto-stylesheet-README.md
C
devto-stylesheet-fetcher.ts
H
devto-stylesheet-provider.ts
H
index.ts
Branches
2
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
REFACTORING-PHASE1.md
Code
/
REFACTORING-PHASE1.md
Search
5/8/2025
Viewing readonly version of main branch: v444
View latest version
REFACTORING-PHASE1.md

DEV Partner Portal Refactoring - Phase 1

This document outlines the changes made in Phase 1 of the continue.html refactoring.

Phase 1: Component Structure Setup

Directory Structure

We've created a component-based architecture with the following structure:

/views
  /components
    /layout
      header.html
      footer.html
    /forms
      company-info-form.html
    /uploadcare
      uploader-config.html
      image-uploader.html
      image-gallery.html
    /ui
      section-card.html
      message-box.html
      account-info.html
    /ad-creation
      ad-preview.html
    README.md
  /templates
    continue-template.html

CSS Organization

We've extracted inline styles into dedicated CSS files:

/public/css
  /components
    section-cards.css
    uploadcare-custom.css
    forms.css
  continue-page.css

Template Service Enhancement

We've enhanced the template service (templateService.ts) to support:

  1. Component Inclusion: Using {{> component/path param1="value1"}} syntax
  2. Conditional Logic: Using {{#if condition}}...{{#else}}...{{/if}} syntax
  3. Variable Replacement: Using {{variableName}} syntax
  4. Parameter Passing: Passing data to components

Component Examples

Header Component

<h1 class="text-3xl font-bold text-center mb-2">{{title}}</h1> {{#if subtitle}} <h2 class="text-xl text-center text-gray-600 mb-8">{{subtitle}}</h2> {{/if}}

Message Box Component

{{#if type == "success"}} <div id="{{id}}" class="hidden mt-6 p-4 bg-green-50 text-green-700 rounded-md"> {{message}} </div> {{else if type == "error"}} <div id="{{id}}" class="hidden mt-6 p-4 bg-red-50 text-red-700 rounded-md"> {{message}} </div> {{else}} <div id="{{id}}" class="hidden mt-6 p-4 bg-blue-50 text-blue-700 rounded-md"> {{message}} </div> {{/if}}

Main Template

We've created a new template (continue-template.html) that uses components:

<!DOCTYPE html> <html lang="en"> <head> {{> components/meta-tags}} <title>Ad Portal - DEV Partner Portal</title> <link rel="stylesheet" href="/public/css/styles.css"> <link rel="stylesheet" href="/public/css/continue-page.css"> {{> components/uploadcare/uploader-config}} </head> <body> <!-- ... --> {{> components/layout/header title="DEV Partner Portal" subtitle="Ad Portal"}} <!-- Account Information Section --> <section class="section-card"> <!-- ... --> {{> components/ui/account-info company=COMPANY_NAME email=EMAIL id=ID host=HOST}} </section> <!-- ... more components ... --> {{> components/layout/footer year="2023"}} </body> </html>

Controller Update

We've updated the submissionController.ts to use our new template:

export async function renderContinuationPage(c: Context): Promise<Response> { // ... const html = await renderTemplate("/views/templates/continue-template.html", { COMPANY_NAME: submission.companyName, EMAIL: submission.email, ID: id, HOST: host }, import.meta.url); return c.html(html); }

Benefits of Phase 1

  1. Improved Organization: Clear separation of concerns with components
  2. Better Maintainability: Smaller, focused files are easier to understand and modify
  3. Enhanced Reusability: Components can be reused across different pages
  4. Cleaner Styling: Dedicated CSS files for components
  5. Simplified Templates: Main template is now more readable and focused on structure

Next Steps

In Phase 2, we'll extract more components from the continue.html file, focusing on common UI patterns and further improving the organization of the code.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.