under construction

This commit is contained in:
2021-08-20 18:07:12 +09:00
parent c1d7e9a5ba
commit 2ee272598a
120 changed files with 20026 additions and 129 deletions

7
.gitignore vendored
View File

@@ -30,3 +30,10 @@ out/
/.nb-gradle/
### VS Code ###
.vscode/
### NODE ###
!**/node_modules/
/mdc-theme/node_modules/
/mdc-theme/dist/
/elex-theme/node_modules/
/elex-theme/dist/
/persona/

View File

@@ -0,0 +1,32 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
plugins {
id("elex-springboot")
id("org.springframework.boot") version "2.5.3"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
}
version = "1.0.0"
description = "Address Finder"
tasks.bootJar{
enabled = false
}
tasks.jar {
enabled = true
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}

View File

@@ -0,0 +1,21 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.address_finder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/address-finder")
public class AppController {
@GetMapping("/**")
public String index(){
return "address-finder";
}
}

View File

@@ -0,0 +1,8 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.address_finder;

View File

@@ -0,0 +1,3 @@
<h1 th:text="${title}"></h1>
<p>Hahaha</p>
<footer th:replace="~{fragments/footer :: footer}"></footer>

View File

@@ -1,6 +1,14 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
plugins {
id("elex-springboot")
id("org.springframework.boot") version "2.4.2"
id("org.springframework.boot") version "2.5.3"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("org.asciidoctor.convert") version "1.5.8"
}
@@ -9,6 +17,12 @@ group = "com.elex-project"
version = "0.0.1-SNAPSHOT"
description = ""
repositories {
maven {
url = uri("https://repository.elex-project.com/repository/maven")
}
}
ext {
set("snippetsDir", file("build/generated-snippets"))
}
@@ -25,9 +39,17 @@ tasks.asciidoctor {
}
dependencies {
//implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-mustache")
implementation(project(":sitemap"))
implementation(project(":linkback"))
implementation(project(":address-finder"))
implementation("com.vladsch.flexmark:flexmark-all:0.62.2")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
//implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-cache")
implementation("org.springframework.boot:spring-boot-starter-web")
//implementation ("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
@@ -36,6 +58,7 @@ dependencies {
compileOnly("org.projectlombok:lombok")
developmentOnly("org.springframework.boot:spring-boot-devtools")
//runtimeOnly("org.mariadb.jdbc:mariadb-java-client")
runtimeOnly("com.h2database:h2")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
annotationProcessor("org.projectlombok:lombok")

View File

@@ -0,0 +1,34 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.stereotype.Component;
@Slf4j
@EnableCaching
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Component
static class Runner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
}
}
}

View File

@@ -0,0 +1,54 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.config;
import com.elex_project.asgard.supplements.Markdown;
import com.elex_project.asgard.view.AsgardLocaleResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
@Configuration
public class Config {
/*@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
*/
/*@Bean
public HttpTraceRepository httpTraceRepository() {
return new InMemoryHttpTraceRepository();
}*/
/**
* Locale resolver, 디폴트 로캐일을 지정한다.
*/
@Bean
public LocaleResolver localeResolver() {
/*SessionLocaleResolver localeResolver = new SessionLocaleResolver();
localeResolver.setDefaultLocale(Locale.ENGLISH);
localeResolver.setLocaleAttributeName("lc");
localeResolver.setTimeZoneAttributeName("tz");
return localeResolver;*/
return new AsgardLocaleResolver();
}
/**
* Markdown parser
*
* @return
*/
@Bean
public Markdown markdown() {
return new Markdown();
}
}

View File

@@ -0,0 +1,32 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.config;
import com.elex_project.asgard.view.AsgardLocaleChangeInterceptor;
import com.elex_project.asgard.view.ViewModelInterceptor;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class ViewConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(@NotNull InterceptorRegistry registry) {
registry.addInterceptor(new AsgardLocaleChangeInterceptor())
.addPathPatterns("/**");
registry.addInterceptor(new ViewModelInterceptor())
.addPathPatterns("/**");
/*registry.addInterceptor(new RequestLogInterceptor())
.addPathPatterns("/**");*/
}
}

View File

@@ -0,0 +1,8 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.config;

View File

@@ -0,0 +1,105 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.controller;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
abstract class BaseController {
/*@NotNull
protected Map<String, Object> map() {
final HashMap<String, Object> map = new HashMap<>();
map.put("html_lang", lang());
return map;
}
@NotNull
private String lang() {
return getHttpRequest()
.map(request -> request.getLocale().toLanguageTag())
.orElse("en");
}
@NotNull
protected URI getRequestURI() {
return getHttpRequest()
.map(request -> URI.create(request.getRequestURI()))
.orElse(URI.create("/"));
}
private Optional<ServletRequestAttributes> getRequestAttributes() {
return Optional
.ofNullable((ServletRequestAttributes) RequestContextHolder.getRequestAttributes());
}
protected Optional<HttpServletRequest> getHttpRequest() {
return getRequestAttributes()
.map(ServletRequestAttributes::getRequest);
}
protected Optional<HttpServletResponse> getHttpResponse() {
return getRequestAttributes()
.map(ServletRequestAttributes::getResponse);
}
@NotNull
protected String[] getAttributeNames() {
return getRequestAttributes()
.map(attr -> attr.getAttributeNames(RequestAttributes.SCOPE_REQUEST))
.orElse(new String[0]);
}
@NotNull
protected String[] getSessionAttributeNames() {
return getRequestAttributes()
.map(attr -> attr.getAttributeNames(RequestAttributes.SCOPE_SESSION))
.orElse(new String[0]);
}
@NotNull
protected Optional<Object> getAttribute(@NotNull final String key) {
return getRequestAttributes()
.map(attr -> attr.getAttribute(key, RequestAttributes.SCOPE_REQUEST));
}
@NotNull
protected Optional<Object> getSessionAttribute(@NotNull final String key) {
return getRequestAttributes()
.map(attr -> attr.getAttribute(key, RequestAttributes.SCOPE_SESSION));
}
protected void setAttribute(@NotNull final String key, final Object value) {
getRequestAttributes()
.ifPresent(attr -> attr.setAttribute(key, value, RequestAttributes.SCOPE_REQUEST));
}
protected void setSessionAttribute(@NotNull final String key, final Object value) {
getRequestAttributes()
.ifPresent(attr -> attr.setAttribute(key, value, RequestAttributes.SCOPE_SESSION));
}
protected void removeAttribute(@NotNull final String key) {
getRequestAttributes()
.ifPresent(attr -> attr.removeAttribute(key, RequestAttributes.SCOPE_REQUEST));
}
protected void removeSessionAttribute(@NotNull final String key) {
getRequestAttributes()
.ifPresent(attr -> attr.removeAttribute(key, RequestAttributes.SCOPE_SESSION));
}*/
}

View File

@@ -0,0 +1,112 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.controller;
import com.elex_project.asgard.service.SitemapService;
import com.elex_project.asgard.service.SyndicationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map;
/**
* @link http://www.robotstxt.org/robotstxt.html
* @link http://humanstxt.org/
*/
@Slf4j
@Controller
public class HomeController extends BaseController {
@Autowired
private SyndicationService syndicationService;
@Autowired
private SitemapService sitemapService;
@GetMapping(path = "/exception")
public void ex() throws Exception {
throw new Exception("Test Exception");
}
@GetMapping(path = "/exception2")
public void ex2() throws ResponseStatusException {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Test Exception");
}
@GetMapping(path = "/")
@ResponseStatus(HttpStatus.OK)
public String home(Model model) {
//final Map<String, Object> map = map();
//map.put("title", "Title~!");
return "home";
}
/**
* @return
* @link {https://www.sitemaps.org/ko/protocol.html}
*/
@GetMapping(path = "/sitemap.xml",
produces = {MediaType.APPLICATION_XML_VALUE})
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public String sitemap() {
return sitemapService.getSitemap();
}
/**
* @return
* @link {https://validator.w3.org/feed/docs/rss2.html}
*/
@GetMapping(path = "/rss.xml",
produces = {MediaType.APPLICATION_RSS_XML_VALUE})
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public String rss() {
return syndicationService.getRssSyndication();
//return "syndication/rss2";
}
/**
* @return
* @link {https://validator.w3.org/feed/docs/atom.html}
*/
@GetMapping(path = "/atom.xml",
produces = {MediaType.APPLICATION_ATOM_XML_VALUE})
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public String atom() {
return syndicationService.getAtomSyndication();
}
@PostMapping(path = "/trackback/{id}",
produces = {MediaType.APPLICATION_XML_VALUE})
@ResponseStatus(HttpStatus.OK)
public ModelAndView trackback(@PathVariable String id) {
return new ModelAndView();
}
@PostMapping(path = "/pingback",
produces = {MediaType.APPLICATION_XML_VALUE})
@ResponseStatus(HttpStatus.OK)
public ModelAndView pingback(@RequestParam String source, @RequestParam String target) {
return new ModelAndView();
}
@PostMapping(path = "/webmention",
produces = {MediaType.APPLICATION_XML_VALUE})
@ResponseStatus(HttpStatus.OK)
public ModelAndView webmention(@RequestParam String source, @RequestParam String target) {
return new ModelAndView();
}
}

View File

