반응형

1. icarusn 모듈 설치

먼저 로컬에 있는 blog 소스가 있는 폴더 안에서 git submodule 을 추가해준다.

내가 설치하려고 하는 테마는 icarus 라는 테마인데 설치 방법은 여러가지가 있다.

Document를 보니 git submodule 을 추가하는 방법도 있고 npm 으로 설치하는방법도 있다.

 

git submodule add https://github.com/ppoffice/hexo-theme-icarus.git themes/icarus

 

이렇게 하면 blog 하위에 themes 폴더 안에 icarus 라는 항목이 생긴다.

 

또는

 

npm install -S hexo-theme-icarus

 

나는 submodule 을 추가 하는 방법을 사용했다.

 

2. 설정파일 변경

_config.yml 파일을 수정해준다.

 

theme: icarus

 

3. 반영 확인

설치 완료 후 hexo server 명령어를 통해서 로컬에서 기동 시켜보면 테마가 변경 된 것을 확인 할 수 있다.

 

4. 에러 발생시?

혹시라도 아래와 같이 dependencies 에러가 난다면 에러난 항목들을 설치해 주면 된다.

아래 bold 처리한 부분을 설치해 주면 된다.

 

INFO  === Checking package dependencies ===
ERROR Package bulma-stylus is not installed.
ERROR Package hexo-renderer-inferno is not installed.
ERROR Package hexo-component-inferno is not installed.
ERROR Package inferno is not installed.
ERROR Package inferno-create-element is not installed.
ERROR Please install the missing dependencies your Hexo site root directory:
ERROR npm install --save bulma-stylus@0.8.0 hexo-renderer-inferno@^0.1.3 hexo-component-inferno@^0.10.1 inferno@^7.3.3 inferno-create-element@^7.3.3
ERROR or:
ERROR yarn add bulma-stylus@0.8.0 hexo-renderer-inferno@^0.1.3 hexo-component-inferno@^0.10.1 inferno@^7.3.3 inferno-create-element@^7.3.3

 

5. git submodule 관련 사항

- 설치 잘못해서 재 설치시 나왔던 에러

git 레파지토리에 submodule을 추가했다가 제거한 후 다시 추가 하려고 하니 다음과 같은 에러가 발생했다.

 

A git directory for 'themes/icarus' is found locally with remote(s):

 

그런데 분명한것은 현재 로컬에는 저 폴더가 없는 상태이다. 하짐나  .git/modules 하위에 themes/icarus 라는 폴더가 남아있었다. 그래서 그 폴더를 삭제한 후 submodule  을 추가 하니 정상적으로 동작을 했다.

 

- 다른 곳에서 submodule 을 포함한 소스 내려 받기

 

최초 내려 받기 : git clone --recursive git_url

이미 내려받는 곳에서 submodule 만 받기 : git submodule update --init --recursive

 

 

참고 사이트 

github.com/ppoffice/hexo-theme-icarus

blog.zhangruipeng.me/hexo-theme-icarus/uncategorized/getting-started-with-icarus/

www.vogella.com/tutorials/GitSubmodules/article.html

728x90
반응형
반응형

1. github 에 레파지토리 생성

레파지토리 이름은 다음과 같이 만든다.

[ID].github.io

일단 이렇게 하면 저장소 준비는 완료된다.

 

2. hexo 설치 (설치전에 node 는 설치 되어있다고 가정한다.)

- hexo-cli 설치 (혹시 권한 관련 Error 가 나면 앞에 sudo 추가)

npm install hexo-cli -g

- hexo 기본 구성 하기

hexo init [폴더명]

여기에서 폴더는 기존에 있던것은 안되고 새로 생성하거나 그냥 이름을 적으면 자동으로 생성해준다.

실제 폴더에 들어가면 아래와 같이 구성이 되어있다.

- _config.yml 파일 설정 하기

간단하게 다음 두개 항목만 설정해준다.

# Site (사이트 설명 : 자신에게 맞게 설정해주면 된다.)

title: Hexo

subtitle: ''

description: ''

keywords:

author: John Doe

language: en

timezone: ''

 

# Deployment (배포)

## Docs: https://hexo.io/docs/one-command-deployment

deploy:

type: git

repo: 위에 생성한 git 주소를 넣어주면 된다.

branch: main (안쓰면 master로 올라가는듯..)

 

- 로컬 실행

hexo server

 

이렇게 하면 기본적으로 4000번 포트로 실행이 된다.

 

 

3. github 에 배포하기

아래 명령어로 static 파일을 생성한다.

hexo generate 

그리고 deploy 를 한다.

hexo deploy

위와 같이 에러가 나면 다음과 같이 실행해준다.

npm install hexo-deployer-git --save

혹시라도 delpoy를 완료 하고 github 주소로 접속을 했는데 404 에러가 날 경우 다음 설정을 확인해 보면 된다.

Source 항목의 Branch 가 내가 실제 배포한 Branch 와 일치 하는지 확인해 본다. github 의 default 브랜치가 기존에는 master 였는데 최근에 main 으로 변경 되면서 당연히 master 라고 착각하는 경우가 생길 수 있다. (실제로 내가 그랬다.. ㅠㅠ)

 

4. Blog Repository 추가

