deprecated-github-backend icon indicating copy to clipboard operation
deprecated-github-backend copied to clipboard

  • Logseq Logseq is A privacy-first, open-source platform for knowledge sharing and management.

** Warning: The GitHub integration is deprecated, we're not going to accept any PRs.

** Website https://logseq.com

** Setup development environment If you're on Windows, use the [[#windows-setup][Windows setup]].

*** 1. Requirements

**** [[https://clojure.org/guides/getting_started][Java && Clojure]]

**** [[https://www.postgresql.org/download/][PostgreSQL]]

**** [[https://nodejs.org/en/][Node.js]]

**** 2. Create a GitHub app

 Follow the guide at
 [[https://docs.github.com/en/free-pro-team@latest/developers/apps/creating-a-github-app]],
 where the user authorization "Callback URL" should be
 =http://localhost:3000/auth/github=.

 Remember to download the =private-key.pem= which will be used for the
 next step. Also take note of your =App ID=, =Client ID=, and your newly
 generated =Client Secret= for use in step 4.

 #+caption: Screenshot 2020-11-27 22-22-39 +0800
 [[https://user-images.githubusercontent.com/479169/100460276-e0bad100-3101-11eb-8fed-1f7c85824b62.png]]

 *Add contents permission*:
 [[https://user-images.githubusercontent.com/479169/100460271-def10d80-3101-11eb-91bb-f2339a52d4f8.png]]

*** 3. Set up PostgreSQL

Make sure you have PostgreSQL running. You can check if it's running
with =pg_ctl -D /usr/local/var/postgres status= and use
=pg_ctl -D /usr/local/var/postgres start= to start it up. You'll also
need to make a Logseq DB in PostgreSQL. Do that with =createdb logseq=.

*** 4. Add environment variables #+BEGIN_SRC sh export ENVIRONMENT="dev" export JWT_SECRET="xxx" export COOKIE_SECRET="xxx" export DATABASE_URL="postgresql://your-user:your-password@localhost:5432/logseq" export GITHUB_APP2_NAME="your github app name" export GITHUB_APP2_ID="your app id" export GITHUB_APP2_KEY="you client id" export GITHUB_APP2_SECRET="your secret" export GITHUB_REDIRECT_URI="http://localhost:3000/auth/github" # Replace your-code-directory with yours export GITHUB_APP_PEM="/your-code-directory/logseq/pem/logseq-test.2020-08-27.private-key.pem" export GOOGLE_APP_KEY="your key" export GOOGLE_APP_SECRET="your secret" export GOOGLE_REDIRECT_URI="http://localhost:3000/auth/google" export LOG_PATH="/tmp/logseq" export WEBSITE_URL="http://localhost:3000" export COOKIE_DOMAIN="localhost"

  export AWS_ACCESS_KEY_ID="your key id"
  export AWS_SECRET_ACCESS_KEY="your secret"
  export AWS_PK_PATH="/your/pk.pem"
  export AWS_KEY_PAIR_ID="your key pair id"
  export AWS_REGION="us-west-1"
#+END_SRC

*** 3. Start the clojure server

**** Using in Emacs #+BEGIN_EXAMPLE 1. C-c M-j and select "clojure-cli" 2. input "(go)" in the clojure repl #+END_EXAMPLE (Note: to specify an alias from within emacs you can follow either option suggested [[https://github.com/clojure-emacs/cider/issues/2396][here]]) **** Using in Cli #+BEGIN_EXAMPLE 1. clj -A:dev 2. input "(go)" in the clojure repl #+END_EXAMPLE

**** Using in Calva (Visual Studio Code) #+BEGIN_EXAMPLE 1. Issue the command Start a REPL server and Connect: ctrl+alt+c ctrl+alt+j 2. Select clojure-cli 3. input "(go)" in the clojure repl #+END_EXAMPLE

*** 4. Compile javascript #+BEGIN_SRC sh cd web yarn yarn watch open http://localhost:3000 #+END_SRC

** Windows setup

*** 1. Required software Install clojure through scoop-clojure: https://github.com/littleli/scoop-clojure. You can also install [[https://nodejs.org/en/][Node.js]], [[https://yarnpkg.com/][Yarn]] and [[https://www.postgresql.org/download/][PostgreSQL]] through scoop if you want to.

*** 2. Setup PostgreSQL Make sure you have PostgreSQL running. You can check if it's running with ~pg_ctl status~ and use ~pg_ctl start~ to start it up. You'll also need to make a logseq DB in PostgreSQL. Do that with ~createdb logseq~.

*** 3. Setup the server Download [[https://gist.github.com/samfundev/98088dd76f67085f114c75493261aa3d][this little script]] that sets up the environment variables and runs ~cmd-clj -A:dev~. The ~GITHUB_APP_PEM~ variable in the script needs to be set with the correct directory for your system. Run that script in the repo and enter ~(go)~ into the interpreter.

*** 4. Setup the website Either run ~cmd-clojure -A:cljs watch app~ instead of ~yarn watch~ in the next step or modify web/package.json to use cmd-clojure instead of clojure in the scripts section.

Open command prompt in the repo and do:
#+BEGIN_SRC batch
  cd web
  yarn
  yarn watch
#+END_SRC
Wait for it to compile and open ~localhost:3000~.

*** Notes 1. The clojure deps should be synced between the two files: ~project.clj~ and ~deps.edn~. We need the ~project.clj~ because it's used for dokku deployment. 2. To use github push, comment this line https://github.com/tiensonqin/logseq/blob/master/web/src/main/frontend/handler.cljs#L751