@@ -0,0 +1,70 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.controller;
import com.elex_project.asgard.service.NoteService;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.net.URI;
import java.util.List;
@Slf4j
@Controller
public class NoteController extends BaseController {
@Autowired
private NoteService noteService;
/*@GetMapping(path = "/*")
public ModelAndView reader(){
return new ModelAndView("document", map());
}*/
@GetMapping(path = "/*")
public ModelAndView editor(@RequestParam boolean edit, ModelAndView model) {
if (edit) {
model.setViewName("edit");
} else {
model.setViewName("document");
}
return model;
}
@PostMapping(path = "/*")
public ResponseEntity<String> update(@RequestBody String p) {
return ResponseEntity.created(URI.create("")).build();
//todo redirect -> get
}
@DeleteMapping(path = "/*")
public ResponseEntity<String> delete() {
return ResponseEntity.ok().build();
//todo redirect -> get
}
@PostMapping()
@ResponseStatus(HttpStatus.CREATED)
public String uploadFile(final @RequestParam("file") MultipartFile file,
final @NotNull RedirectAttributes redirectAttributes) {
//storageService.store(file);
// 업로드 후 새로 고침
redirectAttributes.addFlashAttribute("message",
"You successfully uploaded " + file.getOriginalFilename() + "!");
return "redirect:/";
}
}

View File

@@ -0,0 +1,8 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.controller;

View File

@@ -0,0 +1,84 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.model;
import com.elex_project.asgard.supplements.InetAddressConverter;
import com.elex_project.asgard.supplements.StringArrayConverter;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.persistence.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.Duration;
import java.time.LocalDateTime;
import static com.elex_project.asgard.supplements.RequestLogInterceptor.REQUEST_TIME;
@Slf4j
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "http_trace")
public class HttpTraceModel {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column
private LocalDateTime requestTime;
@Column
private Long elapsed;
@Column
private String requestUrl;
@Column
private String requestMethod;
@Column
private String userAgent;
@Column
private String referer;
@Column
@Convert(converter = StringArrayConverter.class)
private String[] acceptLang;
@Column
@Convert(converter = InetAddressConverter.class)
private InetAddress ipAddress;
public static HttpTraceModel of(final HttpServletRequest request, final HttpServletResponse response) {
final HttpTraceModel model = new HttpTraceModel();
model.requestUrl = request.getRequestURI();
model.requestMethod = request.getMethod();
model.userAgent = request.getHeader("User-Agent");
model.referer = request.getHeader("Referer");
final String acceptLang = request.getHeader("Accept-Language");
if (null != acceptLang) {
model.acceptLang = acceptLang.replaceAll(";q=[0-9.]*", "").split(",");
} else {
model.acceptLang = new String[0];
}
model.requestTime = (LocalDateTime) request.getAttribute(REQUEST_TIME);
if (null != model.requestTime) {
model.elapsed = Duration.between(model.requestTime, LocalDateTime.now()).toMillis();
}
String ip = request.getHeader("X-Forwarded-For");
if (null == ip) ip = request.getHeader("X-Real-Ip");
if (null == ip) ip = request.getRemoteAddr();
try {
model.ipAddress = InetAddress.getByName(ip);
} catch (UnknownHostException ignore) {
}
return model;
}
}

View File

@@ -0,0 +1,54 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.model;
import com.elex_project.asgard.supplements.StringArrayConverter;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import javax.persistence.*;
import java.time.LocalDateTime;
@Slf4j
@Data
@NoArgsConstructor
@Entity
@Table(name = "notes")
public class Note {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(unique = true, nullable = false)
private String url;
@Column
private String title;
@Column
private String description;
@Column
@Convert(converter = StringArrayConverter.class)
private String[] tags;
@Column
private boolean published;
@Column
private String content;
@Column
private String markdownContent;
@Column
@CreatedDate
private LocalDateTime createdOn;
@Column
@LastModifiedDate
private LocalDateTime modifiedOn;
public static Note of(){
return null;
}
}

View File

@@ -0,0 +1,11 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.model;
public class Pingback {
}

View File

@@ -0,0 +1,8 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.model;

View File

@@ -0,0 +1,8 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard;

View File

@@ -0,0 +1,16 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class NoteService {
}

View File

@@ -0,0 +1,16 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class PingbackService {
}

View File

@@ -0,0 +1,44 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.service;
import com.elex_project.asgard.sitemap.BaseSitemapService;
import com.elex_project.asgard.sitemap.Frequency;
import com.elex_project.asgard.sitemap.Sitemap;
import com.elex_project.asgard.sitemap.SitemapItem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Slf4j
@Service
@CacheConfig(cacheNames = "sitemap")
public class SitemapService extends BaseSitemapService {
@Override
protected Sitemap sitemap() {
final Sitemap sitemap = new Sitemap();
sitemap.addItem(SitemapItem.builder()
.loc("https://aaa.com/1")
.lastMod(LocalDateTime.now())
.changeFreq(Frequency.HOURLY)
.build());
sitemap.addItem(SitemapItem.builder()
.loc("https://aaa.com/2")
.lastMod(LocalDateTime.now())
.build());// todo
return sitemap;
}
//@CacheEvict(allEntries = true)
public void clearCaches() {
}
}

View File

@@ -0,0 +1,67 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.service;
import com.elex_project.asgard.syndication.BaseSyndicationService;
import com.elex_project.asgard.syndication.Syndication;
import com.elex_project.asgard.syndication.SyndicationItem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@Slf4j
@Service
//@CacheConfig(cacheNames = "templates/syndication")
public class SyndicationService extends BaseSyndicationService {
//@CacheEvict(allEntries = true)
public void clearCaches() {
}
@Override
protected Syndication syndication() {
final Syndication syndication = Syndication.builder()
.title("Elex Project")
.link("https://www.elex-project.com/")
.linkAtom("https://www.elex-project.com/atom")
.linkRss("https://www.elex-project.com/rss")
.description("Sample description")
.language(Locale.KOREAN)
.copyright("Copyright (c) 2021 Elex. All Rights Reserved.")
.imageUrl("https://www.elex-project.com/images/logo.png")
.lastBuildDate(LocalDateTime.now())
.item(SyndicationItem.builder()
.authorName("Elex")
.authorEmail("email@example.com")
.description("Sample article")
.modDate(LocalDateTime.now())
.pubDate(LocalDateTime.now())
.title("Sample title")
.url("https://something.com/1")
.build())
.item(SyndicationItem.builder()
.authorName("Elex")
.authorEmail("email@example.com")
.description("Sample article 2")
.modDate(LocalDateTime.now())
.pubDate(LocalDateTime.now())
.title("Sample title 2")
.url("https://something.com/2")
.build())
.build();
final List<SyndicationItem> items = new ArrayList<>();// todo
items.forEach(syndication::addItem);
return syndication;
}
}

View File

@@ -0,0 +1,16 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class TrackbackService {
}

View File

@@ -0,0 +1,8 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.service;

View File

@@ -0,0 +1,45 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.supplements;
import com.elex_project.abraxas.Stringz;
import lombok.extern.slf4j.Slf4j;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.net.InetAddress;
import java.net.UnknownHostException;
@Converter
@Slf4j
public class InetAddressConverter implements AttributeConverter<InetAddress, byte[]> {
private static final InetAddress NULL_IP;
static {
try {
NULL_IP = InetAddress.getByAddress(new byte[]{0, 0, 0, 0});
} catch (UnknownHostException e) {
throw new RuntimeException("Unable to make a Null-Ip.");
}
}
@Override
public byte[] convertToDatabaseColumn(final InetAddress attribute) {
return attribute.getAddress();
}
@Override
public InetAddress convertToEntityAttribute(final byte[] dbData) {
try {
return InetAddress.getByAddress(dbData);
} catch (UnknownHostException e) {
log.warn("Unable to convert IP address of {}", Stringz.fromBytes(dbData));
return NULL_IP;
}
}
}

View File

@@ -0,0 +1,105 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.supplements;
import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension;
import com.vladsch.flexmark.ext.aside.AsideExtension;
import com.vladsch.flexmark.ext.autolink.AutolinkExtension;
import com.vladsch.flexmark.ext.definition.DefinitionExtension;
import com.vladsch.flexmark.ext.footnotes.FootnoteExtension;
import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughSubscriptExtension;
import com.vladsch.flexmark.ext.ins.InsExtension;
import com.vladsch.flexmark.ext.media.tags.MediaTagsExtension;
import com.vladsch.flexmark.ext.superscript.SuperscriptExtension;
import com.vladsch.flexmark.ext.tables.TablesExtension;
import com.vladsch.flexmark.ext.typographic.TypographicExtension;
import com.vladsch.flexmark.ext.yaml.front.matter.AbstractYamlFrontMatterVisitor;
import com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterExtension;
import com.vladsch.flexmark.ext.youtube.embedded.YouTubeLinkExtension;
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.ast.KeepType;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.data.MutableDataSet;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class Markdown {
/**
* Flexmark Options
*
* @link {https://github.com/vsch/flexmark-java/wiki/Extensions}
*/
private static final DataHolder OPTIONS = new MutableDataSet()
.set(Parser.REFERENCES_KEEP, KeepType.LAST)
.set(HtmlRenderer.INDENT_SIZE, 2)
.set(HtmlRenderer.PERCENT_ENCODE_URLS, true)
// for full GFM table compatibility add the following table extension options:
.set(TablesExtension.COLUMN_SPANS, false)
.set(TablesExtension.APPEND_MISSING_COLUMNS, true)
.set(TablesExtension.DISCARD_EXTRA_COLUMNS, true)
.set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true)
.set(Parser.EXTENSIONS, Arrays.asList(
AnchorLinkExtension.create(),
AsideExtension.create(),
AutolinkExtension.create(),
DefinitionExtension.create(),
FootnoteExtension.create(),
StrikethroughSubscriptExtension.create(),
InsExtension.create(),
MediaTagsExtension.create(),
SuperscriptExtension.create(),
TablesExtension.create(),
TypographicExtension.create(),
YamlFrontMatterExtension.create(),
YouTubeLinkExtension.create()
))
.toImmutable();
private final Parser parser;
private final HtmlRenderer renderer;
public Markdown() {
this.parser = Parser.builder(OPTIONS).build();
this.renderer = HtmlRenderer.builder(OPTIONS).build();
}
public Node parse(final String md) {
return parser.parse(md);
}
public Node parse(final InputStream md) throws IOException {
return parse(new InputStreamReader(md));
}
public Node parse(final Reader md) throws IOException {
return parser.parseReader(md);
}
public String render(final String md) {
return renderer.render(parse(md));
}
public String render(final Node md) {
return renderer.render(md);
}
public Map<String, List<String>> frontMatter(final Node md) {
AbstractYamlFrontMatterVisitor visitor = new AbstractYamlFrontMatterVisitor();
visitor.visit(md);
return visitor.getData();
}
}

