Compare commits
	
		
			2 commits
		
	
	
		
			ea4339b2dc
			...
			687c1ac5e8
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 687c1ac5e8 | |||
| 5fc8ba54da | 
					 4 changed files with 69 additions and 4 deletions
				
			
		
							
								
								
									
										18
									
								
								main.ts
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								main.ts
									
										
									
									
									
								
							|  | @ -25,6 +25,8 @@ import { serve } from "http/server.ts"; | |||
| import { user_command } from "./user.ts"; | ||||
| import { key_out_cmd } from "./keyout.ts"; | ||||
| import { prepareDocs } from "./src/store/doc.ts"; | ||||
| import { connectDB } from "./src/user/db.ts"; | ||||
| import * as users from "./src/user/user.ts"; | ||||
| 
 | ||||
| const github_markdown = (await Deno.readTextFile( | ||||
|   join(fromFileUrl(import.meta.url), "..", "static", "github-markdown.css"), | ||||
|  | @ -81,12 +83,26 @@ if (import.meta.main) { | |||
|       default: 8000, | ||||
|     }) | ||||
|     .option("--auth", "Enable authentication.") | ||||
|     .option("--db-path <path:string>", "The path to the database file.", { | ||||
|       default: ":memory:", | ||||
|     }) | ||||
|     .option("--id-password <idpassword:string>", "The password to use. (Not recommended). id:password format.") | ||||
|     .arguments("[hostname:string]") | ||||
|     .action(async ({ debug, port, auth }, hostname) => { | ||||
|     .action(async ({ debug, port, auth, dbPath, idPassword }, hostname) => { | ||||
|       hostname ??= "localhost"; | ||||
|       if (auth) { | ||||
|         Deno.env.set("AUTH_REQUIRED", "true"); | ||||
|       } | ||||
|       if (dbPath) { | ||||
|         Deno.env.set("DB_PATH", dbPath); | ||||
|       } | ||||
|       if (idPassword) { | ||||
|         Deno.env.set("AUTH_REQUIRED", "true"); | ||||
|         const db = connectDB(); | ||||
|         const [username, password] = idPassword.split(":"); | ||||
|         const new_user = await users.createUser(username, password); | ||||
|         await users.addUser(db, new_user); | ||||
|       } | ||||
|       if (debug) { | ||||
|         console.log("Debug mode enabled."); | ||||
|       } | ||||
|  |  | |||
|  | @ -1,6 +1,10 @@ | |||
| import { HandlerContext, Handlers, PageProps } from "$fresh/server.ts"; | ||||
| import { asset, Head } from "$fresh/runtime.ts"; | ||||
| import { encodePath, removePrefixFromPathname } from "../../util/util.ts"; | ||||
| import { Head } from "$fresh/runtime.ts"; | ||||
| import { | ||||
|   decodePath, | ||||
|   encodePath, | ||||
|   removePrefixFromPathname, | ||||
| } from "../../util/util.ts"; | ||||
| import { join } from "path/posix.ts"; | ||||
| import DirList, { EntryInfo } from "../../islands/DirList.tsx"; | ||||
| import FileViewer from "../../islands/FileViewer.tsx"; | ||||
|  | @ -127,7 +131,7 @@ async function GET(req: Request, ctx: HandlerContext): Promise<Response> { | |||
|     } | ||||
|   } | ||||
|   const url = new URL(req.url); | ||||
|   const path = removePrefixFromPathname(decodeURI(url.pathname), "/dir"); | ||||
|   const path = removePrefixFromPathname(decodePath(url.pathname), "/dir"); | ||||
|   if (url.searchParams.has("pretty")) { | ||||
|     return await renderPage(req, path, ctx); | ||||
|   } else { | ||||
|  |  | |||
							
								
								
									
										41
									
								
								test_data/h#1/SUMMARY.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								test_data/h#1/SUMMARY.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | |||
| --- | ||||
| title: Q&A | ||||
| tags: ["Q&A"] | ||||
| --- | ||||
| 
 | ||||
| # Q&A | ||||
| 
 | ||||
| ## Q1 | ||||
| 
 | ||||
| What is the default branch name? | ||||
| 
 | ||||
| ## A1 | ||||
| 
 | ||||
| The default branch name is `master`. You can change it to any name you like. For | ||||
| example, you can change it to `main` by following the steps below: | ||||
| 
 | ||||
| ``` | ||||
| git branch -m master main | ||||
| git fetch origin | ||||
| git branch -u origin/main main | ||||
| git remote set-head origin -a | ||||
| ``` | ||||
| 
 | ||||
| ## Q2 | ||||
| 
 | ||||
| What is the defference between `git branch` and `git branch -a`? | ||||
| 
 | ||||
| ## A2 | ||||
| 
 | ||||
| `git branch` shows only local branches, while `git branch -a` shows both local | ||||
| and remote branches. | ||||
| 
 | ||||
| ## Q3 | ||||
| 
 | ||||
| Fast-forward merge is not possible. How can I merge the feature branch into the | ||||
| main branch? | ||||
| 
 | ||||
| ## A3 | ||||
| 
 | ||||
| You can use `--no-ff` option to force a merge commit even if the merge is a | ||||
| fast-forward. | ||||
|  | @ -16,3 +16,7 @@ export function removePrefixFromPathname( | |||
| export function encodePath(path: string): string { | ||||
|   return path.split("/").map(encodeURIComponent).join("/"); | ||||
| } | ||||
| 
 | ||||
| export function decodePath(path: string): string { | ||||
|   return path.split("/").map(decodeURIComponent).join("/"); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue