diff --git a/examples/tiny_twitter b/examples/tiny_twitter deleted file mode 160000 index 6d472fda..00000000 --- a/examples/tiny_twitter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6d472fdac73bf35a27dada48aa0ffa4b42d220c2 diff --git a/examples/tiny_twitter/.gitignore b/examples/tiny_twitter/.gitignore new file mode 100644 index 00000000..1550b48f --- /dev/null +++ b/examples/tiny_twitter/.gitignore @@ -0,0 +1 @@ +sqlpage.bin diff --git a/examples/tiny_twitter/Dockerfile b/examples/tiny_twitter/Dockerfile new file mode 100644 index 00000000..36199a2e --- /dev/null +++ b/examples/tiny_twitter/Dockerfile @@ -0,0 +1,4 @@ +FROM lovasoa/sqlpage:main + +COPY sqlpage /etc/sqlpage +COPY . /var/www/ \ No newline at end of file diff --git a/examples/tiny_twitter/README.md b/examples/tiny_twitter/README.md new file mode 100644 index 00000000..6b15cdb4 --- /dev/null +++ b/examples/tiny_twitter/README.md @@ -0,0 +1,8 @@ +# Tiny Tweeter + +This is a simple example of a very simple Twitter-like application running on top of PostgreSQL. +It is called tweeter because Elon Musk already has the Twitter trademark, even though he doesn't use it. + +It was presented at the [2023 PGConf.EU](https://2023.pgconf.eu/) conference. + +You can find the slides at https://sql.ophir.dev/pgconf/pgconf-2023.html. \ No newline at end of file diff --git a/examples/tiny_twitter/docker-compose.yml b/examples/tiny_twitter/docker-compose.yml new file mode 100644 index 00000000..d06294a3 --- /dev/null +++ b/examples/tiny_twitter/docker-compose.yml @@ -0,0 +1,15 @@ +services: + sqlpage: + build: . + ports: ["8080:8080"] + volumes: [".:/var/www"] + depends_on: [postgres] + environment: + - DATABASE_URL=postgres://root:root@postgres/sqlpage + postgres: + image: postgres:16 + ports: ["5432:5432"] + environment: + - POSTGRES_USER=root + - POSTGRES_PASSWORD=root + - POSTGRES_DB=sqlpage \ No newline at end of file diff --git a/examples/tiny_twitter/index.sql b/examples/tiny_twitter/index.sql new file mode 100644 index 00000000..0a47a9b1 --- /dev/null +++ b/examples/tiny_twitter/index.sql @@ -0,0 +1,22 @@ +select 'shell' as component, + 'TinyTweeter' as title; + +select 'form' as component, + 'Tweet' as validate; +select 'new_tweet' as name, + 'Your story' as label, + 'textarea' as type, + 'Tell me your story...' as placeholder; +select 'checkbox' as type, + 'Terms and conditions' as label, + true as required; + +insert into tweets (tweet) +select :new_tweet +where :new_tweet is not null; + +select 'card' as component, + 'Tweets' as title, + 1 as columns; +select tweet as description +from tweets; \ No newline at end of file diff --git a/examples/tiny_twitter/sqlpage/migrations/0001_tweets.sql b/examples/tiny_twitter/sqlpage/migrations/0001_tweets.sql new file mode 100644 index 00000000..2b5c9a65 --- /dev/null +++ b/examples/tiny_twitter/sqlpage/migrations/0001_tweets.sql @@ -0,0 +1,4 @@ +CREATE TABLE tweets( + id bigserial, + tweet text +); \ No newline at end of file