이건 해도 그만 안해도 그만이다. 본인이 관리하기 쉬운쪽으로 하면 된다.

우선 실제 Blog 가 배포된 Repository 가 존재한다. (github.io 이런 이름으로)

 

그런데 실제 Blog 소스를 배포를 하는 작업을 하나의 PC 가 아닌 여러 PC 에서 작업을 할 경우가 있다. 그래서 이 소스를 관리하기 위한 레파지토리가 하나 더 필요 하다. 

 

- ~.github.io : 실재 배포 버전이 올라가는 repository

- blog : 배포를 하기위한 소스를 관리하가 위한 repository

 

이렇게 나누어 놓으면 어디서든지 github 에서 내려받아서 변경을 하고 배포가 가능하다. 

 

 

참고 사이트

hexo.io/ko/index.html

728x90
반응형
반응형

Spring Data Jpa 를 사용하게 되면서 전에 쓰지 않았던 paging 기능에 대해서 이야기 해보려 한다. 

Domain 을 조회하는 Repository interface를 만들때에 JpaRepository 를 상속해서 사용하는 경우가 많다. 
이 JpaRepository 를 살펴보면 내부에 이렇게 구현이 되어있다.  

public interface JpaRepository<T, ID> extends PagingAndSortingRepository<T, ID>, QueryByExampleExecutor { 
..... 
} 

그리고 다시 PagingAndSortingRepository 를 살펴보면 다음과 같다.

public interface PagingAndSortingRepository<T, ID> extends CrudRepository<T, ID> { 
    Iterable findAll(Sort var1); 

    Page findAll(Pageable var1); 
} 

위에서 볼수 있듯이 Page를 리턴해주는 메소드가 이미 포함되어있다. 

 

그럼 간단히 검색 조건 없이 모든 Data를 검색하는 코드를 작성해보자

 

AccountRestController.java

@GetMapping
public Page<AccountResDto> getPageableAccountList(Pageable pageable){
	return accountService.findAll(pageable);
}

AccountServiceImpl.java

@Override
public Page<AccountResDto> findAll(Pageable pageable) {
  Page<Account> accounts = accountRepository.findAll(pageable);
  return accounts.map(AccountResDto::new);
}

 

http://localhost:9000/api/v1/accounts 로 요청을 하면 다음과 같이 응답을 받을수 있다.

{
    "content": [
        {
            "loginId": "admin",
            "username": "admin",
            "email": "admin@spring.com"
        },
        {
            "loginId": "auser01",
            "username": "user",
            "email": "user01@spring.com"
        },
        {
            "loginId": "guest",
            "username": "guest",
            "email": "guest@spring.com"
        },
        {
            "loginId": "buser02",
            "username": "user",
            "email": "user02@spring.com"
        },
        {
            "loginId": "cuser03",
            "username": "user",
            "email": "user03@spring.com"
        },
        {
            "loginId": "duser04",
            "username": "user",
            "email": "user04@spring.com"
        },
        {
            "loginId": "euser05",
            "username": "user",
            "email": "user05@spring.com"
        },
        {
            "loginId": "fuser06",
            "username": "user",
            "email": "user06@spring.com"
        },
        {
            "loginId": "guser07",
            "username": "user",
            "email": "user07@spring.com"
        },
        {
            "loginId": "huser08",
            "username": "user",
            "email": "user08@spring.com"
        },
        {
            "loginId": "iuser09",
            "username": "user",
            "email": "user09@spring.com"
        },
        {
            "loginId": "juser10",
            "username": "user",
            "email": "user10@spring.com"
        }
    ],
    "pageable": {
        "sort": {
            "sorted": false,
            "unsorted": true,
            "empty": true
        },
        "offset": 0,
        "pageSize": 20,
        "pageNumber": 0,
        "paged": true,
        "unpaged": false
    },
    "last": true,
    "totalPages": 1,
    "totalElements": 12,
    "number": 0,
    "size": 20,
    "sort": {
        "sorted": false,
        "unsorted": true,
        "empty": true
    },
    "first": true,
    "numberOfElements": 12,
    "empty": false
}

리턴 결과를 잘 보면 totalPages 는 1, data 개수는 12, size 는 20 으로 되어있다. 

 

그리고 정렬된 결과를 얻고 싶으면 다음과 같이 파라메터를 추가해주면 된다.

 

http://localhost:9000/api/v1/accounts?sort=loginId,DESC

 

이렇게 하면 loginId 로 정렬된 형태의 결과를 받을수 있다. (그런데 주의할점은 컴마(,) 이후에 공백이 포함되어 있으면 에러가 난다 -_-)

 

그리고 size 도 지정할수 있는데 위 결과는 지정을 하지 않아서 기본 default 로 20 으로 설정된 경우이다.

 

마찬가지로 파라메터에 size 값을 지정해주면 지정한 값으로 size 가 정해지며 그에 따른 totalPages 값도 달라지게 된다.

 

위 코드가 포함된 소스는 아래 주소에서 볼수 있다. (단, 계속 수정을 하기 때문에 소스가 완전히 일치하지 않을수 있다. )

 

https://github.com/blusky10/study_spring

 

blusky10/study_spring

Contribute to blusky10/study_spring development by creating an account on GitHub.

github.com

 

728x90
반응형

+ Recent posts