STUSK (Stupid site keeper)

Share your advanced PureBasic knowledge/code with the community.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: STUSK (Stupid site keeper)

Post by Fangbeast »

[quote="Perkin"]I think I've got it.
Replace the OpenBookMarks() procedure from the test code with this

Should be usable for all the importing (IE, FF and Opera)

Yay!! Works well. I'm so happy that someone has a brain, mine is pickled from smelling that festering pile of pickled sheep tits srod (srod, where the hell is that death you promised me???) that I will give you his preloved underpants collection!!

I'll put it in tomorrow. Still need sleep, haven't recovered from the flu (and other things).

Oh bugger, that means I now have to make a help file:(:(
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: STUSK (Stupid site keeper)

Post by Perkin »

:lol:

Hope you recover soon, I had a bad cold a few weeks ago, so I sympathize.

Glad I could help, rather than just annoy you with problems.
%101010 = $2A = 42
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: STUSK (Stupid site keeper)

Post by Fangbeast »

Hope you recover soon, I had a bad cold a few weeks ago, so I sympathize.
Worse than a cold. I got the cold after exercising for 3 days straight. Coughed and sneezed so much that I caught the cold. Ironic, isn't it? The I got constipated int he middle of it and took tablets to help things along. I had the worse cramps ever that nearly made me pass out times in the loo. Nobody home, could have broken my neck. We found out on the net how dangerous these tablets were (after the fact of course). Then After the tablets wore off, I had the opposite effect on the insides for 3 days,, no wonder I could not concentrate! Will take another week to get back to normal.
Glad I could help, rather than just annoy you with problems.
Hah! Annoy me?? Your ideas keep me going and doing something useful. Pity the remaining brain cells are so small that I keep having brain farts.

Here is the cleaned and revised sample code, hope others can use it too. I need my ugly sleep now and will fix SiteList tomorrow and upload it. Then I ave to think about a help file (oh, my aching fingers)

Code: Select all

Enumeration 1
  #Window_BookMarks
EndEnumeration

#WindowIndex = #PB_Compiler_EnumerationValue

Enumeration 1
  #Gadget_BookMarks_fmain
  #Gadget_BookMarks_BookMarks
  #Gadget_BookMarks_fcontrol
  #Gadget_BookMarks_OpenFile
  #Gadget_BookMarks_ExitProgram
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

Enumeration 1
  #Image_BookMarks_OpenFile
  #Image_BookMarks_ExitProgram
EndEnumeration

#ImageIndex = #PB_Compiler_EnumerationValue

CatchImage(#Image_BookMarks_OpenFile,     ?_OPT_BookMarks_OpenFile)
CatchImage(#Image_BookMarks_ExitProgram,  ?_OPT_BookMarks_ExitProgram)

DataSection
  _OPT_BookMarks_OpenFile     : IncludeBinary "Images\open32x32.ico"
  _OPT_BookMarks_ExitProgram  : IncludeBinary "Images\exit32x32.ico"
EndDataSection

Procedure.l Window_BookMarks()
  If OpenWindow(#Window_BookMarks,65,76,750,600,"",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
      Frame3DGadget(#Gadget_BookMarks_fmain,5,0,740,530,"")
      ListIconGadget(#Gadget_BookMarks_BookMarks,15,15,720,505,"Bookmark",200,#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        AddGadgetColumn(#Gadget_BookMarks_BookMarks,1,"Title",200)
        AddGadgetColumn(#Gadget_BookMarks_BookMarks,2,"Description",200)
        AddGadgetColumn(#Gadget_BookMarks_BookMarks,3,"Category",100)
        AddGadgetColumn(#Gadget_BookMarks_BookMarks,4,"Owner",100)
        SetGadgetFont(#Gadget_BookMarks_BookMarks,LoadFont(#Gadget_BookMarks_BookMarks,"Arial",11,0))
      Frame3DGadget(#Gadget_BookMarks_fcontrol,5,530,740,65,"")
      ButtonImageGadget(#Gadget_BookMarks_OpenFile,15,545,40,40,ImageID(#Image_BookMarks_OpenFile))
      ButtonImageGadget(#Gadget_BookMarks_ExitProgram,695,545,40,40,ImageID(#Image_BookMarks_ExitProgram))
      HideWindow(#Window_BookMarks,0)
      ProcedureReturn WindowID(#Window_BookMarks)
  EndIf
EndProcedure

Declare   OpenBookMarks()
Declare.s XMLToText(XMLString.s)

Structure ProgramData
  QuitValue.i
  CurrentDir.s
  CurrentLine.i
EndStructure

Global Program.ProgramData

Program\CurrentDir  = GetCurrentDirectory()

Procedure OpenBookMarks()
  BookMarkFile.s = OpenFileRequester("Select exported browser bookmarks file", Program\CurrentDir, "HTM (*.htm;*.html)|*.htm;*.html", 1)
  If BookMarkFile.s
    ExpressionId.i = CreateRegularExpression(#PB_Any, "\<[^\<]+\>")
    OwnerName.s = StringField(GetHomeDirectory(), 3, "\")
    InFileId.i = ReadFile(#PB_Any, BookMarkFile.s)
    If InFileId.i
      LineCheck.i = 0
      While Eof(InFileId.i) = 0
        TempString.s = ReadString(InFileId.i)
        LineCheck.i + 1
        If FindString(TempString.s, "<DT>", 1) And FindString(TempString.s, "A HREF", 1)
          MainData.i = 1
          GotOne.i = LineCheck.i
          TempURL.s   = StringField(TempString.s, 2, Chr(34))
          TempTitle.s = LTrim(RTrim(ReplaceRegularExpression(ExpressionId.i, TempString.s, "")))
          TempTitle.s = XMLToText(TempTitle.s)
          If LCase(Right(TempTitle.s, 4)) = ".url"
            TempTitle.s = Left(TempTitle.s, Len(TempTitle.s) - 4)
          EndIf
          AddGadgetItem(#Gadget_BookMarks_BookMarks, -1, TempURL.s + Chr(10) + TempTitle.s + Chr(10) + "" + Chr(10) + "InterNet BookMark" + Chr(10) + OwnerName.s)
        EndIf
        If FindString(TempString.s, "<DD>", 1) And MainData.i = 1 And LineCheck.i = GotOne.i + 1
          Description.s = LTrim(RTrim(ReplaceRegularExpression(ExpressionId.i, TempString.s, "")))
          Description = XMLToText(Description.s)
          MainData.i = 0
          SetGadgetItemText(#Gadget_BookMarks_BookMarks, CountGadgetItems(#Gadget_BookMarks_BookMarks) - 1, Description.s, 2)
        EndIf
        Description.s = ""
      Wend
    Else
      Debug "Could not open the internet bookmarks file off disk."
    EndIf
  Else
    Debug "Nothing to process, user cancelled the file load."
  EndIf
EndProcedure

Procedure.s XMLToText(XMLString.s)
  TextString.s = RemoveString(XMLString.s, Chr(13))
  If Left(TextString.s, 1) = Chr(10)
    TextString.s = Mid(TextString.s, 2)
  EndIf
  TextString.s = ReplaceString(TextString.s, "&", "&")
  TextString.s = ReplaceString(TextString.s, "<", "<")
  TextString.s = ReplaceString(TextString.s, ">", ">")
  TextString.s = ReplaceString(TextString.s, "&apos;", "'")
  TextString.s = ReplaceString(TextString.s, """, Chr(34))
  TextString.s = ReplaceString(TextString.s, "&#128", "€")
  TextString.s = ReplaceString(TextString.s, "'", "'")
  ;TextString.s = ReplaceString(TextString.s, Chr(10), "")
  ;TextString.s = ReplaceString(TextString.s, Chr(182), Chr(10))
  ;TextString.s = ReplaceString(TextString.s, Chr(13), "")
  ProcedureReturn Trim(TextString.s)
EndProcedure

; XIncludeFile "FireFoxMarks_Constants.pb"                                                ; 
; XIncludeFile "FireFoxMarks_Windows.pb"                                                  ; 
; XIncludeFile "FireFoxMarks_Mydeclarations.pb"                                           ; All procedural declarations
; XIncludeFile "FireFoxMarks_Myconstants.pb"                                              ; All my personal constants

; XIncludeFile "Modules\_OpenBookMarks.pbi"                                               ; Open FireFox Bookmarks file
; XIncludeFile "Modules\_XMLToText.pbi"                                                   ; Strip illegal characters from text strings

If Window_BookMarks()
  Program\QuitValue = 0
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Select EventWindow()
          Case #Window_BookMarks                    : Program\QuitValue = 1
        EndSelect
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #Gadget_BookMarks_BookMarks
            Select EventType()
              Case #PB_EventType_LeftDoubleClick
              Case #PB_EventType_RightDoubleClick
              Case #PB_EventType_RightClick
              Default
            EndSelect
          Case #Gadget_BookMarks_OpenFile           : OpenBookMarks()
          Case #Gadget_BookMarks_ExitProgram
        EndSelect

    EndSelect
  Until Program\QuitValue
  CloseWindow(#Window_BookMarks)
EndIf
End
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: STUSK (Stupid site keeper)

Post by Perkin »

Hope you recover soon. :lol: And you say it's srod with the festering underpants, they must be contagious, so you can blame him. :lol:
%101010 = $2A = 42
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: STUSK (Stupid site keeper)

Post by Fangbeast »

Yay! Updated. SiteList can now import Bookmarks (htm, html) from FireFox, I.E, and Opera. (Thanks to Perkin for working out some logic that I was unable to do).

Program updated, version number unchanged. Link is in the first post as usual. I will explain more later!
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: STUSK (Stupid site keeper)

Post by Fangbeast »

Perkin, I have been playing around with the unicode compiler preferences and got help from Trond and TS-Soft on a few issues.

I wanted to display the extended characters from the imported internet bookmarks and it seems to work, store and redisplay just fine.

Do you want the unicode enabled version to test? You will have to delete your md5fingerprint value from the INI file and do it again (so I don't have to write workarounds).

Let me know would you?
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: STUSK (Stupid site keeper)

Post by Perkin »

Yes, I'll give it a try.
%101010 = $2A = 42
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: STUSK (Stupid site keeper)

Post by Perkin »

Just as a quick test, using the last testcode and applying Unicode switch in compiler options.
All the faves with unicode import fine

I've got to find a few sites which will have unicode descriptions when bookmarked.
%101010 = $2A = 42
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: STUSK (Stupid site keeper)

Post by Fangbeast »

Perkin wrote:Just as a quick test, using the last testcode and applying Unicode switch in compiler options.
All the faves with unicode import fine

I've got to find a few sites which will have unicode descriptions when bookmarked.
I know the sample code works fine but I was talking about SiteList itself which threw a conniption. And only because I didn't know what I was doing:):):)
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: STUSK (Stupid site keeper)

Post by Perkin »

I realise that's what you meant, just pointing out that the code we sorted out worked with unicode,
so any code based on it should work.

Apart from a few others, the main titles of any sites which have unicode are mainly from this forum,
Unicode representing the bullet in the titles.
A couple of others I've got are a double-arrow facing right (sort of fast-forward) symbol.
%101010 = $2A = 42
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: STUSK (Stupid site keeper)

Post by Fangbeast »

I realise that's what you meant, just pointing out that the code we sorted out worked with unicode, so any code based on it should work.
Only when you know what you are doing, which I obviously didn't.
Apart from a few others, the main titles of any sites which have unicode are mainly from this forum, Unicode representing the bullet in the titles. A couple of others I've got are a double-arrow facing right (sort of fast-forward) symbol.
I had a lot more with strange characters (now cleared up) so I thought that it might be worth it. After vreakfast then!
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: STUSK (Stupid site keeper)

Post by Fangbeast »

Current unicode test version exe is uploaded and the link is in the first post. Needs testing to see what breaks.

1. Also reworked the Copy-To-Clipboard routine. It now tests the fields with replaceable labels to see if they are both empty and if so, that field is omitted from the copy.

2. Saved 60 lines of code by placing multiple duplicated commands into 1 procedure.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: STUSK (Stupid site keeper)

Post by Fangbeast »

In case I forgot the current full list of changes, here they are.

Added The ability to tag all items currently in the currently showing list

Added The shortcut key menu has been updated for this new key

Added The menu text functions have been updated for this key

Added The ability to import exported Firefox/Ie/Opera htm bookmarks (Perkin's idea)

Added The ability to detect when a duplicated keyboard shortcut is entered and what it is currently assigned to.

Added Windows close button to form title for all windows.

Changed: Combo boxes down one font size to allow longer names

Changed: Removed All and Empty categories in category combo, no sense to have them

Changed: Removed All and Empty owners in owners combo, no sense to have them

Added Warning message when owner, category or first line of data are empty. Data will not be saved.

Added: Window closing code for all the window close buttons

Lazy Perkin should be happy with me now and not bash me around the head with srod's festering underpants

Link in first post as usual
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: STUSK (Stupid site keeper)

Post by Perkin »

:lol:
I've got to buy a new set of industrial protective clothing, then I'll get srod's underpants,
(If I can catch them) and put them in a bunker, just so they're ready for you.

Then I'll just have to find a reason to unleash them on you. :lol:

Thanks.
%101010 = $2A = 42
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: STUSK (Stupid site keeper)

Post by Fangbeast »

I've got to buy a new set of industrial protective clothing, then I'll get srod's underpants, (If I can catch them) and put them in a bunker, just so they're ready for you.
Thanks a lot. With my luck, they will include the traumatised sheep in them!!
Then I'll just have to find a reason to unleash them on you.
Noooooo!! Do you know how they got that way????? (Shudder)

As the only tester i've got, i'll keep my feral gerbils away from your crop of srod's traumatised sheep.

Let me know what else this steaming great pile of software needs. And no more laziness or you will go blind!!
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Post Reply