Skip to content

Commit

Permalink
* logo added
Browse files Browse the repository at this point in the history
* content added
* extend the default layout component
* override default css color variables with own colors
  • Loading branch information
Sebastix committed Jun 27, 2024
1 parent 76692ab commit 47f7fc2
Show file tree
Hide file tree
Showing 14 changed files with 192 additions and 27 deletions.
24 changes: 23 additions & 1 deletion website/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# https://nostr-php.dev website
# Website for https://nostr-php.dev

This documentation website is created with [VitePress](https://vitepress.dev/).

## Install packages

```bash
npm install
```

## Build

```bash
npm run docs:build
```

All files are generated and saved in `content/.vitepress/dist/`

## Development

```bash
npm run docs:dev
```
35 changes: 22 additions & 13 deletions website/content/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,37 @@ import { defineConfig } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "nostr-php",
title: "Nostr-PHP",
description: "A PHP helper library for Nostr",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
logo: '/assets/nostr-php_hero-splash.png',
nav: [
{ text: 'Home', link: '/' },
// { text: 'Examples', link: '/markdown-examples' }
{ text: 'Guides', link: '/guides/get-started' },
{ text: 'phpDoc', link: 'https://phpdoc.nostr-php.dev' },
{ text: 'Fork me', link: 'https://github.com/nostrver-se/nostr-php/fork' }
],

// sidebar: [
// {
// text: 'Examples',
// items: [
// { text: 'Markdown Examples', link: '/markdown-examples' },
// { text: 'Runtime API Examples', link: '/api-examples' }
// ]
// }
// ],
sidebar: [
{
text: 'Guides',
items: [
{ text: 'Get started', link: '/guides/get-started' },
{ text: 'Generate keys', link: '/guides/generate-keys' },
{ text: 'Publish events', link: '/guides/publish-events' },
{ text: 'Read events', link: '/guides/read-events' }
]
}
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
]
{ icon: 'github', link: 'https://github.com/nostrver-se/nostr-php' }
],

editLink: {
pattern: 'https://github.com/nostrver-se/nostr-php/tree/main/website/content/:path'
}
},
cleanUrls: true
})
17 changes: 17 additions & 0 deletions website/content/.vitepress/theme/NostrPHPLayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script setup>
import DefaultTheme from 'vitepress/theme'
const { Layout } = DefaultTheme
</script>

