* Plugin code snippets in the KB

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Plugin code snippets in the KB

Post by ColeValleyGirl » 15 Dec 2020 11:28

I've reviewed the Plugin Code Snippets in the KB and marked most of them as compatible with FH7 as well as 5 & 6.

I have some queries if anyone cares to take a look:

https://fhug.org.uk/kb/code-snippet/uni ... functions/ We have utf8 support in Lua 5.3 plus the utf8 library included in the FH installation -- should we mark this one as compatible with FH7 (it will probably work, after all) or advise people to use lua 5.3 + utf8?

https://fhug.org.uk/kb/code-snippet/pla ... stitution/ Same query

If we do mark them FH7-compatible, somebody needs to review them to identify any changes or caveats needed.

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin code snippets in the KB

Post by tatewise » 15 Dec 2020 13:51

They are both essentially what my plugins use for FH v5, v6, v7 compatibility.

The only change in the UTF8 string functions is for function substring(strTxt,i,j) to cater for %z

Code: Select all

		local strUTF8 = "([%z\1-\127\194-\244][\128-\191]*)"			-- Cater for Lua 5.1 %z or Lua 5.3 \0
		if fhGetAppVersion() > 6 then
			strUTF8 = "([\0-\127\194-\244][\128-\191]*)"
		end

		-- Supply character substring of UTF-8 text --
		function substring(strTxt,i,j)
			local strSub = ""
			j = j or -1
			if j < 0 then j = j + length(strTxt) + 1 end
			if i < 0 then i = i + length(strTxt) + 1 end
			for strChr in string.gmatch(strTxt or "",strUTF8) do
				if j <= 0 then break end
				j = j - 1
				i = i - 1
				if i <= 0 then strSub = strSub..strChr end
			end
			return strSub
		end -- function substring
For the general string functions, I have added a function inert(strTxt) to hide % symbols in gsub replacement strings where no captures are involved.

Code: Select all

	-- Hide % escape/capture symbols in replacement so they are inert
	function fh.inert(strTxt)
		strTxt = tostring(strTxt or ""):gsub("%%","%%%%")					-- Hide all % symbols
		return strTxt
	end -- function inert
Clearly, it is not possible to use the Lua 5.3 + utf8 options if backward compatibility is required.
I have not yet investigated those options for plugins that only support FH v7.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 15 Dec 2020 19:05

Am I mistaken, but didn't there used to be a listing for the snippets according to category? Or am I making it up in my head because that's what I would like to see?

Shosh
Shosh Kalson

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 15 Dec 2020 19:43

Not for snippets, not. They're pretty hard to categorize... but if you want to suggest a et of categories and which snippets belong where, that would be fine.

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 15 Dec 2020 19:45

I will think about it.
Shosh Kalson

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin code snippets in the KB

Post by tatewise » 15 Dec 2020 21:11

Code Snippets were always just listed alphabetically, but the other Downloads and Links were categorised as they are in the new KB.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 16 Dec 2020 07:05

This is a quick and dirty first attempt to get a discussion going.

I created a pdf version, but it's apparently too big... So here's the Word version.
Proposed Snippet Categories.docx
(21.78 KiB) Downloaded 117 times
Shosh Kalson

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 16 Dec 2020 08:00

That breakdown looks fine to me, Shosh. I'll wait for others to comment, and when we have consensus, I'll set up the categories in the KB. I'd be grateful if somebody else would actually assign them -- I'm up to my neck at present.

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 16 Dec 2020 08:01

I can assign them.
Shosh Kalson

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 16 Dec 2020 08:06

Thanks -- let's let Mike T and anyone else who's interested weigh in.

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 16 Dec 2020 08:07

Absolutely
Shosh Kalson

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin code snippets in the KB

Post by tatewise » 16 Dec 2020 11:15

All the categories look good, although I suspect many of those in Other would fit elsewhere:
File & Folder
Load String from File
Load Text File to Table
Save String to File
Word Load Data Direct Into
Plugin / Lua / Programming
InList Is a value in a list
Strings
Format Number
User Interface
Result Set Creation

The remainder of the snippets under Other could go under Project Database Admin
Ancestor & Descendant List
Build Data Refs
Copy Child Branch Fields
Flags Add and Remove Function
Last Updated Date and Time
Relationship Codes
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 16 Dec 2020 12:00

I have no objections
Shosh Kalson

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 16 Dec 2020 12:21

Give me a while to remember how to set it all up...

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 16 Dec 2020 12:24

No pressure...
Shosh Kalson

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 16 Dec 2020 12:30

Shosh, you should be able to categorise them now -- let me know when you've done a few with different categories and I can check how they're displaying.

Thanks.

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 16 Dec 2020 12:34

I don't see any snippet categories. I am trying both 'quick edit' and 'edit.'
Shosh Kalson

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 16 Dec 2020 12:43

I'm an idiot -- forgot to add all the categories. BRB...

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 16 Dec 2020 12:51

Try now. Don't forget you can put a plugin in two or more caregories if it makes sense to do so.

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 16 Dec 2020 13:35

I can see the categories now, but can't assign them -- I get a 'forbidden' icon.

Tried it from both 'edit' and 'quick edit'
Shosh Kalson

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 16 Dec 2020 13:49

Try now -- my brain is running on very low blood pressure today!

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 16 Dec 2020 16:13

I assigned categories to one page full of snippets.

One thing that I notice in the display (kb->downloads>snippets) is that snippets that have not been assigned to a category do not show up anywhere.

Shosh
Shosh Kalson

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 16 Dec 2020 16:39

It's expected the uncategorised snippets won't show up... I'll try to do a few myself.

avatar
shoshk
Famous
Posts: 242
Joined: 13 May 2015 16:28
Family Historian: V7
Location: Mitzpe Jericho, Israel

Re: Plugin code snippets in the KB

Post by shoshk » 16 Dec 2020 16:53

I don't have a problem to do the work, but it'll have to wait until tomorrow morning (it's almost 19:00 here).

Is there someway to verify that all snippets are categorized, short of going through them manually and checking?
Shosh Kalson

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Plugin code snippets in the KB

Post by ColeValleyGirl » 16 Dec 2020 19:14

I don't know of one, other than comparing counts... But let me know when you think you're finished and I'll try to double check.

Post Reply