View File

@@ -0,0 +1,44 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.supplements;
import com.elex_project.asgard.model.HttpTraceModel;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
@Slf4j
public class RequestLogInterceptor implements HandlerInterceptor {
public static final String REQUEST_TIME = "elex.request.time";
@Override
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler)
throws Exception {
request.setAttribute(REQUEST_TIME, LocalDateTime.now());
return true;
}
@Override
public void postHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler, ModelAndView modelAndView)
throws Exception {
}
@Override
public void afterCompletion(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler, Exception ex)
throws Exception {
final HttpTraceModel traceModel = HttpTraceModel.of(request, response);
log.info("Http Trace: {}", traceModel);
}
}

View File

@@ -0,0 +1,26 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.supplements;
import com.elex_project.abraxas.Stringz;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter
public class StringArrayConverter implements AttributeConverter<String[], String> {
@Override
public String convertToDatabaseColumn(final String[] attribute) {
return Stringz.join(',', attribute);
}
@Override
public String[] convertToEntityAttribute(final String dbData) {
return dbData.split(",");
}
}

View File

@@ -0,0 +1,8 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.supplements;

View File

@@ -0,0 +1,20 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.view;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import static com.elex_project.asgard.view.AsgardLocaleResolver.PARAM;
public class AsgardLocaleChangeInterceptor extends LocaleChangeInterceptor {
public AsgardLocaleChangeInterceptor() {
this.setParamName(PARAM);
this.setIgnoreInvalidLocale(true);
}
}

View File

@@ -0,0 +1,71 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.view;
import com.elex_project.abraxas.I18n;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* 로케일 리졸버
* AcceptHeaderLocaleResolver를 기본 정책으로하되, GET 파라미터로 로캐일 변환이 가능하도록 한다.
*
* @author Elex
*/
@Slf4j
public class AsgardLocaleResolver implements LocaleResolver {
@Value("asgard.locale.param:lang")
static String PARAM;
/**
* 지원되는 로캐일 목록. 첫 번째 로캐일은 기본 로캐일로 사용된다.
*/
private static final List<Locale> supportedLocales = List
.of(Locale.KOREAN, Locale.ENGLISH);
private final AcceptHeaderLocaleResolver acceptHeaderLocaleResolver;
public AsgardLocaleResolver() {
acceptHeaderLocaleResolver = new AcceptHeaderLocaleResolver();
acceptHeaderLocaleResolver.setSupportedLocales(supportedLocales);
acceptHeaderLocaleResolver.setDefaultLocale(Locale.ENGLISH);
}
@Override
public @NotNull Locale resolveLocale(@NotNull HttpServletRequest request) {
String lang = request.getParameter(PARAM);
if (null == lang) {
return acceptHeaderLocaleResolver.resolveLocale(request);
} else {
Locale loc = new Locale(lang);
List<Locale.LanguageRange> priorityList = new ArrayList<>();
priorityList.add(new Locale.LanguageRange(loc.toLanguageTag(), 1.0));
priorityList.add(new Locale.LanguageRange(loc.getLanguage(), 0.9));
priorityList.add(new Locale.LanguageRange(Locale.ENGLISH.getLanguage(), 0.3));
Locale pick = I18n.pickLocale(priorityList, supportedLocales, Locale.ENGLISH);
log.debug("Picked locale: {} amongst {}", pick, priorityList);
return pick;
}
}
@Override
public void setLocale(@NotNull HttpServletRequest request, HttpServletResponse response, Locale locale) {
//this.locale = locale;
}
}

View File

@@ -0,0 +1,23 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.view;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ViewModelInterceptor implements HandlerInterceptor {
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
if (null != modelAndView) {
modelAndView.addObject("title", "Title~!!!");
}
}
}

View File

@@ -0,0 +1,8 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.view;

View File

@@ -1,15 +0,0 @@
package com.elex_project.freesia;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@Slf4j
@SpringBootApplication
public final class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,39 +0,0 @@
package com.elex_project.freesia;
import com.samskivert.mustache.Mustache;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.mustache.MustacheEnvironmentCollector;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.web.client.RestTemplate;
@Configuration
public final class Config {
@Value("elex.view.template.default")
private String templateDefaultValue;
@Bean
public Mustache.Compiler mustacheCompiler(
Mustache.TemplateLoader templateLoader,
Environment environment) {
MustacheEnvironmentCollector collector
= new MustacheEnvironmentCollector();
collector.setEnvironment(environment);
return Mustache.compiler()
.defaultValue(templateDefaultValue)
.withLoader(templateLoader)
.withCollector(collector);
}
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
/*@Bean
public HttpTraceRepository httpTraceRepository() {
return new InMemoryHttpTraceRepository();
}*/
}

View File

@@ -1,19 +0,0 @@
package com.elex_project.freesia.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@RestController
public class Home {
@GetMapping(value = "/")
public ModelAndView home() {
final Map<String, Object> map = new HashMap<>();
return new ModelAndView("home", map);
}
}

View File

@@ -1 +0,0 @@
package com.elex_project.freesia.controller;

View File

@@ -1 +0,0 @@
package com.elex_project.freesia.model;

View File

@@ -1 +0,0 @@
package com.elex_project.freesia;

View File

@@ -1 +0,0 @@
package com.elex_project.freesia.view;

View File

@@ -1,39 +1,82 @@
elex:
view:
template:
default: "[!UNDEFINED]"
server:
port: 8080
asgard:
locale:
param: lang
spring:
application:
name: Freesia
name: Asgard
jackson:
date-format: yyyy-MM-dd'T'HH:mm:ss
datasource:
url: jdbc:mariadb://localhost:3306/freesia
driver-class-name: org.mariadb.jdbc.Driver
url: jdbc:h2:~/asgard/test; #jdbc:mariadb://localhost:3306/asgard
driver-class-name: org.h2.Driver #org.mariadb.jdbc.Driver
username: elex
password: test
h2:
console:
enabled: true
path: /h2-console
jpa:
open-in-view: false
generate-ddl: true
show-sql: true
hibernate:
ddl-auto: none
ddl-auto: update
database-platform: org.hibernate.dialect.H2Dialect
thymeleaf:
suffix: .html
messages:
basename: i18n/messages
fallback-to-system-locale: false
security:
user:
name: elex
password: test
logging:
path: ${user.home}/logs/freesia
path: ${user.home}/asgard/logs
level:
root: debug
servlet:
multipart:
enabled: true
max-file-size: 1MB
max-request-size: 10MB
server:
port: 8080
server-header: Elex Project
error:
path: /error
whitelabel:
enabled: true
tomcat:
accept-count: 100
accesslog:
enabled: true
pattern: "%{yyyy-MM-dd HH:mm:ss}t\t%s\t%r\t%{User-Agent}i\t%{Referer}i\t%a\t%b\t%D"
directory: ${user.home}/asgard/accesslog
max-days: 90
rotate: true
suffix: .log
max-connections: 8192
remote-ip:
host-header: X-Forwarded-Host
port-header: X-Forwarded-Port
protocol-header: X-Forwarded-Proto
remote-ip-header: X-Forwarded-For
servlet:
encoding:
charset: utf-8
force-response: true
---
spring:
config:
active:
on-profile: production
server:
tomcat:
accesslog:
directory: /var/log/asgard/accesslog
logging:
path: /var/log/freesia
path: /var/log/asgard
level:
root: info

View File

@@ -0,0 +1,9 @@
ELEX's _ .-') .-') _ ('-.
( \( -O ) ( OO ) ) ( OO ).-.
,--. .-'),-----. ,--. ,--. ,------. ,--./ ,--,' / . --. / ,--.
.-')| ,|( OO' .-. ' | | | | | /`. '| \ | |\ | \-. \ | |.-')
( OO |(_|/ | | | | | | | .-') | / | || \| | ).-'-' | | | | OO )
| `-'| |\_) | |\| | | |_|( OO )| |_.' || . |/ \| |_.' | | |`-' |
,--. | | \ | | | | | | | `-' /| . '.'| |\ | | .-. |(| '---.'
| '-' / `' '-' '(' '-'(_.-' | |\ \ | | \ | | | | | | |
`-----' `-----' `-----' `--' '--'`--' `--' `--' `--' `------'

View File

@@ -0,0 +1,8 @@
#
# Project Asgard
#
# Copyright (c) 2021. Elex. All Rights Reserved.
# https://www.elex-project.com/
#
hello.text = Hello

View File

@@ -0,0 +1,8 @@
#
# Project Asgard
#
# Copyright (c) 2021. Elex. All Rights Reserved.
# https://www.elex-project.com/
#
hello.text = 안녕

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
/* TEAM */
Boss: Elex
Site: https://www.elex.pe.kr/
Facebook:
/* THANKS */
Name:
/* SITE */
Front-end: HTML5, CSS3, Javascript, Material Design Components, Node-js(yarn, webpack, babel), Scss
Back-end: Spring-boot, Mustache, Hibernate
Server: Docker, MariaDB, Tomcat, Nginx, Linux

View File

@@ -0,0 +1,3 @@
User-agent: *
Disallow: /cgi-bin/
Sitemap: https://www.elex-project.com/sitemap.xml

View File

@@ -0,0 +1,167 @@
<!DOCTYPE html>
<html lang="{{html_lang}}">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
{{> fragments/meta}}
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<link rel="author" href="/humans.txt" />
<link rel="stylesheet" href="/bundle.css" />
<title>{{title}}</title>
<script src="/bundle.js"></script>
</head>
<body>
<aside id="layout-drawer" class="mdc-drawer mdc-drawer--dismissible">
<div class="mdc-drawer__header">
<p>Hello</p>
</div>
<div class="mdc-drawer__content">
<nav class="mdc-list mdc-list--dense">
<a class="mdc-list-item mdc-list-item--activated" href="#" aria-current="page">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Inbox</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Outgoing</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts Drafts Drafts Drafts</span>
</a>
<a class="mdc-list-item mdc-list-item--depth-1" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item mdc-list-item--depth-1" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts Drafts Drafts Drafts</span>
</a>
<a class="mdc-list-item " href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item mdc-list-item--depth-2" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts Drafts Drafts Drafts Drafts Drafts Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
</nav>
</div>
</aside>
<div id="layout-content" class="mdc-drawer-app-content">
<header class="mdc-top-app-bar mdc-top-app-bar--fixed">
<div class="mdc-elevation-overlay"></div>
<div class="mdc-top-app-bar__row">
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
<button class="material-icons mdc-top-app-bar__navigation-icon mdc-icon-button"
aria-label="Open navigation menu">menu</button>
<span class="mdc-top-app-bar__title">{{title}}</span>
</section>
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end" role="toolbar">
<button class="material-icons mdc-top-app-bar__action-item mdc-icon-button"
aria-label="Favorite">favorite</button>
<button class="material-icons mdc-top-app-bar__action-item mdc-icon-button"
aria-label="Search">search</button>
<div class="mdc-menu-surface--anchor">
<button id="btn-overflow" class="material-icons mdc-top-app-bar__action-item mdc-icon-button"
aria-label="Options">more_vert</button>
<div class="mdc-menu mdc-menu-surface">
<ul class="mdc-list" role="menu" aria-hidden="true" aria-orientation="vertical" tabindex="-1">
<li class="mdc-list-item" role="menuitem">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">A Menu Item</span>
</li>
<li class="mdc-list-item" role="menuitem">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Another Menu Item</span>
</li>
</ul>
</div>
</div>
</section>
</div>
</header>
<div id="layout-main" class="mdc-top-app-bar--fixed-adjust">
<main class="mdc-layout-grid">
<article>
<h1>Heading 1</h1>
<p>Ha<em>Hehe</em>hoho.</p>
<button class="mdc-button mdc-button--raised">
<div class="mdc-button__ripple"></div>
<span class="mdc-button__label">Button</span>
</button>
<div>
<label class="mdc-text-field mdc-text-field--filled username">
<span class="mdc-text-field__ripple"></span>
<input type="text" class="mdc-text-field__input" aria-labelledby="username-label" name="username">
<span class="mdc-floating-label" id="username-label">Username</span>
<span class="mdc-line-ripple"></span>
</label>
<label class="mdc-text-field mdc-text-field--filled password">
<span class="mdc-text-field__ripple"></span>
<input type="password" class="mdc-text-field__input" aria-labelledby="password-label" name="password">
<span class="mdc-floating-label" id="password-label">Password</span>
<span class="mdc-line-ripple"></span>
</label>
</div>
<blockquote>
Hahaha
</blockquote>
<p>
동해물과 백두산이 마르고 닳도록
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna
aliqua. <strong>Ut enim ad minim</strong> veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.
Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.
Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</article>
</main>
<footer class="mdc-layout-grid">
<p>Copyright &copy; 2021</p>
</footer>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<title>{{status}} - {{message}}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono&family=Ubuntu+Mono&display=swap" rel="stylesheet"> <style>
html {font-family: 'Ubuntu Mono', monospace; font-size: 17px; line-height: 1.3;}
body{background-color: #404552; color: #c8c8c8;}
input {background: none; color: inherit; outline: none; border: 0; appearance: none;}
.green {color: #adff2f;} .blue {color: #5294e2;}
.inline {display:flex;} .inline > *:last-child {flex-grow: 1;}
</style>
</head>
<body>
<p class="inline">
<span class="green">www-user@elex-project.com</span><span>:</span>
<span class="blue">{{path}}</span><span>$&nbsp;</span><span>http get {{path}}</span>
</p>
<p>{{status}} - {{message}}</p>
<p>Trace:<br /> {{trace}}</p>
<p class="inline">
<span class="green">www-user@elex-project.com</span><span>:</span>
<span class="blue">{{path}}</span><span>$&nbsp;</span><input type="text"/>
</p>
</body>
</html>

View File

@@ -0,0 +1,13 @@
<!doctype html>
<html>
<head>
<title>{{status}} - {{message}}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p>Oops-404!</p>
<h1>{{status}}</h1>
<p>{{message}}</p>
</body>
</html>

View File

@@ -1 +0,0 @@
<p>Haha</p>

View File

@@ -0,0 +1,3 @@
<footer th:fragment="footer">
Copyright &copy;
</footer>

View File

@@ -0,0 +1,14 @@
<head th:fragment="meta">
<meta property="og:title" content="{{title}}" />
<meta property="og:url" content="{{url}}" />
<meta name="description" property="og:description" content="{{description}}" />
<meta property="og:locale" content="{{html_lang}}" />
<meta property="og:site_name" content="Elex Project" />
<meta property="og:image" content="{{image}}" />
<meta property="og:type" content="article" />
<meta property="og:article:section" content="{{section}}" />
<meta name="keyword" property="og:article:tag" content="{{tag}}" />
<meta property="og:article:published_time" content="{{published_time}}" />
<meta property="og:article:modified_time" content="{{modified_time}}" />
<meta name="author" property="og:article:author" content="{{author}}"/>
</head>

View File

@@ -0,0 +1,40 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" th:lang="${#locale.language}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title th:text="${title}">{{title}}</title>
<th:block th:include="~{fragments/meta :: meta}"></th:block>
<link rel="stylesheet" href="/persona.min.css" />
<script>
let toggle = function () {
const elem = document.querySelector(".layout");
elem.classList.toggle("closed");
};
</script>
</head>
<body>
<div class="layout">
<div class="sidebar">
<nav class="nav">
<ul>
</ul>
</nav>
</div>
<header class="header">
<span class="icon-button material-icons" onclick="toggle();">menu</span>
<h1 class="grow" th:text="${title}">{{title}}</h1>
</header>
<div class="main">
<main>
<p th:text="#{hello.text}">{{#i18n}}hello.text{{/i18n}}</p>
<p>...</p>
</main>
<footer th:replace="~{fragments/footer :: footer}">
</footer>
</div>
</div>
</body>
</html>

View File

@@ -1,9 +0,0 @@
<html>
<head>
</head>
<body>
<p>Hello</p>
{{>fragments/a}}
</body>
</html>

View File

@@ -1,4 +1,11 @@
package com.elex_project.freesia;
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

View File

@@ -0,0 +1,39 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.supplements;
import com.elex_project.abraxas.Console;
import com.elex_project.abraxas.IOz;
import com.vladsch.flexmark.util.ast.Node;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
class MarkdownTest {
@Test
void render() throws IOException {
String s = IOz.readStringFrom(getClass().getResourceAsStream("/sample.md"));
Markdown markdown = new Markdown();
Node doc = markdown.parse(s);
String html = markdown.render(doc);
Console.writeLine(html);
Map<String, List<String>> frontMatter = markdown.frontMatter(doc);
for (String key : frontMatter.keySet()) {
Console.write(key);
for (String v : frontMatter.get(key)) {
Console.write(v);
Console.write(" ");
}
Console.writeLine();
}
}
}

View File

@@ -1,3 +1,10 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
plugins {
id("com.github.ben-manes.versions") version "0.36.0"

View File

@@ -1,5 +1,5 @@
/*
* Project Freesia
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/

View File

@@ -1,15 +1,16 @@
import org.gradle.kotlin.dsl.repositories
/*
* Project Freesia
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
import org.gradle.kotlin.dsl.repositories
plugins{
java
}
java {
withSourcesJar()
withJavadocJar()
@@ -25,11 +26,13 @@ configurations {
extendsFrom(testAnnotationProcessor.get())
}
}
repositories {
maven {
url = uri("https://repository.elex-project.com/repository/maven")
}
}
tasks.jar {
manifest {
attributes(
@@ -37,11 +40,12 @@ tasks.jar {
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "ELEX co.,pte.",
"Automatic-Module-Name" to "com.elex_project.freesia"
"Automatic-Module-Name" to "com.elex_project.asgard"
)
)
}
}
tasks.compileJava {
options.encoding = "UTF-8"
}
@@ -49,9 +53,11 @@ tasks.compileJava {
tasks.compileTestJava {
options.encoding = "UTF-8"
}
tasks.test {
useJUnitPlatform()
}
tasks.javadoc {
if (JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
@@ -61,7 +67,10 @@ tasks.javadoc {
(options as StandardJavadocDocletOptions).docEncoding = "UTF-8"
}
dependencies {
implementation("org.slf4j:slf4j-api:1.7.30")
implementation("org.jetbrains:annotations:20.1.0")
implementation("org.jetbrains:annotations:22.0.0")
implementation("com.elex-project:abraxas:4.7.2")
}

View File

@@ -0,0 +1,21 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
plugins{
id("elex-base")
`java-library`
}
dependencies {
compileOnly("org.projectlombok:lombok:1.18.16")
annotationProcessor("org.projectlombok:lombok:1.18.16")
testAnnotationProcessor("org.projectlombok:lombok:1.18.16")
testImplementation("ch.qos.logback:logback-classic:1.2.3")
testImplementation("org.junit.jupiter:junit-jupiter:5.7.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
}

View File

@@ -1,4 +1,10 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
plugins{
id("elex-base")
}

29
elex-theme/.editorconfig Normal file
View File

@@ -0,0 +1,29 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
# Change these settings to your own preference
indent_style = space
indent_size = 2
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[*.json]
indent_size = 2
[*.{html,js,md}]
block_comment_start = /**
block_comment = *
block_comment_end = */

23
elex-theme/.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
## editors
/.idea
/.vscode
## system files
.DS_Store
## npm
/node_modules/
/npm-debug.log
## testing
/coverage/
## temp folders
/.tmp/
# build
/_site/
/dist/
/out-tsc/
storybook-static

21
elex-theme/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 elex-theme
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

30
elex-theme/README.md Normal file
View File

@@ -0,0 +1,30 @@
<p align="center">
<img width="200" src="https://open-wc.org/hero.png"></img>
</p>
## Open-wc Starter App
[![Built with open-wc recommendations](https://img.shields.io/badge/built%20with-open--wc-blue.svg)](https://github.com/open-wc)
## Quickstart
To get started:
```sh
npm init @open-wc
# requires node 10 & npm 6 or higher
```
## Scripts
- `start` runs your app for development, reloading on file changes
- `start:build` runs your app after it has been built using the build command
- `build` builds your app and outputs it in your `dist` directory
- `test` runs your test suite with Web Test Runner
- `lint` runs the linter for your project
## Tooling configs
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
If you customize the configuration a lot, you can consider moving them to individual files.

View File

@@ -0,0 +1,26 @@
{
"version": 2,
"tags": [
{
"name": "elex-theme",
"description": "An application with a title and an action counter",
"properties": [
{
"name": "title",
"type": "String",
"description": "The title of your application",
"default": "Hey there"
},
{
"name": "page",
"type": "String",
"description": "Which page to show",
"default": "main"
}
],
"events": [],
"slots": [],
"cssProperties": []
}
]
}

28
elex-theme/index.html Normal file
View File

@@ -0,0 +1,28 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<meta name="Description" content="Put your description here.">
<base href="/">
<style>
html,
body {
margin: 0;
padding: 0;
font-family: sans-serif;
background-color: #ededed;
}
</style>
<title>elex-theme</title>
</head>
<body>
<elex-theme></elex-theme>
<script type="module" src="./out-tsc/src/app.js"></script>
</body>
</html>

84
elex-theme/package.json Normal file
View File

@@ -0,0 +1,84 @@
{
"devDependencies": {
"@babel/core": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@open-wc/eslint-config": "^4.2.0",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"@web/dev-server": "^0.1.8",
"babel-loader": "^8.2.2",
"concurrently": "^5.3.0",
"css-loader": "^5.2.0",
"eslint": "^7.21.0",
"eslint-config-prettier": "^7.2.0",
"husky": "^4.3.8",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"style-loader": "^2.0.0",
"ts-loader": "^8.0.18",
"tslib": "^2.1.0",
"typescript": "^4.2.3",
"webpack": "^5.25.0",
"webpack-cli": "^4.5.0"
},
"scripts": {
"lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
"build": "webpack"
},
"name": "elex-theme",
"version": "0.0.0",
"description": "Webcomponent elex-theme following open-wc recommendations",
"author": "elex-theme",
"license": "MIT",
"dependencies": {
"@material/mwc-button": "^0.20.0",
"@material/mwc-drawer": "^0.20.0",
"@material/mwc-icon-button": "^0.20.0",
"@material/mwc-top-app-bar": "^0.20.0",
"@material/mwc-top-app-bar-fixed": "^0.20.0",
"easymde": "^2.14.0",
"lit-element": "^2.4.0",
"lit-html": "^1.3.0"
},
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"extends": [
"@open-wc/eslint-config",
"eslint-config-prettier"
],
"plugins": [
"@typescript-eslint"
],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error"
],
"import/no-unresolved": "off",
"import/extensions": [
"info",
"always",
{
"ignorePackages": true
}
]
}
},
"prettier": {
"singleQuote": true,
"arrowParens": "avoid"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.ts": [
"eslint --fix",
"prettier --write"
]
}
}

View File

@@ -0,0 +1,79 @@
import { LitElement, html, css, property, customElement } from 'lit-element';
import { openWcLogo } from './open-wc-logo';
@customElement('elex-theme')
export class ElexTheme extends LitElement {
@property({ type: String }) title = 'My app';
static styles = css`
:host {
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
font-size: calc(10px + 2vmin);
color: #1a2b42;
max-width: 960px;
margin: 0 auto;
text-align: center;
background-color: var(--elex-theme-background-color);
}
main {
flex-grow: 1;
}
.logo > svg {
margin-top: 36px;
animation: app-logo-spin infinite 20s linear;
}
@keyframes app-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.app-footer {
font-size: calc(12px + 0.5vmin);
align-items: center;
}
.app-footer a {
margin-left: 5px;
}
`;
render() {
return html`
<main>
<div class="logo">${openWcLogo}</div>
<h1>${this.title}</h1>
<p>Edit <code>src/ElexTheme.js</code> and save to reload!</p>
<a
class="app-link"
href="https://open-wc.org/guides/developing-components/code-examples"
target="_blank"
rel="noopener noreferrer"
>
Code examples
</a>
</main>
<p class="app-footer">
🚽 Made with love by
<a
target="_blank"
rel="noopener noreferrer"
href="https://github.com/open-wc"
>open-wc</a
>.
</p>
`;
}
}

9
elex-theme/src/app.ts Normal file
View File

@@ -0,0 +1,9 @@
export { ElexTheme } from './ElexTheme';
export * from '@material/mwc-button';
export * from '@material/mwc-icon-button';
export * from '@material/mwc-top-app-bar-fixed';
export * from '@material/mwc-drawer';
//import * as EasyMDE from 'easymde';
//export {EasyMDE};

View File

@@ -0,0 +1,33 @@
import { html } from 'lit-html';
export const openWcLogo = html`
<svg
width="244px"
height="244px"
viewBox="0 0 244 244"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<defs>
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
<stop stop-color="#9B00FF" offset="0%"></stop>
<stop stop-color="#0077FF" offset="100%"></stop>
</linearGradient>
</defs>
<g
id="Page-1"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd"
>
<path
d="M205.639259,176.936244 C207.430887,174.217233 209.093339,171.405629 210.617884,168.510161 M215.112174,158.724316 C216.385153,155.50304 217.495621,152.199852 218.433474,148.824851 M220.655293,138.874185 C221.231935,135.482212 221.637704,132.03207 221.863435,128.532919 M222,118.131039 C221.860539,114.466419 221.523806,110.85231 221.000113,107.299021 M218.885321,96.8583653 C218.001583,93.4468963 216.942225,90.1061026 215.717466,86.8461994 M211.549484,77.3039459 C209.957339,74.1238901 208.200597,71.0404957 206.290425,68.0649233 M200.180513,59.5598295 C181.848457,36.6639805 153.655709,22 122.036748,22 C66.7879774,22 22,66.771525 22,122 C22,177.228475 66.7879774,222 122.036748,222 C152.914668,222 180.52509,208.015313 198.875424,186.036326"
id="Shape"
stroke="url(#linearGradient-1)"
stroke-width="42.0804674"
></path>
</g>
</svg>
`;

View File

@@ -0,0 +1,136 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<style>
:root {
--mdc-theme-primary: orange;
}
html, body{
margin:0; border:0; padding:0;
width: 100%; height: 100%;
}
</style>
<script type="module" src="/dist/bundle.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function(){
const drawer = document.getElementsByTagName('mwc-drawer')[0];
if (drawer) {
const container = drawer.parentNode;
container.addEventListener('MDCTopAppBar:nav', () => {
drawer.open = !drawer.open;
});
}
});
</script>
</head>
<body>
<mwc-drawer hasHeader type="dismissible">
<span slot="title">Drawer Title</span>
<div>
<p>
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the
charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to
ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying
through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our
power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to
be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of
business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore
always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or
else he endures pains to avoid worse pains."
</p>
</div>
<div slot="appContent">
<mwc-top-app-bar-fixed>
<mwc-icon-button slot="navigationIcon" icon="menu"></mwc-icon-button>
<div slot="title">Title</div>
<div>
<p>Hello</p>
<mwc-button raised label="Button"></mwc-button>
<p>
The standard Lorem Ipsum passage, used since the 1500s
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem
aperiam,
eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim
ipsam
voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur,
adipisci velit,
sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim
ad minima
veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi
consequatur? Quis
autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui
dolorem
eum fugiat quo voluptas nulla pariatur?"
1914 translation by H. Rackham
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I
will give
you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the
master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure,
but
because those who do not know how to pursue pleasure rationally encounter consequences that are extremely
painful. Nor
again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because
occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial
example,
which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has
any right
to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a
pain
that produces no resultant pleasure?"
Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque
corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in
culpa qui
officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita
distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod
maxime
placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et
aut
officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non
recusandae.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut
perferendis doloribus asperiores repellat."
1914 translation by H. Rackham
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized
by the
charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are
bound to
ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as
saying
through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour,
when our
power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure
is to
be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the
obligations of
business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man
therefore
always holds in these matters to this principle of selection: he rejects pleasures to secure other greater
pleasures, or
else he endures pains to avoid worse pains."
</p>
</div>
</mwc-top-app-bar-fixed>
</div>
</mwc-drawer>
</body>
</html>

View File

@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- <link rel="stylesheet" href="../node_modules/easymde/dist/easymde.min.css">
<script src="../node_modules/easymde/dist/easymde.min.js"></script> -->
<style>
:root {
--mdc-theme-primary: orange;
}
html, body{
margin:0; border:0; padding:0;
width: 100%; height: 100%;
}
</style>
<script src="../dist/editor.js"></script>
<script type="module" src="../dist/bundle.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function(){
const drawer = document.getElementsByTagName('mwc-drawer')[0];
if (drawer) {
const container = drawer.parentNode;
container.addEventListener('MDCTopAppBar:nav', () => {
drawer.open = !drawer.open;
});
}
let easyMDE = new EasyMDE({ element: document.getElementById('editor') });
});
</script>
</head>
<body>
<mwc-drawer hasHeader type="dismissible">
<span slot="title">Drawer Title</span>
<div>
<p>
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the
charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to
ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying
through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our
power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to
be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of
business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore
always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or
else he endures pains to avoid worse pains."
</p>
</div>
<div slot="appContent">
<mwc-top-app-bar-fixed>
<mwc-icon-button slot="navigationIcon" icon="menu"></mwc-icon-button>
<div slot="title">Editor title</div>
</mwc-top-app-bar-fixed>
<div>
<textarea id="editor"></textarea>
</div>
</div>
</mwc-drawer>
</body>
</html>

19
elex-theme/tsconfig.json Normal file
View File

@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es2018",
"module": "esnext",
"moduleResolution": "node",
"noEmitOnError": true,
"lib": ["es2017", "dom"],
"strict": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"importHelpers": true,
"outDir": "out-tsc",
"sourceMap": true,
"inlineSources": true,
"rootDir": "./"
},
"include": ["**/*.ts", "src/app.ts"]
}

View File

@@ -0,0 +1,28 @@
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
/** Use Hot Module replacement by adding --hmr to the start command */
const hmr = process.argv.includes('--hmr');
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
nodeResolve: true,
open: '/',
watch: !hmr,
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
// esbuildTarget: 'auto'
/** Set appIndex to enable SPA routing */
// appIndex: 'demo/index.html',
/** Confgure bare import resolve plugin */
// nodeResolve: {
// exportConditions: ['browser', 'development']
// },
plugins: [
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
],
// See documentation for all available options
});

