Skip to content

Commit 3e14871

Browse files
authored
Merge pull request #413 from api-platform/staging
MEP
2 parents 46988c5 + d43fb21 commit 3e14871

File tree

88 files changed

+1496
-373
lines changed

Some content is hidden

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

88 files changed

+1496
-373
lines changed

README.md

Lines changed: 96 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,108 @@
1-
<h1 align="center"><a href="https://api-platform.com"><img src="https://api-platform.com/logo-250x250.png" alt="API Platform"></a></h1>
1+
# api-platform.com
22

3-
API Platform is a next-generation web framework designed to easily create API-first projects without compromising extensibility
4-
and flexibility:
3+
This repository contains the source code and documentation powering [api-platform.com](https://api-platform.com/).
54

6-
* Design your own data model as plain old PHP classes or [**import an existing ontology**](https://api-platform.com/docs/schema-generator).
7-
* **Expose in minutes a hypermedia REST or a GraphQL API** with pagination, data validation, access control, relation embedding,
8-
filters and error handling...
9-
* Benefit from Content Negotiation: [GraphQL](https://api-platform.com/docs/core/graphql/), [JSON-LD](https://json-ld.org), [Hydra](https://hydra-cg.com),
10-
[HAL](https://github.com/mikekelly/hal_specification/blob/master/hal_specification.md), [JSON:API](https://jsonapi.org/), [YAML](https://yaml.org/), [JSON](https://www.json.org/), [XML](https://www.w3.org/XML/) and [CSV](https://www.ietf.org/rfc/rfc4180.txt) are supported out of the box.
11-
* Enjoy the **beautiful automatically generated API documentation** ([OpenAPI](https://api-platform.com/docs/core/openapi/)).
12-
* Add [**a convenient Material Design administration interface**](https://api-platform.com/docs/admin) built with [React](https://reactjs.org/)
13-
without writing a line of code.
14-
* **Scaffold fully functional Progressive-Web-Apps and mobile apps** built with [Next.js](https://api-platform.com/docs/client-generator/nextjs/) (React),
15-
[Nuxt.js](https://api-platform.com/docs/client-generator/nuxtjs/) (Vue.js) or [React Native](https://api-platform.com/docs/client-generator/react-native/)
16-
thanks to [the client generator](https://api-platform.com/docs/client-generator/) (a Vue.js generator is also available).
17-
* Install a development environment and deploy your project in production using **[Docker](https://api-platform.com/docs/distribution)**
18-
and [Kubernetes](https://api-platform.com/docs/deployment/kubernetes).
19-
* Easily add **[OAuth](https://oauth.net/) authentication**.
20-
* Create specs and tests with **[a developer friendly API testing tool](https://api-platform.com/docs/distribution/testing/)**.
5+
Single Page Application built with [React](https://facebook.github.io/react/) and powered by [Next.js](https://nextjs.org/).
216

22-
[![GitHub Actions](https://github.com/api-platform/core/workflows/CI/badge.svg)](https://github.com/api-platform/core/actions?workflow=CI)
23-
[![Codecov](https://codecov.io/gh/api-platform/core/branch/master/graph/badge.svg)](https://codecov.io/gh/api-platform/core/branch/master)
7+
[![Build Status](https://travis-ci.org/api-platform/website.svg?branch=main)](https://travis-ci.org/api-platform/website)
248

25-
The official project documentation is available **[on the API Platform website](https://api-platform.com)**.
269

27-
API Platform embraces open web standards and the
28-
[Linked Data](https://www.w3.org/standards/semanticweb/data) movement. Your API will automatically expose structured data.
29-
It means that your API Platform application is usable **out of the box** with technologies of
30-
the semantic web.
10+
## Project structure
3111

32-
It also means that **your SEO will be improved** because **[Google leverages these formats](https://developers.google.com/search/docs/guides/intro-structured-data)**.
12+
The project has been created from the [API Platform distribution folder](https://api-platform.com/docs/distribution/#installing-the-framework). All next.js application code is located in the "pwa" folder. The project is made with [the Next.js new app router](https://nextjs.org/docs/app).
3313

34-
Last but not least, the server component of API Platform is built on top of the [Symfony](https://symfony.com) framework,
35-
while client components leverage [React](https://reactjs.org/) ([Vue.js](https://vuejs.org/) flavors are also available).
36-
It means that you can:
3714

38-
* Use **thousands of Symfony bundles and React components** with API Platform.
39-
* Integrate API Platform in **any existing Symfony, React or Vue application**.
40-
* Reuse **all your Symfony and JavaScript skills**, benefit of the incredible amount of documentation available.
41-
* Enjoy the popular [Doctrine ORM](https://www.doctrine-project.org/projects/orm.html) (used by default, but fully optional:
42-
you can use the data provider you want, including but not limited to MongoDB and Elasticsearch)
15+
## 🤝 Contributors features
4316

44-
## Install
17+
You need to use a valid github token to retrieve the list of contributors.
18+
19+
1. Go to your [github developer settings](https://github.com/settings/tokens)
20+
21+
2. Select scopes `public_repo`, `read:org` and `read:user`, generate the token and copy it.
22+
23+
3. If you use "pnpm dev" on the folder pwa to launch the project, add a new `.env.local` file on the root of pwa folder, and set your token as an environment variable named `GITHUB_KEY`.
24+
25+
26+
If you use docker, create a file "secret_github_key" at the root of the project with your token inside :
27+
```sh
28+
# Create the secret_github_key file
29+
echo "YOUR_GITHUB_TOKEN" > secret_github_key
30+
31+
```
32+
33+
> **❗Core team badges restriction**: You need to be a member of API Platform organization to retrieve API Platform teams. You can still locally launch the project, but the badges of the core team members will not appear.
34+
35+
## Installation and usage
36+
37+
### with docker
38+
39+
```sh
40+
# Checkout project
41+
git clone https://github.com/api-platform/website.git
42+
43+
# Change directory
44+
cd website
45+
46+
# Create the github_key file
47+
echo YOUR_GITHUB_TOKEN > secret_github_key
48+
49+
# Install and run the project locally
50+
docker compose up -d
51+
> Go to http://localhost
52+
53+
```
54+
55+
### without docker
56+
57+
```sh
58+
# Checkout project
59+
git clone https://github.com/api-platform/website.git
60+
61+
# Change directory
62+
cd website/pwa
63+
64+
# Install dependencies
65+
pnpm install
66+
67+
# Launch prebuild script (necessary to create some images variants like wallpapers or logos)
68+
pnpm prebuild
69+
70+
# Run project locally (for development)
71+
pnpm dev
72+
> Go to http://localhost:3000/
73+
74+
75+
```
76+
77+
## Build the project locally
78+
79+
### with docker
80+
81+
```sh
82+
83+
# TO COMPLETE
84+
85+
```
86+
87+
88+
### without docker
89+
90+
```sh
91+
92+
# Build the project (for production) from the pwa folder
93+
pnpm build
94+
95+
# Test the built project locally
96+
pnpm start
97+
> Go to http://localhost:3000
98+
99+
```
100+
101+
## Publishing Docs For New Versions
102+
103+
1. Create a branch for the new version [in the `api-platform/docs` repository](https://github.com/api-platform/docs).
104+
2. Update [`consts.ts`](./pwa/consts.ts)
105+
3. Update [Algolia crawler configuration](https://crawler.algolia.com/admin/crawlers/23316da5-88e8-4a30-ab16-d5ec5bd9133f/configuration/edit)
45106

46-
[Read the official "Getting Started" guide](https://api-platform.com/docs/distribution).
47107

48-
## Credits
49108

50-
Created by [Kévin Dunglas](https://dunglas.fr). Commercial support available at [Les-Tilleuls.coop](https://les-tilleuls.coop).

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@ volumes:
9595

9696
secrets:
9797
GITHUB_KEY:
98-
file: ./secret_github_key
98+
file: ./secret_github_key

pwa/.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ NEXT_PUBLIC_EVENT_BRITE_ID=483719928327
22
NEXT_PUBLIC_DOCSEARCH_API_KEY = 52043128794330355240504c03762281
33
NEXT_PUBLIC_DOCSEARCH_INDEX_NAME = api-platform
44
NEXT_PUBLIC_DOCSEARCH_APP_ID = ZQ00U6B6ML
5-
NEXT_PUBLIC_MAPBOX_KEY=pk.eyJ1IjoiZ2luaWZpenoiLCJhIjoiY2tsZ2c3d3Z1MWs1MDJvbWpvdjM2MGg4ZSJ9.5jBAlLJbO-gf2_BQGzfZ0Q
5+
NEXT_PUBLIC_MAPBOX_KEY=pk.eyJ1IjoiZ2luaWZpenoiLCJhIjoiY2tsZ2c3d3Z1MWs1MDJvbWpvdjM2MGg4ZSJ9.5jBAlLJbO-gf2_BQGzfZ0Q
6+

pwa/api/doc/index.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { cache } from "react";
1212
import { current } from "consts";
1313
import { load as parseHtml } from "cheerio";
1414
import { Chapters } from "types";
15-
import { notFound } from "next/navigation";
1615

1716
export const MyOctokit = Octokit.plugin(throttling);
1817
const sidebarMemoryCache = new Map();
@@ -182,6 +181,9 @@ export const getDocContentFromSlug = async (
182181
const codeInside = /\[codeSelector\]([\s\S]+?)(?=\[\/codeSelector])/gm;
183182
const codeBlock = /```[a-z]([\s\S]+?)(?=```)/gm;
184183
const codeLanguage = /```([a-z]+)/;
184+
const absoluteImgRegex = /src="\/docs\/(.*?\.(jpg|jpeg|png|gif|svg))"/gm;
185+
const blankLinkRegex =
186+
/<a\s+([^>]*\s+)?href="http[^"]*"(?![^>]*\starget=[^>]*>)/gm;
185187

186188
function getLang(block: string): string {
187189
const language = block.match(codeLanguage);
@@ -193,13 +195,11 @@ function getLang(block: string): string {
193195
return language[1];
194196
}
195197

196-
export const getHtmlFromGithubContent = async ({
197-
data,
198-
path: githubPath,
199-
}: {
200-
data: any;
201-
path: string;
202-
}) => {
198+
export const getHtmlFromGithubContent = async (
199+
data: any,
200+
githubPath: string,
201+
version: string
202+
) => {
203203
const result = Buffer.from(data.content, "base64").toString();
204204

205205
marked.setOptions({ mangle: false, headerIds: false });
@@ -251,7 +251,6 @@ export const getHtmlFromGithubContent = async ({
251251
$("img").map(function (i, elem) {
252252
const el = $(this);
253253
const src = el.attr("src");
254-
255254
if (src) {
256255
el.attr("src", toAbsoluteUrl(src, githubPath));
257256
}
@@ -316,5 +315,11 @@ export const getHtmlFromGithubContent = async ({
316315
},
317316
});
318317

319-
return marked.parse(result);
318+
return marked
319+
.parse(result)
320+
.replace(
321+
absoluteImgRegex,
322+
`src="https://raw.githubusercontent.com/api-platform/docs/${version}/$1"`
323+
)
324+
.replace(blankLinkRegex, '$& target="_blank"');
320325
};

pwa/app/(common)/community/contributors/[slug]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from "api/contributors";
66
import Heading from "components/common/typography/Heading";
77
import RepoLink from "./components/RepoLink";
8-
import Link from "next/link";
8+
import Link from "components/common/Link";
99
import ContributorRepositories from "./components/ContributorRepositories";
1010
import ContributorProfileCard from "./components/ContributorProfileCard";
1111
import { Fragment } from "react";
@@ -145,6 +145,7 @@ export default async function Page({
145145
<Link
146146
className="uppercase font-semibold text-sm mb-2 opacity-80"
147147
href="/community/contributors"
148+
prefetch={false}
148149
>
149150
Our contributors
150151
</Link>

pwa/app/(common)/community/contributors/components/ContributorItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Image from "next/image";
22
import { Contributor } from "types";
33
import classNames from "classnames";
4-
import Link from "next/link";
4+
import Link from "components/common/Link";
55
import Heading from "components/common/typography/Heading";
66

77
interface ContributorItemProps {

pwa/app/(common)/community/contributors/components/ContributorSmallItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Heading from "components/common/typography/Heading";
22
import Image from "next/image";
3-
import Link from "next/link";
3+
import Link from "components/common/Link";
44
import { Contributor } from "types";
55

66
interface ContributorSmallItemProps {

pwa/app/(common)/components/Admin.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Button from "components/common/Button";
22
import Heading from "components/common/typography/Heading";
33
import Image from "next/image";
44
import ListPoint from "./AdminListPoint";
5+
import Link from "components/common/Link";
56

67
export default function Admin() {
78
return (
@@ -13,20 +14,28 @@ export default function Admin() {
1314
<p className="text-text-secondary dark:text-white text-xl font-light mt-8">
1415
API Platform Admin exposes your data trough a beautiful UI.
1516
</p>
16-
<div className="flex flex-col w-full justify-between items-start py-8 gap-y-8 | sm:flex-row sm:max-w-xl sm:gap-x-24 sm:gap-y-0 sm:mt-8 | md:max-w-none | xl:min-h-[450px]">
17-
<div className="flex flex-col items-center text-center w-full | lg:text-left lg:w-1/4">
17+
<div className="flex flex-col w-full justify-between items-center py-8 gap-y-8 | sm:flex-row sm:max-w-xl sm:gap-x-24 sm:gap-y-0 sm:mt-8 | md:max-w-none | xl:min-h-[450px]">
18+
<div className="flex flex-col items-center text-center w-full | sm:items-start sm:text-left | lg:w-1/4">
1819
<ListPoint direction="left">
1920
Entirely <strong>customizable</strong>
2021
</ListPoint>
2122
<ListPoint direction="left">
22-
<strong>Hydra</strong> and <strong>OpenAPI</strong> compatible
23+
<strong>Hydra</strong> and{" "}
24+
<Link
25+
href="/docs/admin/openapi/"
26+
prefetch={false}
27+
className="link"
28+
>
29+
<strong>OpenAPI</strong>
30+
</Link>{" "}
31+
compatible
2332
</ListPoint>
2433
<ListPoint direction="left">
2534
Built on top of <strong>Material UI</strong> and{" "}
2635
<strong>React Admin</strong>
2736
</ListPoint>
2837
</div>
29-
<div className="flex flex-col items-center text-center w-full | lg:text-left lg:w-1/4">
38+
<div className="flex flex-col items-center text-center w-full | sm:items-start sm:text-left | lg:w-1/4">
3039
<ListPoint direction="right">
3140
100% <strong>no code</strong>
3241
</ListPoint>
@@ -50,7 +59,7 @@ export default function Admin() {
5059
empty
5160
className="relative dark:border-blue-extralight dark:text-blue-extralight"
5261
color="white"
53-
href="/docs"
62+
href="/docs/admin/"
5463
ariaLabel="See admin interface"
5564
>
5665
Learn more

0 commit comments

Comments
 (0)