Skip to content

Commit 2c48f33

Browse files
committed
renaming projects
1 parent 823a776 commit 2c48f33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+154
-29
lines changed
File renamed without changes.

Diff for: 01_basics/src/pages/index.astro

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
---
22
import Layout from '../layouts/Layout.astro';
3-
console.log(`index.astro> node version = ${process.version}`)
3+
import { project_dir } from '../libs/utils';
44
5+
const proj = project_dir(import.meta.url)
56
const node_version = process.version
7+
console.log(`index.astro> node version = ${node_version}`)
68
79
---
810

911
<Layout title="Welcome to Astro.">
1012
<main>
11-
<h1>01_basics</h1>
12-
<h2>Astro Node version <span class="text-gradient">{node_version}</span></h2>
13+
<h1>Astro Node version <span class="text-gradient">{node_version}</span></h1>
14+
<a href={`https://github.com/MicroWebStacks/astro-examples/tree/main/${proj}`} target="_blank">github project '{proj}'</a>
1315
<p class="instructions">
1416
This is a minimal example that shows the node version running
1517
</p>
File renamed without changes.

Diff for: 02_ssr-counter/src/pages/index.astro

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
import Layout from '../layouts/Layout.astro';
33
import { get_count, increment } from './shared';
4+
import { project_dir } from '../libs/utils';
5+
6+
const proj = project_dir(import.meta.url)
47
58
increment()
69
const current_count = get_count()
@@ -10,6 +13,7 @@ const current_count = get_count()
1013
<Layout title="Welcome to Astro.">
1114
<main>
1215
<h1>Astro page1 count = <span class="text-gradient">{current_count}</span></h1>
16+
<a href={`https://github.com/MicroWebStacks/astro-examples/tree/main/${proj}`} target="_blank">github project '{proj}'</a>
1317
<a href="/page2">page2</a>
1418
<p>shared global var demo. reload the page to increment the counter. All pages share the same counter</p>
1519
</main>
File renamed without changes.

Diff for: 03_sse-counter/src/pages/index.astro

+3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
---
22
import Layout from '../layouts/Layout.astro';
33
import { get_count } from './events';
4+
import { project_dir } from '../libs/utils';
45
6+
const proj = project_dir(import.meta.url)
57
const current_count = get_count()
68
79
---
810

911
<Layout title="Welcome to Astro.">
1012
<main>
1113
<h1>Astro SSE Counter <span class="text-gradient">{current_count}</span></h1>
14+
<a href={`https://github.com/MicroWebStacks/astro-examples/tree/main/${proj}`} target="_blank">github project '{proj}'</a>
1215
<p>SSE: Server Sent Events with Node18 using ReadableStream()</p>
1316
<p>Events are coming from a separate file using a timer and Emitter</p>
1417
<p>Note that reloading the page has no effect on server counter</p>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: 05_client-uid-counters/src/libs/utils.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {dirname, normalize, basename, sep,join} from 'path'
2+
let next_uid = 1
3+
4+
function uid(){
5+
return Date.now()+"_"+Math.floor(Math.random() * 10000)
6+
}
7+
8+
function suid(){
9+
let date = (Date.now()).toString();
10+
const sub = date.substring(date.length-6,date.length-1);
11+
return sub+"_"+Math.floor(Math.random() * 10000)
12+
}
13+
14+
function sequence_uid(){
15+
const result = next_uid
16+
next_uid += 1
17+
return result
18+
}
19+
20+
function rel_to_abs(reference,relative){
21+
return join(dirname(normalize(reference)),relative).replace("file:\\","")
22+
}
23+
24+
function project_dir(url){
25+
let project = rel_to_abs(url,"../..")
26+
if(import.meta.env.PROD){
27+
project = rel_to_abs(url,"..")
28+
}
29+
return basename(project)
30+
}
31+
32+
export{
33+
uid,
34+
suid,
35+
sequence_uid,
36+
project_dir
37+
}

Diff for: 04_uid-components/src/pages/index.astro renamed to 05_client-uid-counters/src/pages/index.astro

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
import Layout from '../layouts/Layout.astro';
33
import Card from '../components/Card.astro'
4-
import CardUid from '../components/Card_uid.astro'
54
import { sequence_uid } from '../libs/utils';
5+
import { project_dir } from '../libs/utils';
66
7+
const proj = project_dir(import.meta.url)
78
const c1 = sequence_uid()
89
const c2 = sequence_uid()
910
const c3 = sequence_uid()
@@ -12,6 +13,7 @@ const c3 = sequence_uid()
1213
<Layout title="Welcome to Astro.">
1314
<main>
1415
<h1>Astro <span class="text-gradient">UID</span> Scoped Components</h1>
16+
<a href={`https://github.com/MicroWebStacks/astro-examples/tree/main/${proj}`} target="_blank">github project '{proj}'</a>
1517
<p>Every component has a generated UID to scope its js code</p>
1618
<h2>Time+Random UIDs</h2>
1719
<p>Easiest variant, decentralized but not reproducible, new ids on reload</p>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: 06_astro-xelement/src/libs/utils.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {dirname, normalize, basename, sep,join} from 'path'
2+
let next_uid = 1
3+
4+
function uid(){
5+
return Date.now()+"_"+Math.floor(Math.random() * 10000)
6+
}
7+
8+
function suid(){
9+
let date = (Date.now()).toString();
10+
const sub = date.substring(date.length-6,date.length-1);
11+
return sub+"_"+Math.floor(Math.random() * 10000)
12+
}
13+
14+
function sequence_uid(){
15+
const result = next_uid
16+
next_uid += 1
17+
return result
18+
}
19+
20+
function rel_to_abs(reference,relative){
21+
return join(dirname(normalize(reference)),relative).replace("file:\\","")
22+
}
23+
24+
function project_dir(url){
25+
let project = rel_to_abs(url,"../..")
26+
if(import.meta.env.PROD){
27+
project = rel_to_abs(url,"..")
28+
}
29+
return basename(project)
30+
}
31+
32+
export{
33+
uid,
34+
suid,
35+
sequence_uid,
36+
project_dir
37+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: 07_env-config/src/libs/utils.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {dirname, normalize, basename, sep,join} from 'path'
2+
let next_uid = 1
3+
4+
function uid(){
5+
return Date.now()+"_"+Math.floor(Math.random() * 10000)
6+
}
7+
8+
function suid(){
9+
let date = (Date.now()).toString();
10+
const sub = date.substring(date.length-6,date.length-1);
11+
return sub+"_"+Math.floor(Math.random() * 10000)
12+
}
13+
14+
function sequence_uid(){
15+
const result = next_uid
16+
next_uid += 1
17+
return result
18+
}
19+
20+
function rel_to_abs(reference,relative){
21+
return join(dirname(normalize(reference)),relative).replace("file:\\","")
22+
}
23+
24+
function project_dir(url){
25+
let project = rel_to_abs(url,"../..")
26+
if(import.meta.env.PROD){
27+
project = rel_to_abs(url,"..")
28+
}
29+
return basename(project)
30+
}
31+
32+
export{
33+
uid,
34+
suid,
35+
sequence_uid,
36+
project_dir
37+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: README.md

+28-25

0 commit comments

Comments
 (0)