It is currently April 19th, 2024, 8:06 pm

Creating a skin that displays text from a reference manual

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7128
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Creating a skin that displays text from a reference manual

Post by Yincognito »

CieroCeramics wrote: March 30th, 2020, 10:26 pm feeling somewhat ashamed at my lack of skills and overwhelemed with the your guyses talent rendered me a silent observer of this.
however seeing the interaction between Yincognito and cordemanon gave me a new burst of hope. I have been using what I have been calling DocuGetv3 by eclectic-tech (v1 by balala and v2 by yincognito)
for some reason the skin is not properly searching anymore, and instead appearing blank. I think this might be an issue with the google search URL or the User agent. which when trying to look into I was VERY overwhelmed with info that I simply did not understand.
Maybe trying eclectic-tech's version solves the issue, because so far it seemed hard to localize it (since everything more or less worked fine for us in our posted samples). If not, maybe posting your code and a precise explanation of what happens and when it happens (also, if that's the case, when it doesn't happen as well) - I'm talking about the issue you're facing - could help in identifying the underlying problem, if any.
CieroCeramics wrote: March 30th, 2020, 10:26 pmI know it seems silly, why the heck would I want that. well it's simple. I am a huge sucker for my sexy UI and I will not compromise.the clunky nature of modern browsers is simply too disruptive to my workflow.
that being said, what I want IS possible. look at this lua script.
[...]
the only thing I can't seem to get rid of is the annoying meta tags. which only represents the top half of the page.
I have come to understand regex is really more of a word by word. nay, character by character parsing method, but there's gotta be a way to get rid of those meta tags. and then. once you get that .txt file.
parse it with the ever famed jsmorelys lua scroll text
putting this together should theoretically be simple. but without a working example for parsing the actual web data I am left helpless in going any further.
It does NOT seem silly - at least not for me. I like your attitude, to not give up, not compromise and prove things are possible. Love it. Nice finds in terms of code as well, they help here indeed. Like I said, eliminating things you don't need (like tags and stuff done in Lua) is not overly complicated, but the problem comes when trying to make header-like styles from HTML. There are huge variations of styles (and I'm not even considering the internal/external CSS at this point, or, going even further, the different variations of HTML code, like XHTML and such) possible in HTML and covering them all is going to be like trying to catch all mosquitoes in the air. What can be done with reasonable effort is to somehow format the content of <title></title> or <ul><li>...</li>...</ul> before the mass elimination of tags begins (so that you know where to style differently, since tags are the only indication of something's location in HTML and you lose them after that "mass cleaning").

That being said, I don't quite get the issue you have with the meta tags: the image you posted seems to indicate that you already took care of that. Of course, these tags can be a little different from others, in that they are not explicitly closed (i.e. they have no end tag, like, for example </meta>), but this shouldn't be problematic if either the Rainmeter or Lua's regex bits are adjusted to handle it...

I think your code would be helpful here. I am quite busy today so I can't guarantee I'll take care of it, but hopefully the code won't be (yet) too complex to try something, eventually.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
CieroCeramics
Posts: 4
Joined: March 19th, 2020, 11:08 pm

Re: Creating a skin that displays text from a reference manual

Post by CieroCeramics »

but alas, using eclectic-techs working example, and even incorperating Yincognitos updated regex, I am simply not getting any results.

Yincognito wrote: April 2nd, 2020, 6:46 am Maybe trying eclectic-tech's version solves the issue, because so far it seemed hard to localize it (since everything more or less worked fine for us in our posted samples). If not, maybe posting your code and a precise explanation of what happens and when it happens (also, if that's the case, when it doesn't happen as well) - I'm talking about the issue you're facing - could help in identifying the underlying problem, if any.



It does NOT seem silly - at least not for me. I like your attitude, to not give up, not compromise and prove things are possible. Love it. Nice finds in terms of code as well, they help here indeed. Like I said, eliminating things you don't need (like tags and stuff done in Lua) is not overly complicated, but the problem comes when trying to make header-like styles from HTML. There are huge variations of styles (and I'm not even considering the internal/external CSS at this point, or, going even further, the different variations of HTML code, like XHTML and such) possible in HTML and covering them all is going to be like trying to catch all mosquitoes in the air. What can be done with reasonable effort is to somehow format the content of <title></title> or <ul><li>...</li>...</ul> before the mass elimination of tags begins (so that you know where to style differently, since tags are the only indication of something's location in HTML and you lose them after that "mass cleaning").

That being said, I don't quite get the issue you have with the meta tags: the image you posted seems to indicate that you already took care of that. Of course, these tags can be a little different from others, in that they are not explicitly closed (i.e. they have no end tag, like, for example </meta>), but this shouldn't be problematic if either the Rainmeter or Lua's regex bits are adjusted to handle it...

I think your code would be helpful here. I am quite busy today so I can't guarantee I'll take care of it, but hopefully the code won't be (yet) too complex to try something, eventually.
to answer your questions hopefully.
it used to happen, now it doesn't happen. it never happens anymore, nothing I do or type allows it to happen, no versions work, none of the posted versions, with any of the various regex strings... work.
now its hypothesis time.
lets just say I have a knack for entropic coding. I like to push something to its limits, so I may understand it. not realizing how sensitive the topic "user agents" might have been. I began running pretty absurd experiments. switching around strings from various websites, changing my default browser, checking how it effected the string at www.whatismybrowser.com, doing tests with wget and curl, checking out which sites I could actually crawl, seeing what I could get away with, not taking advantage of it, but just to know if certain things were possible. call it gross curiousity
and somewhere along the lines,
I believe some network administrator,.or a powerful google webmaster.
decided "this man and his outrageous experimentation must be stopped."
this is only a theory. but I can't think of any other reason this could be happening.
other skins that take in regex seem to work fine, like RSS feeds and Weather.
but I realize RSS is designed to allow for crawling
if this isn't what is causing my problem, and all I have done is demonstrated a tragic misunderstanding of the nature of user agents, then allow me to digress
it could be that around the time it stopped working I was trying out different browsers. because as I said before most modern browsers are too clunky and disruptive. I tried going back to my default browser before the issue started but that doesn't seem to help.

Another thing i did that might have cause my problem, is I moved my rainmeters skin folder. It was stored in my OneDrive by default, which would promptly filled up and start deleting unused skins. so in order to preserve them I moved it to a local folder.
right now when I run the newest example by eclectic-tech I can select a doc from the context menu, I can type in to search and then the result is empy
when I REFRESH the skin I get "No documents found!" even when searching something obvious like "skins" or "web parser" in the rainmeter docs.
I don't think I can really post much else in the form of code as even the bare copy paste of the originals will not work properly.


now as for those meta tags. they aren't actually taken care of.
I just went into the produced .txt and deleted all of them myself. not a big deal to show off my proof of concept. but I wouldn't want to have to do that everytime.
also, I don't really NEED the styling, certainly it would be nice to have, and its great to know its possible. but I may have to leave that for when I have a little more regular expression under my belt. right now I am content with a small little scroll box with plain font.
If I can ever get this to work, another option might be to run it through a text based browser like lynx and just read it from there.
I really appreciate your help. hopefully my info can provide some insights on my issue.
User avatar
Yincognito
Rainmeter Sage
Posts: 7128
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Creating a skin that displays text from a reference manual

Post by Yincognito »

CieroCeramics wrote: April 2nd, 2020, 11:59 pmbut alas, using eclectic-techs working example, and even incorperating Yincognitos updated regex, I am simply not getting any results.
Well, if you were "banned" from searching on Google through WebParser, there isn't much you can do, other than wait and try later on. If you messed up browsers' installations, the "easy" option is to uninstall all of them and reinstall a single one, the one you want to work with in that moment, and the "difficult" option is to do a clean reinstall of your operating system (as some browsers do have "deeper roots" than one might expect). If there is some OneDrive thing that's interfering with this, I'm afraid I can't help, as I don't use these kind of services.

Now, the 1st possibility is possible, but slightly improbable. The 2nd is highly probable, as it's the 3rd. So, what I would do is, in order:
- set Rainmeter's skin folder back to its default (I'm not sure if it hates having this folder changed, but just to cover the possibility)
- try one more time to make the skin work (using the slightly modified eclectic-tech's sample below)
- try to simplify the process in the skin to the maximum, maybe having just one measure & meter if possible, in the hope you'll find the culprit by elimination (if there is a culprit, that is)
- try other very similar skins (even building a basic skin with just the [MeasureIPinfo] and another meter in it and looking in Rainmeter's log to see if the measure gets some value/content would probably help)
- if none of the above work, do a clean reinstall of Rainmeter (after you back up your data in the relevant folders, of course) and see if that helps
- uninstall all browsers and clean reinstall a single one (I tested the code in Chrome 80, for example), then after an OS restart see how it goes
- clean reinstall the operating system (backup data, prepare necessary drivers, etc.)

That being said, here's one more attempt of a code. The changes are minor, but who knows, maybe you get lucky:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

RightMouseUpAction=[!SkinCustomMenu]

ContextTitle=Google Docs
ContextAction=[!WriteKeyValue "Variables" "Site" "Google.com"][!SetVariable "Site" "Google.com"][!UpdateMeasure "MeasureIPinfo"][!UpdateMeasure "MeasureSiteTitle"][!CommandMeasure "MeasureIPinfo" "Update"]
ContextTitle2=Microsoft Docs
ContextAction2=[!WriteKeyValue "Variables" "Site" "Microsoft.com"][!SetVariable "Site" "Microsoft.com"][!UpdateMeasure "MeasureIPinfo"][!UpdateMeasure "MeasureSiteTitle"][!CommandMeasure "MeasureIPinfo" "Update"]
ContextTitle3=Oracle Docs
ContextAction3=[!WriteKeyValue "Variables" "Site" "Oracle.com"][!SetVariable "Site" "Oracle.com"][!UpdateMeasure "MeasureIPinfo"][!UpdateMeasure "MeasureSiteTitle"][!CommandMeasure "MeasureIPinfo" "Update"]
ContextTitle4=Rainmeter Docs
ContextAction4=[!WriteKeyValue "Variables" "Site" "Rainmeter.net"][!SetVariable "Site" "Rainmeter.net"][!UpdateMeasure "MeasureIPinfo"][!UpdateMeasure "MeasureSiteTitle"][!CommandMeasure "MeasureIPinfo" "Update"]
ContextTitle5=---
ContextTitle6=More actions...
ContextAction6=[!SkinMenu]

[Variables]
Site=Rainmeter.net
Item=(?(?=.*<div class="g".*>).*<div class="g".*>.*<div class="rc".*>.*<div class="r".*>.*<a href="(.*)".*>.*<h3 class=".*">(.*)</h3>.*<div class="s".*>.*<span class="st".*>(.*)</span>.*</div>)
ToSearch=skin
TagCleaner="(?siU)<([^\s]+)(?: .+)?>":""
TooltipW=300

[StringStyle]
X=0
Y=0R
W=300
ClipString=1
Padding=15,2,15,2
FontColor=255,255,255
FontEffectColor=0,0,0
SolidColor=0,0,0,1
StringEffect=Shadow
FontSize=10
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%1
MouseOverAction=[!SetOption #CURRENTSECTION# InlineSetting "Underline"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# InlineSetting "None"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]

[MeasureSiteTitle]
Measure=String
String=#Site#
RegExpSubstitute=1
Substitute="^(.*)\..*$":"\1"
DynamicVariables=1

[MeasureInputText]
Measure=Plugin
Plugin=InputText
X=15
Y=6
W=300
H=16
Command1=[!SetOption MeterTitle1 Text "%1"][!UpdateMeter MeterTitle1][!Redraw][!WriteKeyValue Variables ToSearch "$UserInput$"][!SetVariable "ToSearch" "[MeasureInputText]"][!UpdateMeasure "MeasureIPinfo"][!UpdateMeasure "MeasureSiteTitle"][!CommandMeasure "MeasureIPinfo" "Update"]
DefaultValue=#ToSearch#
FontColor=0,0,0,255
FontFace=SegoeUI
FontSize=10

[MeasureIPinfo]
Measure=WebParser
UpdateRate=3600
Url=https://www.google.com/search?sitesearch=docs.#Site#&q=#ToSearch#
UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
RegExp=(?siU).*<div id="search".*>#Item##Item##Item##Item##Item#.*
DynamicVariables=1
LogSubstringErrors=0

[MeasureAddress1]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=1

[MeasureTitle1]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=2
DecodeCharacterReference=1
IfMatch=^$
IfMatchAction=[!SetOption MeterTitle1 Text "No documents found!"][!UpdateMeter MeterTitle1][!Redraw]
IfNotMatchAction=[!SetOption MeterTitle1 Text "%1"][!UpdateMeter MeterTitle1][!Redraw]

[MeasureExtract1]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=3
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="#TagCleaner#"
DynamicVariables=1

[MeasureAddress2]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=4

[MeasureTitle2]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=5
DecodeCharacterReference=1

[MeasureExtract2]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=6
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="#TagCleaner#"

[MeasureAddress3]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=7

[MeasureTitle3]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=8
DecodeCharacterReference=1

[MeasureExtract3]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=9
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="#TagCleaner#"

[MeasureAddress4]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=10

[MeasureTitle4]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=11
DecodeCharacterReference=1

[MeasureExtract4]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=12
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="#TagCleaner#"

[MeasureAddress5]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=13

[MeasureTitle5]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=14
DecodeCharacterReference=1

[MeasureExtract5]
Measure=WebParser
Url=[MeasureIPinfo]
StringIndex=15
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="#TagCleaner#"

[MeterBackgground]
Meter=Shape
X=0
Y=0
Shape=Rectangle 0,0,330,145,3 | Fill Color 0,0,0,80 | StrokeWidth 1 | StrokeColor 0,0,0,220

[MeterSearch]
Meter=STRING
X=0
Y=0
W=300
Padding=15,5,15,5
FontColor=255,255,255,255
FontEffectColor=0,0,0,255
SolidColor=0,0,0,100
StringEffect=Shadow
FontSize=10
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=[&MeasureSiteTitle] Doc Search for "#ToSearch#":
LeftMouseUpAction=!CommandMeasure "MeasureInputText" "ExecuteBatch 1"
DynamicVariables=1

[MeterTitle1]
Meter=STRING
MeterStyle=StringStyle
MeasureName=MeasureTitle1
LeftMouseUpAction=["[MeasureAddress1]"]
TooltipText="[MeasureExtract1]"
TooltipWidth=#TooltipW#
DynamicVariables=1

[MeterTitle2]
Meter=STRING
MeterStyle=StringStyle
MeasureName=MeasureTitle2
LeftMouseUpAction=["[MeasureAddress2]"]
TooltipText="[MeasureExtract2]"
TooltipWidth=#TooltipW#
DynamicVariables=1

[MeterTitle3]
Meter=STRING
MeterStyle=StringStyle
MeasureName=MeasureTitle3
LeftMouseUpAction=["[MeasureAddress3]"]
TooltipText="[MeasureExtract3]"
TooltipWidth=#TooltipW#
DynamicVariables=1

[MeterTitle4]
Meter=STRING
MeterStyle=StringStyle
MeasureName=MeasureTitle4
LeftMouseUpAction=["[MeasureAddress4]"]
TooltipText="[MeasureExtract4]"
TooltipWidth=#TooltipW#
DynamicVariables=1

[MeterTitle5]
Meter=STRING
MeterStyle=StringStyle
MeasureName=MeasureTitle5
LeftMouseUpAction=["[MeasureAddress5]"]
TooltipText="[MeasureExtract5]"
TooltipWidth=#TooltipW#
DynamicVariables=1
Padding=15,2,15,5
The main changes are a slightly updated Item regex:

Code: Select all

Item=(?(?=.*<div class="g".*>).*<div class="g".*>.*<div class="rc".*>.*<div class="r".*>.*<a href="(.*)".*>.*<h3 class=".*">(.*)</h3>.*<div class="s".*>.*<span class="st".*>(.*)</span>.*</div>)
And a new user agent (didn't use whatismybrowser.com for this, but instead searched "my user agent" on Google and took the big text before the search results - curiously, this worked, unlike taking the string from whatismybrowser.com, which, by the way, failed for me too):

Code: Select all

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
Let me know how it goes.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth