; ============================================================================
; Module Declarations for SelfHost Admin WebApp
; ============================================================================

DeclareModule General
	; -- Configuration --
	#AppName = "SelfHost Admin"
	#Address = "http://127.0.0.1/"
	
	; -- Protocol Constants (must match server) --
	#FieldSeparator = Chr(2)
	#RecordSeparator = Chr(1)
	
	; -- Response Prefixes --
	#Prefix_NewArticle = "NA:"
	#Prefix_ListArticles = "LA:"
	#Prefix_ListFiles = "LF:"
	#Prefix_ListLanguages = "LL:"
	#Prefix_ArticleContent = "AC:"
	#Prefix_NewFile = "NF:"
	#Prefix_PreviewArticle = "PA:"
	#Prefix_UpdateArticle = "UA:"
	#Prefix_DeleteFile = "DF:"
	#Prefix_ListTags = "LT:"
	#Prefix_NewTag = "NT:"
	#Prefix_TagContent = "TC:"
	#Prefix_UpdateTag = "UT:"
	#Prefix_DeleteArticle = "DA:"
	
	; -- Public Procedures --
	Declare Init()
EndDeclareModule

DeclareModule DataModel
	; -- Data Structures --
	Structure File
		ID.i
		Name.s
		Type.s
		Size.i
	EndStructure
	
	Structure Article
		Title.s
		ID.i
		Date.i
		Draft.b
		Tags.i
	EndStructure
	
	Structure Tag
		ID.i
		BinaryID.i  ; Power of 2 for bitfield storage
		DefaultName.s
		Color.s
	EndStructure
	
	; -- Data Collections --
	Global NewMap MIMETypes.s()
	Global NewList Language.s()
	Global NewList Tags.Tag()
	Global NewList Files.File()
	Global NewList Articles.Article()
	
	; -- Public Procedures --
	; Parsing utilities
	Declare.s StripPrefix(Result.s, Prefix.s)
	Declare.s GetField(Record.s, Index)
	Declare GetRecordCount(Result.s)
	Declare.s GetRecord(Result.s, Index)
	Declare.b ValidateResponse(Result.s, ExpectedPrefix.s)
	
	; Formatting
	Declare.s FormatArticleListItem(*Article.Article)
	Declare.s FormatTagListItem(*Tag.Tag)
	
	; Lookup
	Declare FindArticleByID(ID)
	Declare FindFileByID(ID)
	Declare FindTagByID(ID)
EndDeclareModule

DeclareModule MainWindow
	Declare Open()
EndDeclareModule
; IDE Options = SpiderBasic 3.10 (Linux - x64)
; CursorPosition = 7
; Folding = 6
; iOSAppOrientation = 0
; AndroidAppCode = 0
; AndroidAppOrientation = 0
; EnableXP
; DPIAware
; CompileSourceDirectory