View File

@@ -0,0 +1,41 @@
const path = require("path");
const webpack = require("webpack");
module.exports = {
mode: "development",
entry: {
bundle: "./src/app.ts",
editor: ["./node_modules/easymde/dist/easymde.min.js",
"./node_modules/easymde/dist/easymde.min.css"]
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.(ts|js)$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
{
loader: 'ts-loader'
}
]
},{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
}
],
},
plugins: [new webpack.ProgressPlugin()],
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
};

4301
elex-theme/yarn-error.log Normal file

File diff suppressed because it is too large Load Diff

5518
elex-theme/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,12 @@
#
# Project Asgard
#
# Copyright (c) 2021. Elex. All Rights Reserved.
# https://www.elex-project.com/
#
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

15
gradlew vendored
View File

@@ -1,19 +1,10 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
# Project Asgard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copyright (c) 2021. Elex. All Rights Reserved.
# https://www.elex-project.com/
#
##############################################################################

1
linkback/README.md Normal file
View File

@@ -0,0 +1 @@
# Linkback

42
linkback/build.gradle.kts Normal file
View File

@@ -0,0 +1,42 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
plugins {
id("elex-springboot")
id("org.springframework.boot") version "2.5.3"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
}
version = "1.0.0"
description = "Linkback"
tasks.bootJar{
enabled = false
}
tasks.jar {
enabled = true
}
dependencies {
// https://mvnrepository.com/artifact/org.jsoup/jsoup
implementation("org.jsoup:jsoup:1.14.2")
// https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
// https://mvnrepository.com/artifact/com.github.spullara.mustache.java/compiler
//implementation("com.github.spullara.mustache.java:compiler:0.9.7")
implementation("org.springframework.boot:spring-boot-starter")
//implementation("org.springframework.boot:spring-boot-starter-mustache")
compileOnly("org.projectlombok:lombok")
//runtimeOnly("org.mariadb.jdbc:mariadb-java-client")
annotationProcessor("org.projectlombok:lombok")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}

