notionterm

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2022 License: Unlicense Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CONFIGURATION string = "C O N F I G U R A T I O N"
View Source
const PORT = "Port"
View Source
const SHELL = "Shell"
View Source
const TARGET = "Target"
View Source
const TERMINAL string = "T E R M I N A L"

Variables

This section is empty.

Functions

func ActivateNotionTerm

func ActivateNotionTerm(client *notionapi.Client, pageid string, play chan struct{}) http.Handler

ActivateNotionTerm: endpoint to activate notionterm

func AddRichText

func AddRichText(client *notionapi.Client, codeBlock notionapi.CodeBlock, content string) (notionapi.Block, error)

AddRichText: Add rich text in code

func AddTermLine

func AddTermLine(config *Config, codeBlock notionapi.CodeBlock) (notionapi.Block, error)

AddTermLine: Add rich text with a new line and "$"

func AppendCodeBlock added in v1.0.0

func AppendCodeBlock(client *notionapi.Client, pageid string, content string) (resp *notionapi.AppendBlockChildrenResponse, err error)

AppendCodeBlock: Add a code block ("shell") at the end of the page

func AppendEmbedBlock added in v1.0.0

func AppendEmbedBlock(client *notionapi.Client, pageid string, url string) (resp *notionapi.AppendBlockChildrenResponse, err error)

AppendEmbedBlock: Add a embed block with specified url

func AppendHeadingBlock added in v1.0.0

func AppendHeadingBlock(client *notionapi.Client, pageid string, content string) (resp *notionapi.AppendBlockChildrenResponse, err error)

AppendEmbedBlock: Add a embed block with specified url

func ButtonPage added in v1.0.0

func ButtonPage() http.Handler

buttonPage: button widget handler

func CreateButtonBlock added in v1.0.0

func CreateButtonBlock(config Config) notionapi.BlockID

CreateButtonBlock: create embed block with url button

func CreateHeadingCaptionBlock added in v1.0.0

func CreateHeadingCaptionBlock(config Config) notionapi.BlockID

func CreateTerminalBlock added in v1.0.0

func CreateTerminalBlock(config Config) notionapi.BlockID

CreateTerminalBlock: create the block code simulating a terminal

func DeactivateNotionTerm

func DeactivateNotionTerm(pause chan struct{}) http.Handler

DeactivateNotionTerm: endpoint to deactivate notionterm

func DeleteEmbed added in v1.0.0

func DeleteEmbed(config Config) (err error)

DeleteEmbed: find the last embed/bookmark block of a page and delete it

func ExecAndPrint

func ExecAndPrint(config *Config, termBlock notionapi.CodeBlock, cmd string)

ExecAndPrint: execute command and print the result in code block

func GetButtonBlock

func GetButtonBlock(children notionapi.Blocks, buttonId notionapi.BlockID) (button notionapi.EmbedBlock, err error)

GetButtonBlock: retrieve "button" block (embed blocks)

func GetHeadingCaptionBlock added in v1.0.0

func GetHeadingCaptionBlock(children notionapi.Blocks, headingID notionapi.BlockID) (headingCaption notionapi.Heading3Block, err error)

GetHeadingCaptionBlock: retrieve heading3 block by id.

func GetTableBlock

func GetTableBlock(children notionapi.Blocks) (table notionapi.TableBlock, err error)

GetTableBlock: retrieve table block

func GetTerminalBlock

func GetTerminalBlock(children notionapi.Blocks, termId notionapi.BlockID) (terminal notionapi.CodeBlock, err error)

GetTerminalBlock: retrieve "terminal" block (code blocks)

func GetTerminalLastRichText

func GetTerminalLastRichText(termCode notionapi.CodeBlock) (terminal string, err error)

GetTerminalLastRichText: Obtain the last RichText

func LaunchNotiontermServer added in v1.0.0

func LaunchNotiontermServer(config *Config, isServer bool, play chan struct{}, pause chan struct{}) (stopServer chan bool)

LaunchNotiontermServer: Launch server with appropriate endpoint: /button which return a button widget, /activate to activate button , /deactivate for the reverse, and if

func LaunchUrlWaitingServer added in v1.0.0

func LaunchUrlWaitingServer(config *Config) (pageid string)

LaunchUrlWaitingServer: launch the server waiting for url parameter, kill it when task is finished

func NotiontermRun added in v1.0.0

func NotiontermRun(config *Config, play chan struct{}, pause chan struct{})

NotionTerm: "Infinite loop" to read the content of terminal code block and execute it if it is a command, then returning stdout

func RequestButtonBlock

func RequestButtonBlock(client *notionapi.Client, pageid string, buttonId notionapi.BlockID) (button notionapi.EmbedBlock, err error)

RequestButtonBlock: retrieve "button" widget (embed block)

func RequestHeadingCaptionBlock added in v1.0.0

func RequestHeadingCaptionBlock(client *notionapi.Client, pageid string, headingID notionapi.BlockID) (button notionapi.Heading3Block, err error)

RequestButtonBlock: retrieve heading 3 block to store caption/path

func RequestTerminalBlock

func RequestTerminalBlock(client *notionapi.Client, pageId string, termId notionapi.BlockID) (terminal notionapi.CodeBlock, err error)

RequestTerminalBlock: retrieve "terminal" block (code blocks)

func UpdateButtonUrl

func UpdateButtonUrl(client *notionapi.Client, buttonID notionapi.BlockID, url string) (notionapi.Block, error)

UpdateButtonUrl: update url of the button widget

func UpdateCaptionById added in v1.0.0

func UpdateCaptionById(client *notionapi.Client, pageID string, captionBlock CaptionBlock, caption string) (notionapi.Block, error)

UpdateCaptionID: update caption of captionBlock. For the light mode the "caption block" is a heading3 so we change the content (not the caption)

func UpdateCodeContent

func UpdateCodeContent(client *notionapi.Client, codeBlockID notionapi.BlockID, content string) (notionapi.Block, error)

UpdateCodeContent: update code block with content

func WaitPageIDHandler added in v1.0.0

func WaitPageIDHandler(config *Config, urlCh chan string) http.Handler

WaitPageIDHandler: handler waiting for pageid of notion page in parameter

Types

type CaptionBlock added in v1.0.0

type CaptionBlock struct {
	Type notionapi.BlockType
	Id   notionapi.BlockID
}

type Config

type Config struct {
	Delay           time.Duration
	Client          *notionapi.Client
	ExternalUrl     string
	Port            string
	PageID          string
	Path            string
	PS1             string
	Shell           string
	ExternalIP      string
	CaptionBlock    CaptionBlock
	TerminalBlockId notionapi.BlockID
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL