-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2f6977
commit e6204c0
Showing
30 changed files
with
2,213 additions
and
702 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
import Countly from 'countly-sdk-web' | ||
|
||
window.addEventListener('turbo:load', () => { | ||
Countly.init({ | ||
app_key: '8696ce4d4dfb160bb24351cb04ae16be868501f6', | ||
url: 'https://countly.chinour.dev', | ||
debug: process.env.NODE_ENV !== 'production', | ||
}); | ||
if (process.env.NODE_ENV === 'production') { | ||
window.addEventListener('turbo:load', () => { | ||
Countly.init({ | ||
app_key: '8696ce4d4dfb160bb24351cb04ae16be868501f6', | ||
url: 'https://countly.chinour.dev', | ||
debug: process.env.NODE_ENV !== 'production', | ||
}); | ||
|
||
// Enable tracking | ||
Countly.track_sessions(); | ||
Countly.track_pageview(); | ||
Countly.track_errors(); | ||
// Enable tracking | ||
Countly.track_sessions(); | ||
Countly.track_pageview(); | ||
Countly.track_errors(); | ||
|
||
// User click on any article suggestion at the end of article | ||
document.querySelectorAll('.analytics-suggestions').forEach((link) => { | ||
link.addEventListener('click', () => { | ||
console.debug('Suggestion click'); | ||
Countly.q.push(['add_event', {key: 'suggestion_click'}]); | ||
}) | ||
// User click on any article suggestion at the end of article | ||
document.querySelectorAll('.analytics-suggestions').forEach((link) => { | ||
link.addEventListener('click', () => { | ||
console.debug('Suggestion click'); | ||
Countly.q.push(['add_event', {key: 'suggestion_click'}]); | ||
}) | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import moment from "moment"; | ||
|
||
export default function (props) { | ||
return <time className={props.className} dateTime={props.dateTime}> | ||
{moment(Date.parse(props.dateTime), null, 'fr').fromNow()} | ||
</time> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import axios from "axios"; | ||
import DateTime from "../component/DateTime"; | ||
|
||
export default function (props) { | ||
const [comments, setComments] = useState(null); | ||
const [inputFieldOpened, setInputFieldOpened] = useState(false); | ||
const [userComment, setUserComment] = useState(''); | ||
const [username, setUsername] = useState(''); | ||
|
||
async function fetchComments() { | ||
const response = await axios.get(`/api/article/${props.articleId}/comments`); | ||
if (response.status === 200) { | ||
setComments(response.data); | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
fetchComments().then(_ => console.debug('comments loaded')); | ||
}, []); | ||
|
||
return <div> | ||
<h2 className="text-2xl font-bold">Discussion {comments && | ||
<span className="text-muted">({comments.length})</span>}</h2> | ||
|
||
<textarea | ||
name="comment" | ||
onFocus={() => setInputFieldOpened(true)} | ||
className="mt-4 p-2 w-full rounded dark:bg-zinc-700 bg-zinc-100" | ||
value={userComment} | ||
onChange={e => setUserComment(e.target.value)} | ||
rows={inputFieldOpened ? 5 : 3} | ||
placeholder="Participe à la discussion 💬"> | ||
</textarea> | ||
|
||
{inputFieldOpened && | ||
<div className="mt-2 mb-4 flex gap-2"> | ||
<input type="text" | ||
name="author" | ||
value={username} | ||
onChange={e => setUsername(e.target.value)} | ||
placeholder="Pseudonyme 👻" | ||
className="p-2 rounded dark:bg-zinc-700 bg-zinc-100 min-w-0"/> | ||
<button disabled={userComment.length < 1 || username.length < 1} | ||
className="rounded bg-blue-800 disabled:cursor-not-allowed disabled:opacity-50 p-2 text-white font-bold ms-auto"> | ||
Partager | ||
</button> | ||
</div>} | ||
|
||
<ul className="mt-4"> | ||
{comments && | ||
comments.map(({id, author, publishAt, content}) => ( | ||
<li key={id} className="my-4 p-4 rounded border border-zinc-400"> | ||
<p className="mb-2"> | ||
<span className="text-lg font-bold">{author}</span> | ||
<span className="font-bold text-muted"> • </span> | ||
<DateTime className="text-muted" dateTime={publishAt}></DateTime> | ||
</p> | ||
<p className="text-justify">{content}</p> | ||
</li> | ||
))} | ||
</ul> | ||
</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.