Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 137 additions & 37 deletions examples/ignore-rules/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,137 @@
# Ignore / Exclude Rules

This example extends the `static-files-and-index-rewrite` example in order to show how to explicitly
not apply the `connect-history-api-fallback`. If you haven't already inspected the
`static-files-and-index-rewrite` example, then do this first as it explains the basic setup of the
project / middleware.

The following excerpts highlight the demo app's important code locations.

## Running the demo app

```
npm install
npm start
```

## Configuring the middleware

In order to define our ignore rules, we define a custom connect middleware which wraps the
middleware created by `connect-history-api-fallback`. This allows us to do anything we want
in terms of ignore rule complexity.

```javascript
const historyMiddleware = history({
disableDotRule: true,
verbose: true
});
app.use((req, res, next) => {
// This is the ignore rule. You can do whatever checks you feel are necessary, e.g.
// check headers, req path, external vars…
if (req.path === '/signOut') {
next();
} else {
historyMiddleware(req, res, next);
}
});
```
<!doctype html>
<html lang="kk">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Гендер Пати — Invited</title>
<meta name="description" content="Гендер-пати — стиль, көңіл-күй, шақыру" />
<style>
:root{
--bg:#0f1724;
--card:#0b1220;
--accent1:#ff6b6b;
--accent2:#6be7ff;
--muted:#9aa7bd;
--glass: rgba(255,255,255,0.04);
font-family: Inter, system-ui, Arial, sans-serif;
}
*{box-sizing:border-box}
body{
margin:0; background: linear-gradient(180deg,var(--bg) 0%, #071122 100%);
color:#e6eef8; -webkit-font-smoothing:antialiased;
}
.container{max-width:980px;margin:36px auto;padding:20px;}
header{display:flex;align-items:center;justify-content:space-between;gap:12px}
.brand{display:flex;align-items:center;gap:12px}
.logo{
width:56px;height:56px;border-radius:12px;background:linear-gradient(135deg,var(--accent1),var(--accent2));
display:flex;align-items:center;justify-content:center;font-weight:700;color:#071122;font-size:18px;
box-shadow:0 6px 20px rgba(0,0,0,0.45);
}
h1{margin:0;font-size:28px}
p.lead{color:var(--muted);margin:8px 0 18px}
.card{background:var(--card);padding:18px;border-radius:14px;box-shadow:0 6px 30px rgba(2,6,23,0.7)}
.hero{display:grid;grid-template-columns:1fr 340px;gap:18px;align-items:start}
@media(max-width:860px){ .hero{grid-template-columns:1fr} .brand h1{font-size:20px} }
.details h2{margin-top:0}
.meta{display:flex;gap:12px;flex-wrap:wrap;margin:12px 0}
.meta .item{background:var(--glass);padding:8px 12px;border-radius:10px;color:var(--muted);font-size:14px}
.rsvp{background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));padding:16px;border-radius:12px}
label{display:block;font-size:13px;margin:8px 0 4px;color:var(--muted)}
input[type=text],input[type=email],textarea{
width:100%;padding:10px;border-radius:8px;border:1px solid rgba(255,255,255,0.04);background:transparent;color:inherit;
}
button.primary{width:100%;padding:12px;border-radius:10px;border:0;background:linear-gradient(90deg,var(--accent1),var(--accent2));color:#041029;font-weight:700;font-size:15px;cursor:pointer;margin-top:10px}
.schedule{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media(max-width:600px){ .schedule{grid-template-columns:1fr} }
.event{background:var(--glass);padding:10px;border-radius:10px}
.gallery{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.gallery img{width:calc(50% - 4px);border-radius:8px;height:120px;object-fit:cover}
footer{margin-top:18px;color:var(--muted);font-size:13px;text-align:center}
</style>
</head>
<body>
<div class="container">
<header>
<div class="brand">
<div class="logo">G</div>
<div>
<h1>Гендер Пати — "Spectrum Night"</h1>
<div class="lead">Стиль: түрлі-түсті, қолайлы. Барлығын қуана қарсы аламыз 🎉</div>
</div>
</div>
<div style="text-align:right;color:var(--muted)">
<div>20 Қазан, 2025</div>
<div style="font-size:12px">19:00 — 23:00</div>
</div>
</header>

<section class="hero" style="margin-top:18px">
<div class="card details">
<h2>Шара жайлы</h2>
<p class="lead">Бұл — гендер-ортаны құрметтейтін, қауіпсіз және көңілді кеш. Костюм еркін, бірақ "радужный" элемент қосса жақсы.</p>

<div class="meta">
<div class="item">Орны: ArtHall, Алматы</div>
<div class="item">Кіру: алдын ала RSVP</div>
<div class="item">Кіріс жасы: 16+</div>
</div>

<h3>Бағдарлама</h3>
<div class="schedule">
<div class="event"><strong>19:00</strong><div>Қош келдіңіздер — ашылу</div></div>
<div class="event"><strong>20:00</strong><div>DJ сет және би</div></div>
<div class="event"><strong>21:30</strong><div>Қайырымдылық аукцион (міндетті емес)</div></div>
<div class="event"><strong>22:30</strong><div>Жабылу</div></div>
</div>

<h3 style="margin-top:12px">Галерея</h3>
<div class="gallery">
<img src="https://images.unsplash.com/photo-1506084868230-bb9d95c24759?w=800&q=60" alt="sample">
<img src="https://images.unsplash.com/photo-1497032628192-86f99bcd76bc?w=800&q=60" alt="sample2">
</div>
</div>

<aside class="rsvp card">
<h3 style="margin:0 0 8px">RSVP</h3>
<p class="lead" style="margin:0 0 12px">Қатысуыңды растайсың ба? Төмендегі форманы толтыр және Send батырын бас.</p>

<!-- Formspree немесе Google Forms action салыңыз -->
<form id="rsvpForm" action="https://formspree.io/f/your-id" method="POST">
<label for="name">Атыңыз</label>
<input id="name" name="name" type="text" required placeholder="Атыңыз">

<label for="email">Email</label>
<input id="email" name="email" type="email" required placeholder="[email protected]">

<label for="guests">Қонақтар (өзіңді қосқанда)</label>
<input id="guests" name="guests" type="text" placeholder="1">

<label for="note">Ескерту (мысалы: тағамдық шектеу)</label>
<textarea id="note" name="note" rows="3" placeholder="Қысқаша жаз..."></textarea>

<button class="primary" type="submit">RSVP жіберу</button>
</form>

<div style="margin-top:10px;color:var(--muted);font-size:13px">
Немесе <a href="mailto:[email protected]" style="color:inherit;text-decoration:underline">[email protected]</a>-қа хат жаз.
</div>
</aside>
</section>

<footer>
© 2025 — "Spectrum Night". Байланыс: +7 (700) 000-0000 — Организатор: Аты-жөні
</footer>
</div>

<script>
// Жеңіл UX: форма жіберілгенде батырма өшіп, мәтін өзгерсін.
document.getElementById('rsvpForm').addEventListener('submit', function(e){
const btn = this.querySelector('button[type="submit"]');

btn.disabled = true;
btn.textContent = 'Жіберілуде...';
});
</script>
</body>
</html>