This file contains hidden or 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
| import React, { useContext, useState } from "react"; | |
| import { BrowserRouter, Link } from "react-router-dom"; | |
| import { Route, Switch } from "react-router"; | |
| import { format, formatDistance, formatRelative } from "date-fns"; | |
| import nb from "date-fns/locale/nb"; | |
| import enUS from "date-fns/locale/en-US"; | |
| type AppLocale = "en" | "nb"; | |
| interface ApplicationTexts extends Record<AppLocale, string> { |
This file contains hidden or 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
| import org.jsonbuddy.JsonNode; | |
| import org.jsonbuddy.JsonObject; | |
| import java.io.FileInputStream; | |
| import java.io.IOException; | |
| import java.io.OutputStreamWriter; | |
| import java.net.HttpURLConnection; | |
| import java.net.URL; | |
| import java.nio.charset.StandardCharsets; | |
| import java.security.GeneralSecurityException; |
This file contains hidden or 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
| const english: ApplicationTexts = { | |
| standardTexts: { | |
| submit: "Submit", | |
| }, | |
| personTexts: { | |
| givenName: "First name", | |
| familyName: "Last name", | |
| title: "Title", | |
| header: "Enter your details" | |
| } |
This file contains hidden or 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
| interface ApplicationTexts { | |
| standardTexts: { | |
| submit: string; | |
| }; | |
| personTexts: { | |
| givenName: string; | |
| familyName: string; | |
| title: string; | |
| header: string; | |
| }; |
This file contains hidden or 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
| export default function App() { | |
| const [language, setLanguage] = useState(english); | |
| return ( | |
| <ApplicationTextsContext.Provider value={language}> | |
| <div className="App"> | |
| <MainPage /> | |
| <SelectLanguage onChangeLanguage={setLanguage} /> | |
| </div> | |
| </ApplicationTextsContext.Provider> | |
| ); |
This file contains hidden or 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
| function MainPage() { | |
| const { standardTexts, personTexts: texts } = useContext( | |
| ApplicationTextsContext | |
| ); | |
| return ( | |
| <div> | |
| <h2>{texts.header}</h2> | |
| <div> | |
| <label>{texts.givenName}:</label> | |
| <input /> |
This file contains hidden or 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
| function useLoader<T>( | |
| loadingFunction: () => Promise<T>, | |
| deps: DependencyList[] = [] | |
| ) { | |
| const [data, setData] = useState<T | undefined>(); | |
| const [loading, setLoading] = useState(true); | |
| const [error, setError] = useState<Error | undefined>(); | |
| async function reload() { | |
| setData(undefined); |
This file contains hidden or 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
| function TodoList({ list }: { list: string }) { | |
| const { data, error, loading, reload } = useLoader( | |
| async () => listTodos(list), | |
| [list] | |
| ); | |
| return ( | |
| <> | |
| <h2>Items in {list}</h2> | |
| {loading && <Spinner />} | |
| {error && <ErrorView error={error} reload={reload} />} |
This file contains hidden or 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
| var authentication = "key=a...&token=9..."; | |
| var idBoard = "592...."; | |
| var inboxList = "592..."; | |
| var updatedLabel = "592...."; | |
| function getField(itemResponses, fieldName) { | |
| var titles = []; | |
| for (var i in itemResponses) { | |
| if (itemResponses[i].getItem().getTitle() === fieldName && itemResponses[i].getResponse().length > 0) { |
This file contains hidden or 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
| public class AnnotationScanner { | |
| protected void scanForAnnotations(final String javaPackage, WebAppContext webapp) throws Exception { | |
| Set<AnnotationParser.Handler> handlers = new HashSet<>(); | |
| handlers.add(new WebServletAnnotationHandler(webapp)); | |
| handlers.add(new WebFilterAnnotationHandler(webapp)); | |
| handlers.add(new WebListenerAnnotationHandler(webapp)); | |
| AnnotationParser annotationParser = new AnnotationParser(); | |
| for (URL url : ((URLClassLoader) getClass().getClassLoader()).getURLs()) { |
NewerOlder