Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,31 @@ avec son contenu.
- Ouvrir un terminal
- Récupérer le repo `git clone git@github.com:lechappeebelle/scribouilli.git` dans le dossier qui va bien
- Rentrer dans le dossier `scribouilli`
- Faire `npm install`
- Faire `npm install` (vous pouvez aussi utiliser `pnpm`)
- Builder le projet avec `npm run dev`
- Lancer le projet avec `npm start` dans un autre terminal
- Ouvrir dans votre navigateur préféré `http://localhost:8080/`

## Développement

- Forker le repo sur votre compte
- Modifier les settings
- Donner les droits en écriture a _github action_
- Pour déployer la branche `online`
- Forker le repo sur votre compte en prenant soin de **ne pas** copier **uniquement** la branche `principale` (pour disposer de la branche `online`)
- Modifier les paramètres (_Settings_) de votre fork
- Donner les droits en écriture à _github action_ dans **Actions > General > Workflow permissions**
- Pour déployer la branche `online` dans **Pages > Build and deployment**
- Ajouter votre origine github pages (ex: `yaf.github.io`) dans [Scribouilli/toctoctoc/allowlist.csv](https://github.com/Scribouilli/toctoctoc/blob/main/allowlist.csv)

Voilà à quoi ça peut ressembler : [github.com/yaf/scribouilli](https://github.com/yaf/scribouilli)

Une fois les développements réalisés, vous pouvez faire une PR dans Scribouilli, en précisant votre url de développement pour que l'on puisse tester la modification.


### Limite connue

Pour le moment, il n'est pas possible de tester en local des sites hébergés sur gitlab ou scribougit (`git.scribouilli.org`)
On peut le faire, mais ça demande de changer la config de toctoctoc en prod (et donc, ça casse la prod pour les sites ; une histoire de `redirect_uri`)


### Outils de développement

Des pre-commit hooks sont installés automatiquement avec `husky`. Si jamais il sont trop contraignants,
Des pre-commit hooks peuvent être installés avec `husky` en exécutant `npm run prepare`. Si jamais il sont trop contraignants,
il est possible de les ignorer avec l'option `--no-verify` de `git commit`.

Vous pouvez également lancer les tests en local avec :
Expand Down
2 changes: 0 additions & 2 deletions assets/scripts/GitAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,6 @@ export default class GitAgent {
*
*
* https://isomorphic-git.org/docs/en/setConfig
*
* Alors, on doit passer le repoName
*/
async setAuthor(
login: string,
Expand Down
20 changes: 8 additions & 12 deletions assets/scripts/actions/current-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import page from 'page'
import yaml from 'js-yaml'

import store, { type PartialStore } from './../store.ts'
import ScribouilliGitRepo, {
makeRepoId,
makePublicRepositoryURL,
} from './../scribouilliGitRepo.ts'
import ScribouilliGitRepo, { makeRepoId } from './../scribouilliGitRepo.ts'
import GitAgent from '../GitAgent.ts'
import { handleErrors, logMessage } from './../utils.ts'
import { fetchAuthenticatedUserLogin } from './current-user.ts'
Expand Down Expand Up @@ -41,16 +38,16 @@ export const setCurrentRepositoryFromQuerystring = async (
querystring: string,
): Promise<void> => {
const params = new URLSearchParams(querystring)
const repoName = params.get('repoName')
const repoPath = params.get('repoPath')
const owner = params.get('account')

const oAuthProvider = store.state.oAuthProvider

let message

if (!repoName || !owner || !oAuthProvider) {
if (!repoName) {
message = `Missing parameter 'repoName' in URL`
if (!repoPath || !owner || !oAuthProvider) {
if (!repoPath) {
message = `Missing parameter 'repoPath' in URL`
} else {
if (!owner) {
message = `Missing parameter 'account' in URL`
Expand All @@ -65,19 +62,18 @@ export const setCurrentRepositoryFromQuerystring = async (
}

const origin = oAuthProvider.origin
const repoId = makeRepoId(owner, repoName)

const scribouilliGitRepo = new ScribouilliGitRepo({
owner,
repoName,
repoId,
repoPath,
origin: origin,
publicRepositoryURL: makePublicRepositoryURL(owner, repoName, origin),
gitServiceProvider: getOAuthServiceAPI(),
})

store.mutations.setCurrentRepository(scribouilliGitRepo)

const { repoId } = scribouilliGitRepo

const gitAgent = new GitAgent({
repoId,
remoteURL: `${origin}/${repoId}.git`,
Expand Down
25 changes: 10 additions & 15 deletions assets/scripts/actions/setup.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import page from 'page'

import store, { ResolutionOption } from './../store.ts'
import ScribouilliGitRepo, {
makePublicRepositoryURL,
makeRepoId,
} from './../scribouilliGitRepo.ts'
import ScribouilliGitRepo from './../scribouilliGitRepo.ts'
import { getOAuthServiceAPI } from './../oauth-services-api/index.ts'
import { makeAtelierListPageURL } from './../routes/urls.ts'
import { logMessage } from './../utils.ts'
Expand Down Expand Up @@ -71,14 +68,14 @@ export const setupLocalRepository = async (): Promise<
*/
export function guessBaseURL({
owner,
repoName,
repoPath,
origin,
}: ScribouilliGitRepo): string {
if (origin === 'https://github.com') {
const publishedHostname = `${owner.toLowerCase()}.github.io`
repoName = repoName.toLowerCase()
repoPath = repoPath.toLowerCase()

return publishedHostname === repoName ? '' : `/${repoName}`
return publishedHostname === repoPath ? '' : `/${repoPath}`
} else if (
origin === 'https://gitlab.com' ||
origin === 'https://git.scribouilli.org'
Expand Down Expand Up @@ -116,7 +113,8 @@ export const createRepositoryForCurrentAccount = async (
throw new TypeError(`missing login in createRepositoryForCurrentAccount`)
}

const escapedRepoName = repoName
// On creation, on both GitHub and GitLab, the name matches the repository path
const escapedRepoPath = repoName
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.replace(/[^\w\.-]/g, '-') // see https://stackoverflow.com/a/59082561
Expand All @@ -133,24 +131,21 @@ export const createRepositoryForCurrentAccount = async (

const scribouilliGitRepo = new ScribouilliGitRepo({
owner: owner,
repoName: escapedRepoName,
repoPath: escapedRepoPath,
origin: origin,
publicRepositoryURL: makePublicRepositoryURL(
owner,
escapedRepoName,
origin,
),
gitServiceProvider: getOAuthServiceAPI(),
})

const { repoId } = scribouilliGitRepo

store.mutations.setCurrentRepository(scribouilliGitRepo)

return (
getOAuthServiceAPI()
.createDefaultRepository(scribouilliGitRepo, template)
.then(({ remoteURL }) => {
const gitAgent = new GitAgent({
repoId: makeRepoId(owner, escapedRepoName),
repoId,
remoteURL: remoteURL,
onMergeConflict: (
resolutionOptions: ResolutionOption[] | undefined,
Expand Down
22 changes: 12 additions & 10 deletions assets/scripts/components/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import type { BuildStatus } from '../types/git.ts'
import type { ScribouilliState } from '../store.ts'
import { makeAtelierListPageURL } from '../routes/urls.ts'
import { makeAtelierListArticlesURL } from '../routes/atelier-list-articles.ts'

interface Props {
buildStatus: BuildStatus
Expand All @@ -20,18 +22,18 @@
let buildStatusClass = $derived(buildStatus ? `build-${buildStatus}` : undefined)
let publishedWebsiteURL: Promise<string> | undefined = $derived(currentRepository?.publishedWebsiteURL)
let repositoryURL: string | undefined = $derived(currentRepository?.publicRepositoryURL)
let repoName: string | undefined = $derived(currentRepository?.repoName)
let account: string | undefined = $derived(currentRepository?.owner)
let repoPath: string | undefined = $derived(currentRepository?.repoPath)
let account: string | undefined = $derived(currentRepository?.owner)
let homeURL: string | undefined =
$derived(repoName && account
? `/atelier-list-pages?repoName=${repoName}&account=${account}`
$derived(currentRepository
? makeAtelierListPageURL(currentRepository)
: '/')

function makeResolutionDesynchronisationURL(account: string, repoName: string): string {
return `/resolution-desynchronisation?account=${account}&repoName=${repoName}`
function makeResolutionDesynchronisationURL(account: string, repoPath: string): string {
return `/resolution-desynchronisation?account=${account}&repoPath=${repoPath}`
}

let resolutionURL: string = $derived(makeResolutionDesynchronisationURL(account || '', repoName || ''));
let resolutionURL: string = $derived(makeResolutionDesynchronisationURL(account || '', repoPath || ''));
</script>

<header>
Expand Down Expand Up @@ -76,23 +78,23 @@
<nav>
<ul>
<li>
<a href="/atelier-list-pages?repoName={repoName}&account={account}">
<a href="{makeAtelierListPageURL(currentRepository)}">
Pages
</a>
</li>

{#if showArticles}
<li>
<a
href="/atelier-list-articles?repoName={repoName}&account={account}"
href="{makeAtelierListArticlesURL(currentRepository)}"
>
Articles
</a>
</li>
{/if}

<li>
<a href="/settings?repoName={repoName}&account={account}">
<a href="/settings?repoPath={repoPath}&account={account}">
Paramètres
</a>
</li>
Expand Down
6 changes: 3 additions & 3 deletions assets/scripts/components/screens/AfterOauthLogin.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script lang="ts">
import Skeleton from "./../Skeleton.svelte";
import SiteCreationLoader from "./../loaders/SiteCreationLoader.svelte";
import type { GithubRepository } from "../../types/git";
import type { GitRepository } from "../../types/git";

interface Props {
currentUserReposP: Promise<GithubRepository[] | void>
currentUserReposP: Promise<GitRepository[] | void>
}

let { currentUserReposP }: Props = $props();

</script>

<Skeleton>
Expand Down
15 changes: 8 additions & 7 deletions assets/scripts/components/screens/SelectCurrentSite.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

import Skeleton from "./../Skeleton.svelte";
import Loader from "./../loaders/Loader.svelte";
import type { GithubRepository } from "../../types/git"
import type { GitRepository } from "../../types/git"

interface Props {
currentAccount: string | Promise<string> | undefined
currentAccountRepositories: GithubRepository[]
currentAccountRepositories: GitRepository[]
}

let { currentAccount, currentAccountRepositories }: Props = $props();

let repo: GithubRepository | undefined = $state()
let repo: GitRepository | undefined = $state()
let loading = $state(false);

// @ts-ignore
Expand All @@ -26,13 +26,14 @@

// @ts-ignore
const onSubmit = (e) => {
e.preventDefault();
e.preventDefault()

if (!repo) return

loading = true;
loading = true
const repoPath = repo.path || repo.name // In GitLab, the repository slug may differ from the name attribute (after repository renaming), while in GitHub, the name attribute corresponds to the repository slug

page(`/atelier-list-pages?repoName=${repo.name}&account=${repo.owner.login}`);
page(`/atelier-list-pages?repoPath=${repoPath}&account=${repo.owner.login}`);

loading = false;
};
Expand Down
10 changes: 5 additions & 5 deletions assets/scripts/components/screens/intern/ListContenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { makePageFrontMatter } from '../../../utils.ts'
import ScribouilliGitRepo from '../../../scribouilliGitRepo.ts'
import type { FileContenu } from '../../../types/atelier.ts';

interface Props {
buildStatus: any
listContenu?: FileContenu[]
Expand All @@ -29,8 +29,8 @@
conflict
}: Props = $props();

let repoName = $derived(currentRepository.repoName)
let account = $derived(currentRepository.owner)
let repoPath = $derived(currentRepository.repoPath)
let account = $derived(currentRepository.owner)
let modification = $state(false)

const gitAgent = store.state.gitAgent
Expand Down Expand Up @@ -78,7 +78,7 @@
{title}
</h2>
<a
href="{atelierPrefix}?repoName={repoName}&account={account}"
href="{atelierPrefix}?repoPath={repoPath}&account={account}"
class="btn btn__medium">{newContentButtonText}</a
>
</header>
Expand Down Expand Up @@ -113,7 +113,7 @@
</div>
{:else}
<a
href="{atelierPrefix}?path={encodeURIComponent(contenu.path)}&repoName={repoName}&account={account}"
href="{atelierPrefix}?path={encodeURIComponent(contenu.path)}&repoPath={repoPath}&account={account}"
>
Modifier</a
>
Expand Down
6 changes: 3 additions & 3 deletions assets/scripts/oauth-services-api/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class GitHubAPI implements OAuthServiceAPI {
}

async createDefaultRepository(
{ owner, repoName, publishedWebsiteURL }: ScribouilliGitRepo,
{ owner, repoPath, publishedWebsiteURL }: ScribouilliGitRepo,
template: GitSiteTemplate,
) {
// Generate a new repository from the theme repository
Expand All @@ -57,7 +57,7 @@ export default class GitHubAPI implements OAuthServiceAPI {
method: 'POST',
body: JSON.stringify({
owner,
name: repoName,
name: repoPath,
description: 'Mon site Scribouilli',
}),
},
Expand Down Expand Up @@ -96,7 +96,7 @@ export default class GitHubAPI implements OAuthServiceAPI {
method: 'PUT',
body: JSON.stringify({
owner,
repo: repoName,
repo: repoPath,
names: ['site-scribouilli'],
}),
})
Expand Down
Loading