<template>
<Layout>
<template #layout-bottom>
<footer class="text-center">
Released under the MIT License. Supported by OpenSats.
<br />
<a href="https://github.com/nostrver-se/nostr-php/tree/main/website)" target="_blank">Source Code</a>
</footer>
</template>
</Layout>
</template>
34 changes: 34 additions & 0 deletions website/content/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css */
:root {
--nostrphp-purple: #603d98;
--nostrphp-orange: #f26724;
--vp-home-hero-name-color: var(--nostrphp-orange);
/*--vp-home-hero-name-background: -webkit-linear-gradient( 120deg, var(--nostrphp-purple) 30%, var(--nostrphp-orange) );*/
--vp-home-hero-image-background-image: linear-gradient( -45deg, #bd34fe 60%, var(--nostrphp-orange) 50% );
--vp-home-hero-image-filter: blur(70px);
--docsearch-primary-color: var(--nostrphp-orange);
--docsearch-logo-color: var(--nostrphp-orange);
--vp-c-brand-1: var(--nostrphp-orange);
--vp-button-brand-bg: var(--nostrphp-orange);
--vp-button-brand-hover-bg: var(--nostrphp-purple);
--vp-button-brand-active-bg: var(--nostrphp-purple);
}

footer {
margin: 30px 0;
}
.text-center {
text-align: center;
}

.image-bg {
position: absolute;
top: 50%;
left: 50%;
border-radius: 50%;
width: 280px !important;
height: 280px !important;
background-image: var(--vp-home-hero-image-background-image);
filter: var(--vp-home-hero-image-filter);
transform: translate(-50%, -50%);
}
8 changes: 8 additions & 0 deletions website/content/.vitepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import DefaultTheme from 'vitepress/theme';
import NostrPHPLayout from './NostrPHPLayout.vue'
import './custom.css';

export default {
extends: DefaultTheme,
Layout: NostrPHPLayout,
}
19 changes: 19 additions & 0 deletions website/content/compare-nostr-libraries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
Title: Compare Nostr helper libraries
---

| Library | [go-nostr](https://github.com/nbd-wtf/go-nostr) | [python-nostr](https://github.com/jeffthibault/python-nostr) | [nostr-flutter](https://pub.dev/documentation/nostr/latest/nostr/nostr-library.html) | nostr-php | [NDK](https://ndk.fyi/docs/) | [nostr-rust](https://rust-nostr.org/) |
| --- |-------------------------------------------------|--------------------------------------------------------------|--------------------------------------------------------------------------------------| --- |------------------------------|---------------------------------------|
| Language | Golang | Python | Dart (Flutter) | PHP | TypeScript | Rust |
| Keypair generation | | | || | |
| CLI | | | || ||
| NIP-02 | | | | | | |
| NIP-05 | | | | | | |
| NIP-10 | | | | | | |
| | | | | | | |
| NIP-19 | | | | | | |
| NIP-21 | | | | | | |
| NIP-24 | | | | | | |
| NIP-42 | | | | | | |
| NIP-57 | | | | | | |
| NIP-65 | | | | | | |
Empty file.
Empty file.
Empty file.
20 changes: 20 additions & 0 deletions website/content/guides/generate-keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Generate keys
---

# Generate keys

## Create a private key

```php
$privateKey = new Key();
$privateKey->generatePrivateKey();
```

## Get public key from a private key

```php
$key = new Key();
$private_key_hex = $privateKey->convertToHex($private_key);
$public_key = $key->getPublicKey($private_key_hex);
```
19 changes: 19 additions & 0 deletions website/content/guides/get-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Get started with Nostr-PHP
---

# Get Started

## Try it out online

## Prerequisites
* PHP 8.1 or higher
* Composer

## Installation

Nostr-PHP can be installed as a package with Composer in your PHP project.

```bash
composer require nostrverse/nostr-php
```
1 change: 1 addition & 0 deletions website/content/guides/publish-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Publish events
1 change: 1 addition & 0 deletions website/content/guides/read-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Read events
41 changes: 28 additions & 13 deletions website/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,44 @@
layout: home

hero:
name: "nostr-php"
name: "Nostr-PHP"
text: "A PHP helper library for Nostr"
# tagline: My great project tagline
tagline: Empower your 🐘 PHP project with Nostr.
image:
src: /assets/nostr-php_hero-splash.png
alt: Nostr-PHP
actions:
# - theme: brand
# text: Markdown Examples
# link: /markdown-examples
- theme: brand
text: Get started
link: /guides/get-started
- theme: alt
text: Chat
link: https://t.me/nostr_php
- theme: alt
text: View source code
text: Source Code
link: https://github.com/nostrver-se/nostr-php


features:
- title: Publish events
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
details: Create, sign and publish Nostr events to relays.
link: /guides/publish-events
- title: Read events
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
details: Request Nostr events from relays.
link: /guides/read-events
- title: Examples
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
details: Learn how to use this PHP helper library for Nostr.
---

Add the nostr-php to your PHP project with Composer
## Get started

Add the nostr-php package to your PHP project with Composer

```bash
composer require nostrverse/nostr-php
```

Here is very simple example:
Here is an example how to create and publish an event to a relay:

```php
<?php
Expand All @@ -52,17 +59,24 @@ function send($message) {
$private_key = $key->generatePrivateKey(); // this will generate a private key
$private_key_hex = $key->convertToHex($private_key);
$public_key = $key->getPublicKey($private_key_hex);

$relayUrl = 'wss://relay.damus.io';

$note = new Event();
$note->setKind(1);
$note->addTag(['p', $public_key]);
$note->addTag(['r', $relayUrl]);
$note->setContent($message);

$signer = new Sign();
$signer->signEvent($note, $private_key);

$eventMessage = new EventMessage($note);
$relay = new Relay($relayUrl, $eventMessage);

$relay = new Relay($relayUrl);
$relay->setMessage($eventMessage);
$result = $relay->send();

if ($result->isSuccess()) {
print "The event has been sent to Nostr!\n";
} else {
Expand All @@ -76,4 +90,5 @@ function send($message) {
$message = 'Hello world ' . date('Y-m-d H:i:s');
send($message);

```
```
For more examples please check this [README](https://github.com/nostrver-se/nostr-php/blob/main/README.md).

0 comments on commit 47f7fc2

Please sign in to comment.