Skip to content

Commit

Permalink
Merge pull request #16 from ernestmarcinko/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ernestmarcinko authored Dec 26, 2023
2 parents aaef7a8 + 9954f3c commit ff589e6
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 17 deletions.
1 change: 1 addition & 0 deletions dist/github-worth.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/htmx-serverless.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ app.get('/htmx-serverless', function(req, res) {
});
});

app.get('/github-worth', function(req, res) {
var att = {
title: 'Get money for your github account',
description: 'See how much your fantastic github account is worth and get the money immediately'
};
res.render('pages/github-worth',{
att: att,
});
});

app.get('/flappybird', function(req, res) {
var att = {
title: 'Flappy Bird in TypeScript by Ernest Marcinko',
Expand Down
10 changes: 10 additions & 0 deletions src/github-worth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import htmx from "htmx.org";
import htmxServerless from "htmx-serverless";

htmxServerless.init(htmx);

function garbage() {
return `<p class='idiot'>You are an idiot.</p>`;
}

export default garbage;
34 changes: 19 additions & 15 deletions src/htmx-serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@ let duckCount = 0;
duck.getDuck = function(text, params, xhr){
let status = 'bad, get more.';


if ( duckCount > 0 && duckCount < 10 ) {
status = 'okay.'
} else if ( duckCount < 20 ) {
status = 'getting better.'
} else if ( duckCount < 50 ) {
status = 'getting better and better.'
} else if ( duckCount < 100 ) {
status = 'even better!'
} else if ( duckCount < 200 ) {
status = 'marvelous!'
} else if ( duckCount < 500 ) {
status = 'duckolitios!'
} else if ( duckCount < 500 ) {
status = 'what???'
if ( duckCount > 0 ) {
// Switch is for the weak
if ( duckCount < 10 ) {
status = 'okay.'
} else if ( duckCount < 20 ) {
status = 'getting better.'
} else if ( duckCount < 50 ) {
status = 'getting better and better.'
} else if ( duckCount < 100 ) {
status = 'even better!'
} else if ( duckCount < 200 ) {
status = 'marvelous!'
} else if ( duckCount < 500 ) {
status = 'duckolitios!'
} else if ( duckCount < 1000 ) {
status = '...what how many???'
} else {
status = 'crazy...'
}
}

return `You have ${duckCount++} 🦆, it is ${status}`;
Expand Down
49 changes: 49 additions & 0 deletions views/pages/github-worth.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<%- include('../parts/head'); %>
<script src="/dist/github-worth.js"></script>
<style>
.github-worth {
background-image: none;
}
.github-worth button,
.github-worth input[type="text"] {
padding: 12px;
border: none;
border-radius: 5px;
font-weight: 700;
margin: 1em;
}
.github-worth input[type="text"] {
background: var(--color-bg);
border: 1px solid #354b5e;
color: white;
}
p.idiot {
font-style: italic;
font-size: 2em;
}
</style>
</head>
<body>
<main class="wrapper github-worth" role="main">
<section class="intro">
<h1 id="tw1">How much is your github repo worth?</h1>
<div>
<h3>Click the button to withdraw $$$</h3>
<input type="text" placeholder="github username">
<button hx-get="js:garbage" hx-trigger="click" hx-target=".github-worth div" hx-ext="serverless">
Give me my money
</button>
</div>
</section>
<section style="max-width: 640px;">
<p><a href='../'><< Back Home</a></p>
</section>
</main>

<%- include('../parts/footer'); %>
</body>
</html>
11 changes: 11 additions & 0 deletions views/pages/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
</p>
</section>
<section class="projects flexy">
<div class="project">
<a class="title" href="/github-worth/">
<h2>Get the worth of your GitHub account</h2>
</a>
<p>Calculate a very accurate worth of your GitHub account. Don't let people scam you!</p>
<p>Instant withdrawal!</p>
<ul>
<li><a href='/github-worth/'>Go for it!</a></li>
<li><a href='https://github.com/ernestmarcinko/' target="_blank">Github Repository</a></li>
</ul>
</div>
<div class="project">
<a class="title" href="/htmx-serverless/">
<h2>HTMX without a Server</h2>
Expand Down
13 changes: 13 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,18 @@ export default [{
path: path.resolve(__dirname, 'dist'),
filename: 'htmx-serverless.js',
},
},
{
entry: './src/github-worth.js',
output: {
library: {
name: 'garbage',
type: 'global',
export: 'default',
},
globalObject: 'window',
path: path.resolve(__dirname, 'dist'),
filename: 'github-worth.js',
},
}
];

0 comments on commit ff589e6

Please sign in to comment.