View File

@@ -0,0 +1,19 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.linkback;
import lombok.Data;
import java.net.URI;
@Data
public class Backlink {
private URI source, target;
private String title;
private String excerpt;
}

View File

@@ -0,0 +1,96 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.linkback;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.concurrent.Executors;
@Slf4j
public class Linkback {
private static final String UA = "Asgard linkback crawler by Elex (https://www.elex-project.com/)";
private static final HttpClient httpClient;
static {
httpClient = HttpClient.newBuilder()
.executor(Executors.newSingleThreadExecutor())
.version(HttpClient.Version.HTTP_2)
.connectTimeout(Duration.ofSeconds(10))
.followRedirects(HttpClient.Redirect.NORMAL)
.build();
}
private final URI source, target;
public Linkback(final @NotNull URI source, final @NotNull URI target) {
this.source = source;
this.target = target;
}
public void process(final @NotNull LinkbackListener listener) {
if (source.equals(target)) {
listener.onError(new Exception(""));//todo
return;
}
httpClient.sendAsync(HttpRequest.newBuilder(source)
.GET()
.header("User-Agent", UA)
.timeout(Duration.ofSeconds(10))
.build(),
HttpResponse.BodyHandlers.ofString())
.exceptionally(ex -> {
listener.onError(ex);
return null;
})
.thenAccept(resp -> {
final Backlink result = new Backlink();
result.setSource(source);
result.setTarget(target);
try {
final Document document = Jsoup.parse(resp.body());
result.setTitle(document.title());
final Element descElement = document.selectFirst("meta[name='description']");
if (null == descElement) {
final String text = document.wholeText();
result.setExcerpt(text.substring(0, Math.min(text.length(), 200)));
} else {
result.setExcerpt(descElement.attr("value"));
}
final Elements links = document.select("a[href^='" + target.toString() + "']");
if (links.size() > 0) {
listener.onResult(result);
} else {
listener.onError(new Exception("No link found."));
}
// todo
} catch (Throwable e) {
listener.onError(e);
}
});
}
private void crawl(String document){
}
}

View File

@@ -0,0 +1,13 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.linkback;
public interface LinkbackListener {
public void onResult(final Backlink backlink);
public void onError(final Throwable e);
}

View File

@@ -0,0 +1,8 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.linkback;

View File

@@ -0,0 +1,28 @@
/*
* Project Asgard
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package com.elex_project.asgard.linkback;
import org.junit.jupiter.api.Test;
import java.net.URI;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.*;
class LinkbackTest {
@Test
void uriTest(){
URI a = URI.create("http://example.com/a").normalize();
URI b = URI.create("http://example.com/a/").normalize();
Path pa = Path.of(a.getPath());
Path pb = Path.of(b.getPath());
System.out.println(pa.equals(pb));
}
}

View File

@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2021. Elex co.,ltd. All rights reserved.
~ developed by <developer@elex-project.com>
~ Project Asgard
~
~ Copyright (c) 2021. Elex. All Rights Reserved.
~ https://www.elex-project.com/
-->
<configuration>
@@ -15,7 +16,7 @@
</encoder>
</appender>
<logger name="com.elex_project.freesia" level="debug" additivity="false">
<logger name="com.elex_project.asgard" level="debug" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<root level="info">

23
mdc-theme/.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
## editors
/.idea
/.vscode
## system files
.DS_Store
## npm
/node_modules/
/npm-debug.log
## testing
/coverage/
## temp folders
/.tmp/
# build
/_site/
/dist/
/out-tsc/
storybook-static

202
mdc-theme/editor.html Normal file
View File

@@ -0,0 +1,202 @@
<!--
~ Project Asgard
~
~ Copyright (c) 2021. Elex. All Rights Reserved.
~ https://www.elex-project.com/
-->
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
<link rel="stylesheet" href="./dist/bundle.css" />
<title>Hello</title>
<script src="./dist/bundle.js"></script>
<link
rel="stylesheet"
href="https://unpkg.com/easymde/dist/easymde.min.css"
/>
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
<link
rel="stylesheet"
href="https://unpkg.com/@highlightjs/cdn-assets@10.7.1/styles/default.min.css"
/>
<script src="https://unpkg.com/@highlightjs/cdn-assets@10.7.1/highlight.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
let mde = new EasyMDE({
element: document.querySelector("#editor"),
renderingConfig: {
codeSyntaxHighlighting: true,
},
});
});
</script>
</head>
<body>
<aside id="layout-drawer" class="mdc-drawer mdc-drawer--dismissible">
<div class="mdc-drawer__header">
<p>Hello</p>
</div>
<div class="mdc-drawer__content">
<nav class="mdc-list mdc-list--dense">
<a
class="mdc-list-item mdc-list-item--activated"
href="#"
aria-current="page"
>
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Inbox</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Outgoing</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts Drafts Drafts Drafts</span>
</a>
<a class="mdc-list-item mdc-list-item--depth-1" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item mdc-list-item--depth-1" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts Drafts Drafts Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item mdc-list-item--depth-2" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text"
>Drafts Drafts Drafts Drafts Drafts Drafts Drafts</span
>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
</nav>
</div>
</aside>
<div id="layout-content" class="mdc-drawer-app-content">
<header class="mdc-top-app-bar mdc-top-app-bar--fixed">
<div class="mdc-elevation-overlay"></div>
<div class="mdc-top-app-bar__row">
<section
class="
mdc-top-app-bar__section mdc-top-app-bar__section--align-start
"
>
<button
class="
material-icons
mdc-top-app-bar__navigation-icon
mdc-icon-button
"
aria-label="Open navigation menu"
>
menu
</button>
<span class="mdc-top-app-bar__title">Page title.</span>
</section>
<section
class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end"
role="toolbar"
>
<button
class="
material-icons
mdc-top-app-bar__action-item
mdc-icon-button
"
aria-label="Favorite"
>
favorite
</button>
<button
class="
material-icons
mdc-top-app-bar__action-item
mdc-icon-button
"
aria-label="Search"
>
search
</button>
<div class="mdc-menu-surface--anchor">
<button
id="btn-overflow"
class="
material-icons
mdc-top-app-bar__action-item
mdc-icon-button
"
aria-label="Options"
>
more_vert
</button>
<div class="mdc-menu mdc-menu-surface">
<ul
class="mdc-list"
role="menu"
aria-hidden="true"
aria-orientation="vertical"
tabindex="-1"
>
<li class="mdc-list-item" role="menuitem">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">A Menu Item</span>
</li>
<li class="mdc-list-item" role="menuitem">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Another Menu Item</span>
</li>
</ul>
</div>
</div>
</section>
</div>
</header>
<div id="layout-main" class="mdc-top-app-bar--fixed-adjust">
<textarea id="editor"></textarea>
<footer class="mdc-layout-grid">
<p>Copyright &copy; 2021</p>
</footer>
</div>
</div>
</body>
</html>

238
mdc-theme/index.html Normal file
View File

@@ -0,0 +1,238 @@
<!--
~ Project Asgard
~
~ Copyright (c) 2021. Elex. All Rights Reserved.
~ https://www.elex-project.com/
-->
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
<link rel="stylesheet" href="./dist/bundle.css" />
<title>Hello</title>
<script src="./dist/bundle.js"></script>
</head>
<body>
<aside id="layout-drawer" class="mdc-drawer mdc-drawer--dismissible">
<div class="mdc-drawer__header">
<p>Hello</p>
</div>
<div class="mdc-drawer__content">
<nav class="mdc-list mdc-list--dense">
<a
class="mdc-list-item mdc-list-item--activated"
href="#"
aria-current="page"
>
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Inbox</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Outgoing</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts Drafts Drafts Drafts</span>
</a>
<a class="mdc-list-item mdc-list-item--depth-1" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item mdc-list-item--depth-1" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts Drafts Drafts Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item mdc-list-item--depth-2" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text"
>Drafts Drafts Drafts Drafts Drafts Drafts Drafts</span
>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
<a class="mdc-list-item" href="#">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Drafts</span>
</a>
</nav>
</div>
</aside>
<div id="layout-content" class="mdc-drawer-app-content">
<header class="mdc-top-app-bar mdc-top-app-bar--fixed">
<div class="mdc-elevation-overlay"></div>
<div class="mdc-top-app-bar__row">
<section
class="
mdc-top-app-bar__section mdc-top-app-bar__section--align-start
"
>
<button
class="
material-icons
mdc-top-app-bar__navigation-icon
mdc-icon-button
"
aria-label="Open navigation menu"
>
menu
</button>
<span class="mdc-top-app-bar__title">Page title.</span>
</section>
<section
class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end"
role="toolbar"
>
<button
class="
material-icons
mdc-top-app-bar__action-item
mdc-icon-button
"
aria-label="Favorite"
>
favorite
</button>
<button
class="
material-icons
mdc-top-app-bar__action-item
mdc-icon-button
"
aria-label="Search"
>
search
</button>
<div class="mdc-menu-surface--anchor">
<button
id="btn-overflow"
class="
material-icons
mdc-top-app-bar__action-item
mdc-icon-button
"
aria-label="Options"
>
more_vert
</button>
<div class="mdc-menu mdc-menu-surface">
<ul
class="mdc-list"
role="menu"
aria-hidden="true"
aria-orientation="vertical"
tabindex="-1"
>
<li class="mdc-list-item" role="menuitem">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">A Menu Item</span>
</li>
<li class="mdc-list-item" role="menuitem">
<span class="mdc-list-item__ripple"></span>
<span class="mdc-list-item__text">Another Menu Item</span>
</li>
</ul>
</div>
</div>
</section>
</div>
</header>
<div id="layout-main" class="mdc-top-app-bar--fixed-adjust">
<main class="mdc-layout-grid">
<article>
<h1>Heading 1</h1>
<p>Ha<em>Hehe</em>hoho.</p>
<button class="mdc-button mdc-button--raised">
<div class="mdc-button__ripple"></div>
<span class="mdc-button__label">Button</span>
</button>
<div>
<label class="mdc-text-field mdc-text-field--filled username">
<span class="mdc-text-field__ripple"></span>
<input
type="text"
class="mdc-text-field__input"
aria-labelledby="username-label"
name="username"
/>
<span class="mdc-floating-label" id="username-label"
>Username</span
>
<span class="mdc-line-ripple"></span>
</label>
<label class="mdc-text-field mdc-text-field--filled password">
<span class="mdc-text-field__ripple"></span>
<input
type="password"
class="mdc-text-field__input"
aria-labelledby="password-label"
name="password"
/>
<span class="mdc-floating-label" id="password-label"
>Password</span
>
<span class="mdc-line-ripple"></span>
</label>
</div>
<blockquote>Hahaha</blockquote>
<p>동해물과 백두산이 마르고 닳도록</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
<strong>Ut enim ad minim</strong> veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</article>
</main>
<footer class="mdc-layout-grid">
<p>Copyright &copy; 2021</p>
</footer>
</div>
</div>
</body>
</html>

34
mdc-theme/package.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "mdc-theme",
"version": "1.0.0",
"description": "MDC Theme",
"main": "index.js",
"author": "Elex",
"license": "MIT",
"private": true,
"dependencies": {
"easymde": "^2.14.0",
"highlight.js": "^10.7.1",
"material-components-web": "^10.0.0"
},
"devDependencies": {
"@babel/core": "^7.13.8",
"@babel/preset-env": "^7.13.8",
"autoprefixer": "^10.2.4",
"babel-loader": "^8.2.2",
"css-loader": "^5.1.0",
"extract-loader": "^5.1.0",
"file-loader": "^6.2.0",
"postcss-loader": "^5.0.0",
"sass": "^1.32.8",
"sass-loader": "^11.0.1",
"webpack": "^5.24.2",
"webpack-cli": "^4.5.0",
"webpack-dev-server": "^3.11.2"
},
"scripts": {
"start": "webpack serve",
"build": "webpack",
"dist": "cp ./dist/*.css ./dist/*.js ../app/src/main/resources/static"
}
}

252
mdc-theme/src/_article.scss Normal file
View File

@@ -0,0 +1,252 @@
main article {
font-size: 1.1rem;
line-height: 1.6;
h1,
h2,
h3,
h4,
h5,
h6 {
display: block;
font-weight: bold;
border-bottom: thin solid $color-primary;
margin: {
top: 2.4rem;
bottom: 0.5rem;
}
padding-bottom: 0.3rem;
line-height: 1.25;
}
h1 {
font-size: 2.2rem;
}
h2 {
font-size: 1.8rem;
padding-left: 1rem;
}
h3 {
font-size: 1.6rem;
padding-left: 1.5rem;
}
h4 {
font-size: 1.4rem;
padding-left: 2rem;
}
h5 {
font-size: 1.2rem;
padding-left: 2.8rem;
}
h6 {
font-size: 1rem;
padding-left: 3.2rem;
}
p {
text-align: justify;
word-wrap: break-word;
}
pre,
code {
font-family: monospace;
}
pre {
font-size: 0.9rem;
line-height: 1.2;
word-wrap: normal;
border-radius: 4px;
padding: 1rem;
text-overflow: ellipsis;
overflow-x: hidden;
white-space: nowrap;
&.scrollable {
max-height: 280px;
overflow: scroll;
}
}
blockquote {
margin: 0;
border-left: 0.43rem solid $color-gray-light;
padding: 0.43rem 0 0.43rem 1rem;
word-wrap: break-word;
}
p,
pre,
blockquote {
margin: {
top: 0.2rem;
bottom: 0.82rem;
}
}
a {
color: $color-primary;
text-decoration: none;
background-color: transparent;
}
a:active,
a:hover {
outline-width: 0;
text-decoration: underline;
}
a:not([href]) {
color: inherit;
text-decoration: none;
}
strong {
font-weight: bolder;
color: $color-primary;
}
em {
font-style: italic;
border-bottom: thin solid $color-primary;
}
mark {
background-color: $color-primary;
color: $color-on-primary;
border-radius: 4px;
padding: 0.2rem 0.34rem;
}
kbd {
font-family: monospace;
background-color: $color-primary;
color: $color-on-primary;
border-radius: 4px;
padding: 0.2rem 0.34rem;
}
var {
font-style: italic;
}
del,
s {
text-decoration: line-through;
color: $color-gray-dark;
}
ins,
u {
text-decoration: underline;
}
small {
color: $color-gray-dark;
font-size: 0.8rem;
}
abbr {
text-decoration: none;
border-bottom: 1px dashed inherit;
&[title] {
text-decoration: none;
border-bottom: 1px dashed inherit;
cursor: help;
}
}
address {
white-space: nowrap;
}
cite {
font-style: italic;
}
samp {
font-family: monospace;
border-radius: 4px;
font-size: 0.88rem;
margin: 0;
padding: 0.2rem 0.34rem;
}
code {
font-family: monospace;
border-radius: 4px;
font-size: 0.88rem;
margin: 0;
padding: 0.2rem 0.34rem;
}
pre > code {
padding: 0;
background: transparent;
white-space: pre;
word-break: normal;
}
img {
border-style: none;
max-width: 100%;
}
table {
display: table;
width: 100%;
overflow: auto;
border-collapse: collapse;
border-spacing: 0;
margin: {
top: 0.2rem;
bottom: 0.82rem;
}
&.hover tbody tr:hover {
background-color: $color-gray-light;
}
}
thead {
border-bottom: 2px solid $color-primary;
}
th {
font-weight: bold;
background-color: $color-on-primary;
color: $color-primary;
}
td,
th {
border: 1px solid $color-gray-light;
padding: 0.2rem 0.5rem;
}
tr {
background-color: $color-background;
border-top: 1px solid $color-gray-light;
}
ol,
ul,
dl {
margin-bottom: 0.5rem;
margin-top: 0.25rem;
list-style-position: outside;
padding-left: 1.25rem;
}
ol ol,
ul,
ol {
list-style-type: lower-roman;
margin-bottom: 0;
margin-top: 0;
}
ol ol ol,
ol ul ol,
ul ol ol,
ul ul ol {
list-style-type: lower-alpha;
}
li {
display: list-item;
word-wrap: break-word;
}
dt {
font-weight: bold;
}
dt::after {
content: " :";
}
dd {
margin-left: 2.5rem;
}
hr {
background-color: transparent;
border: 1px solid $color-gray-light;
height: 0;
margin: 2.34rem 0;
}
details {
display: block;
cursor: pointer;
}
summary {
display: list-item;
cursor: pointer;
}
}

View File

@@ -0,0 +1,57 @@
html,
body {
margin: 0;
border: 0;
padding: 0;
}
* {
box-sizing: content-box;
}
body {
display: flex;
height: 100vh;
}
.mdc-top-app-bar--fixed-adjust {
padding-top: 0 !important;
margin-top: 64px;
}
#layout-drawer {
.mdc-list-item {
margin: 0;
padding: 8px;
border-radius: 0;
&.mdc-list-item--depth-1 {
padding-left: 24px;
}
&.mdc-list-item--depth-2 {
padding-left: 40px;
}
&.mdc-list-item--depth-3 {
padding-left: 56px;
}
}
}
#layout-content {
flex: auto;
overflow: auto;
position: relative;
//overflow: hidden;
//height: 100%;
//box-sizing: content-box;
display: flex;
flex-direction: column;
& > header {
width: 100%;
position: absolute;
}
& > #layout-main {
overflow: auto;
//height: 100%;
box-sizing: content-box;
flex-grow: 1;
& > footer {
background-color: #242424;
color: #767676;
}
}
}

73
mdc-theme/src/app.js Normal file
View File

@@ -0,0 +1,73 @@
import {MDCRipple} from '@material/ripple';
import {MDCDrawer} from "@material/drawer";
import {MDCTopAppBar} from "@material/top-app-bar";
import {MDCTextField} from '@material/textfield';
import {MDCList} from '@material/list';
import {MDCMenu} from '@material/menu';
import autoInit from '@material/auto-init';
const App = {
appBar:null,
drawer:null,
init: function(){
autoInit();
document.querySelectorAll('.mdc-list-item').forEach(function(item){
new MDCRipple(item);
});
document.querySelectorAll('.mdc-button').forEach(function(item){
new MDCRipple(item);
});
document.querySelectorAll('.mdc-list').forEach(function(item){
new MDCList(item);
});
document.querySelectorAll('.mdc-text-field').forEach(function(item){
new MDCTextField(item);
});
this.initDrawer();
this.appBar = MDCTopAppBar.attachTo(document.querySelector('#layout-content > header'));
this.appBar.setScrollTarget(document.querySelector('#layout-content > #layout-main'));
this.appBar.listen('MDCTopAppBar:nav', () => {
this.drawer.open = !this.drawer.open;
});
//document.querySelectorAll('.mdc-top-app-bar--fixed-adjust').forEach(function(item){
// item.style.marginTop = this.appBar.;
//});
const menu = new MDCMenu(document.querySelector('.mdc-menu'));
document.querySelector('#btn-overflow').addEventListener('click', function(){
menu.open = true;
});
console.log('hello world.');
window.addEventListener('resize', this.initDrawer);
},
initDrawer: function(){
const drawerElement = document.querySelector('#layout-drawer');
if (document.body.offsetWidth>600){
drawerElement.classList.remove('mdc-drawer--modal');
drawerElement.classList.add('mdc-drawer--dismissible');
try {
document.removeChild(document.querySelector('mdc-drawer-scrim'));
} catch (ex){ }
} else {
drawerElement.classList.add('mdc-drawer--modal');
drawerElement.classList.remove('mdc-drawer--dismissible');
const scrimElement = document.createElement('div');
scrimElement.classList.add('mdc-drawer-scrim');
drawerElement.parentNode.insertBefore(scrimElement, drawerElement.nextSibling);
}
this.drawer = MDCDrawer.attachTo(document.querySelector('.mdc-drawer'));
if (document.body.offsetWidth>600) {
this.drawer.open = true;
}
}
};
window.addEventListener('DOMContentLoaded', (event) => {
App.init();
});

36
mdc-theme/src/app.scss Normal file
View File

@@ -0,0 +1,36 @@
$color-primary: #0f4c81;
$color-secondary: #ffbf00;
$color-on-primary: #eaeaea;
$color-on-secondary: #efefef;
$color-background: #e4e4e4;
$color-surface: #fdfdfd;
$color-on-surface: #242424;
$color-gray-light: #a0a0a0;
$color-gray-dark: #6f6f6f;
//@use "normalize-scss/sass/normalize";
@use "@material/theme" with (
$primary: $color-primary,
$secondary: $color-secondary,
$on-primary: $color-on-primary,
$on-secondary: $color-on-secondary,
$background: $color-background,
$surface: $color-surface,
$on-surface: $color-on-surface
);
@use "@material/typography" with (
$font-family: unquote("Noto Sans CJK KR, Roboto, sans-serif")
);
@use "@material/icon-button/mdc-icon-button";
@use "@material/top-app-bar/mdc-top-app-bar";
@use "@material/drawer/mdc-drawer";
@use "@material/menu-surface/mdc-menu-surface";
@use "@material/menu/mdc-menu";
@use "@material/list";
@use "@material/list/mdc-list";
@use '@material/button/mdc-button';
@use "@material/textfield/mdc-text-field";
@use "@material/layout-grid/mdc-layout-grid";
@use "@material/elevation/mdc-elevation";
@import "./layout";
@import "./article";

103
mdc-theme/webpack.config.js Normal file
View File

@@ -0,0 +1,103 @@
const autoprefixer = require("autoprefixer");
const path = require("path");
function tryResolve_(url, sourceFilename) {
// Put require.resolve in a try/catch to avoid node-sass failing with cryptic libsass errors
// when the importer throws
try {
return require.resolve(url, { paths: [path.dirname(sourceFilename)] });
} catch (e) {
return "";
}
}
function tryResolveScss(url, sourceFilename) {
// Support omission of .scss and leading _
const normalizedUrl = url.endsWith(".scss") ? url : `${url}.scss`;
return (
tryResolve_(normalizedUrl, sourceFilename) ||
tryResolve_(
path.join(
path.dirname(normalizedUrl),
`_${path.basename(normalizedUrl)}`
),
sourceFilename
)
);
}
function materialImporter(url, prev) {
if (url.startsWith("@material")) {
const resolved = tryResolveScss(url, prev);
return { file: resolved || url };
}
return { file: url };
}
module.exports = [
{
entry: {
app: ["./src/app.scss", "./src/app.js"],
//editor: [
// "./node_modules/easymde/src/css/easymde.css",
// "./node_modules/easymde/src/js/easymde.js",
//],
//hljs: ["./node_modules/highlight.js/lib/index.js"],
},
output: {
filename: "[name].js",
},
mode: "production",
module: {
rules: [
{
test: /\.(css|scss)$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].css",
},
},
{
loader: "extract-loader",
},
{
loader: "css-loader",
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [autoprefixer()],
},
},
},
{
loader: "sass-loader",
options: {
implementation: require("sass"),
webpackImporter: false,
sassOptions: {
importer: materialImporter,
includePaths: ["./node_modules"],
},
},
},
],
},
{
test: /\.js$/,
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
},
},
],
},
],
},
},
];

Some files were not shown because too many files have changed in this diff Show More