Web View

Here is where the magnanimous folks that create externals post them (.zip archives only please).

Re: Web View

Postby bookbuzz » Fri Jan 30, 2009 6:27 am

Thanks a million. I'd totally forgot to try SuperEdit.

BookBuzz
bookbuzz
 
Posts: 13
Joined: Tue Jan 13, 2009 3:54 pm

Re: Web View

Postby bookbuzz » Fri Jan 30, 2009 8:52 am

bmartin wrote:In SuperEdit you have to use the Import Bundle External... from the file menu. This will import the needed resources into a new project from there you can move as needed in the usual ways. Since this is still in development I wouldn't expect it to be delivered in the traditional manor because building an app with this external may lead to issues that are unseen right now. So if you don't have SE you muse wait.


Thanks again. That was easy enough. The external works well for my demo prototype.
bookbuzz
 
Posts: 13
Joined: Tue Jan 13, 2009 3:54 pm

Re: Web View

Postby sctell » Sun Feb 08, 2009 11:39 am

Hi all,

I have just posted an update of SCWebView.

You can download it here:

http://www.theaford.co.uk/Site/SC_Externals_files/SCWebViewTest.zip

I have not had much time to work on it in the last two weeks but have made some progress.

The functions now available are:

init
createWebView
release
hideWebView
showWebView
loadURLText
goForward
goBack
setFocusToWebView
setFocusToSC
makeTextLarger
makeTextSmaller
reload
doJavaScript
loadHTMLFile

It is now possible to have more than one WebView attached to a window.
Please see the instructions in the test project.

It should be possible to have two WebViews attached to separate windows but I have not tested this.

This is not the finished product and I would appreciate comments.
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby sctell » Sun Feb 15, 2009 3:57 am

Hi,

Another update. I will continue to add functions as time allows:

You can download it here:

http://www.theaford.co.uk/Site/SC_Externals_files/SCWebViewTest.zip

The functions now available are:

init
createWebView
release
hideWebView
showWebView
loadURLText
goForward
goBack
setFocusToWebView
setFocusToSC
makeTextLarger
makeTextSmaller
reload
doJavaScript
loadHTMLFile


I have added two new functions for this update:

loadHTMLString (NEW)
getSourceCode (NEW)
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby Dave_Higgins » Thu Feb 19, 2009 5:10 pm

haden_young wrote:I have added two new functions for this update:

loadHTMLString (NEW)
getSourceCode (NEW)

Looking very good now. Nice work. The ability to have more than one view open at a time is a real help.

Dave.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: Web View

Postby johnjohnston1 » Sun Feb 22, 2009 6:32 am

Hi Terry,
This is great, thanks.
Is there a way to tell when the page has finished loading?

cheers

john
User avatar
johnjohnston1
 
Posts: 196
Joined: Sun Jul 06, 2008 10:42 am
Location: Glasgow, UK

Re: Web View

Postby sctell » Sun Feb 22, 2009 7:56 am

Hi John,

Thanks for the encouragement.

I will include a function to tell when the page has loaded in the next update, probably in a weeks time.

I have not worked on the external much at all in the last week as I have been really busy at home.

The next update will be the first version that I consider not a test.

I will unfortunately be changing the syntax for the external to simplify things.

Gone will be:

init
release

You just call:

put SCWebView("createWebView","wd id 100",tLeft,tTop,tWidth,tHeight) into gWebView

You will then be responsible for maintaining gWebView or whatever variable you have used.

To call a function you will for example:

put SCWebView("loadURLText",gWebView,tURLText) into tInfo

With gWebView provided from the saved variable when the web view was created.

When you have finished with a web view you will:

put SCWebView("deleteWebView",gWebView) into tInfo

The external will know which window gWebView is attached to.

I think this should make using the external a little easier.
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby Dave_Higgins » Sat Mar 07, 2009 1:04 pm

haden_young wrote:I will include a function to tell when the page has loaded in the next update, probably in a weeks time.

This would be ideal to use as an unsolicited message (as opposed to polling queries to check something like this). Tomas had set many of his externals to send AppleEvents with various class & IDs. Direct data (----) could contain the ref ID, and even other selectors could contain the URL (wurl). The on appleEvent handler would then request ae data with keyword "wurl" to get the url that finished loading.

Another message that might be useful is a notification of an automatic refresh (start and finish). Not an absolute "gotta have now" thing, you know... Just one for the back pocket. :-)

These AE messages are how you could alert SC to things like links being clicked on, text fields being opened/closed, buttons being clicked, etc...

haden_young wrote:To call a function you will for example:
put SCWebView("loadURLText",gWebView,tURLText) into tInfo
With gWebView provided from the saved variable when the web view was created.

I was about to ask about the need for both a ref ID (gWebView) and the window ID as parameters. Looks like you eliminated the need for both now.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Web View (Window Ordering)

Postby Dave_Higgins » Sat Mar 07, 2009 1:15 pm

I've noticed some oddities when using SCWebView. There are times when another app is brought up front, then SC is brought back up that the SCWebView window will not layer in front (like it hides behind Finder windows, for instance). Once the view is released the layering goes back to working normal. Is there a trick or formula to make this work right?
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: Web View

Postby sctell » Mon Mar 09, 2009 4:22 am

Hi,

I have not looked at the external for over 2 weeks now as a result of other committments.

I will hopefully have some time this week.

I really want to get this external right and must apologise for the time it is taking.

I suppose this is one of the issues of waiting for externals that are produced by "amateurs" rather than "professional (paid)" programmers in that you have to be patient until the "amateurs" can get the time.
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby Anderson » Mon Mar 09, 2009 7:11 pm

I downloaded the most recent SCWebViewTest and had it up and running with 2 views. Very cool I thought. When I turned on and tried to tune in tonite the webview crashed on CreateView and would not run. How come?
Anderson.
iMac - High Sierra - SC(current beta)
User avatar
Anderson
 
Posts: 220
Joined: Mon Jul 21, 2008 9:00 am
Location: Perth County, Canada

Re: Web View

Postby sctell » Sun Mar 22, 2009 12:01 am

Hi,

I am back working on this again and would hope to release an update during the next week.


Dave,
I've noticed some oddities when using SCWebView. There are times when another app is brought up front, then SC is brought back up that the SCWebView window will not layer in front (like it hides behind Finder windows, for instance). Once the view is released the layering goes back to working normal. Is there a trick or formula to make this work right?


Having looked at this the answer seems to be to place this in the openProject handler:

Code: Select all
set the singleWindowLayer to true
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby sctell » Sun Mar 22, 2009 12:03 am

Hi again,

Although I have not put an update on my web site and to show I have done something here is the latest list of functions etc.

FUNCTIONS:

createWindowGroup
createWebView
releaseWebView
setFrameRect

setFocusToWebView
setFocusToSC

hideWebView
showWebView

loadURLText

goForward
goBack

makeTextLarger
makeTextSmaller

reload

doJavaScript
loadHTMLFile
loadHTMLString
getSourceCode

mainFrameTitle
mainFrameURL

setEditable
cut
copy
paste


GLOBALS:

SCWV_frameLoaded
the external sets this global to true
when the frame has finished loading

SCWV_errorDescription
the external sets this global with a text description
relating to the error encountered when loading a page
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby Ken Norris » Sun Mar 29, 2009 2:34 pm

Hi terry,

Looks like you did quite a bit of work ... unfortunately, I'm illiterate with this stuff. I'm totally in dark about what it is or does. I followed the instructions, came up with some sort of independent blank space, and SC refused to Quit so I had to force quit.

Can you explain to a rank novice what this is supposed to do?

Thanks much ... Ken N.



haden_young wrote:Hi,

I have been playing again following a request for flash in SC.

Now, before I post a link to the external please be aware that this is a 30 minute blast to show that it is possible.

This external is for trying out and is liable to crash.

Click on the init button then the loadURLText button then play from there. It does not seem to download.

I am sure there is lots to do. So please ask.

http://www.theaford.co.uk/Site/SC_Externals_files/SCWebViewTest.zip
All the best,
Ken N.
http://fhtinyradio.com/
kenn@fhtinyradio.com
User avatar
Ken Norris
 
Posts: 284
Joined: Mon Nov 03, 2008 7:27 pm

Re: Web View

Postby sctell » Mon Mar 30, 2009 10:20 am

Ken,

The blank space you see is in fact a cocoa window overlayed on top of the SC window. As in the SCGroupWindows external it is grouped with the SC window to give the illusion of being a SC container.

Within the overlay window is a cocoa WebView. As an example Safari is a WebView.

A WebView allows you to embed web content and the various functions of the external allow you to carryout a number of these tasks.

So:

It basically functions as a mini web browser.

Clicking on or passing in download links will download the file.

Clicking on or passing in a pdf link will display the pdf.

etc....

I would suggest you have a play.

I am just about to post an update for the external.
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby sctell » Mon Mar 30, 2009 10:43 am

Hi all,

I have just posted an update to the SCWebView external.

It can be found here:
http://www.theaford.co.uk/Site/SC_Externals.html

I think it is more stable but maybe not 100%.

Although I have not managed to break it I'm sure one of you good fellows will.

I have added a few more functions and incorporated some globals to give feedback.

The full complement of functions are listed below.

I have put a link in a cd fld to a flash animation in the test project mainly because I thought it was excellent work.

Having set up the view click on the cd fld to see it.


FUNCTIONS:

createWindowGroup
createWebView
releaseWebView
setFrameRect

setFocusToWebView
setFocusToSC

hideWebView
showWebView

loadURLText

goForward
goBack

makeTextLarger
makeTextSmaller

reload

doJavaScript
loadHTMLFile
loadHTMLString
getSourceCode

mainFrameTitle
mainFrameURL

setEditable
cut
copy
paste


GLOBALS:

SCWV_frameLoaded
the external sets this global to true
when the frame has finished loading

SCWV_errorDescription
the external sets this global with a text description
relating to the error encountered when loading a page or when downloading.

SCWV_downloadError
the external sets this global with a text description
relating to the error encountered when when downloading.

DOWNLOADING:

When you click on a link that has a file attached the external checks to see if the web view can display it.
If it can, it does.
If it can't it attempts to download the linked file to the current users Downloads folder.

PDF's:

If you click on a link it will open a pdf in the view. Right clicking allows it to be downloaded.
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby Dave_Higgins » Mon Mar 30, 2009 1:50 pm

One little oopsie in the sample project. At the bottom of the instructions field you have:

WHEN YOU HAVE FINISHED WITH THE WEB VIEW
Click "loadURLText" button.
This will remove the web view from the screen.

I think this should be:
Click "releaseWebView" button.

Other than that, it looks good. Will start digging in soon.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: Web View (Back pocket suggestion)

Postby Dave_Higgins » Mon Mar 30, 2009 2:13 pm

Ok. Here we go. More ideas. :-)

Being able to setEditable is really cool. I see, however, that after editing, the source code HTML remains as it was when loaded (no surprise).

What I'd like to see may not be possible. You're probably at the mercy of Apple's APIs, but if you could look into this (in the long run, not an immediate need)... What would be nice is to be able to grab the generated HTML after any edits, and also after any dynamic (AJAX) content is loaded or changed. The folks that do Firefox figured it out, but their browser is more home rolled compared to anything that Apple (WebKit) provides.

I think for my needs, the generated HTML after dynamic content would be more important (I've been messing with AJAX for some time), but with editing enabled, some new HTML after editing could come in handy for some Web Dev tools, too.

Anyway, just something for you to look at when you're up to your ears in the WebView docs someday.

Thanks for the update.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: Web View

Postby johnjohnston1 » Mon Mar 30, 2009 9:57 pm

Hi Terry,
great stuff.

I have managed to crash SC with a script using the external, not sure if it is me or the external. The script is a bit messy, but I am trying to make thumbnails of webpages. The idea would be to build a illustrated links page from a list of urls. Assumes a cd grc "tn"
Anyway here is the script:
Code: Select all
on webThumb tURL
  save
  compact
  save
  global SCWV_frameLoaded, SCWV_errorDescription,SCWV_downloadError,gWebView
  if SCWV_frameLoaded is "" then put false into SCWV_frameLoaded
  put CR&"init"&&the ticks && SCWV_frameLoaded &CR after cd  fld 1
  put SCWebView("createWindowGroup","wd id 100") into gWebView
  put gWebView&CR
  put SCWebView("createWebView","wd id 100",0,0,1000,800) into gWebView
  put gWebView&CR
  put SCWebView("loadURLText","wd id 100",gWebView,tURL) 
  repeat until SCWV_frameLoaded
    put the ticks
  end repeat
  put CR&"looped"&&the ticks && SCWV_frameLoaded &CR after cd  fld 1
  put   replace(tUrl,"http://","")&".jpg" into fname
 
  get shell(merge("screencapture -m ~/Desktop/[[fname]]"))
  put SCWebView("releaseWebView","wd id 100",gWebView) into tInfo
  put findfolder("desktopFolder")& fname into tfile
 
  put globalloc("0,0") into tL
 
  set the picturedata of cd grc "tn" to tFile
  set the sourceRect of cd grc "tn" to (tL&COMMA&item 1 of tL+1000&COMMA&item 2 of tL + 800)
  set the width of cd grc "tn" to 250
  set the height of cd grc "tn" to 200
  set the topleft of cd grc "tn" to "0,0"
  export card from "0,0" to "250,200" to JPEG file tfile
 
  get shell (merge("open ~/Desktop/[[fname]]"))
 
 
end webThumb


The script seems to work, but starts crashing if i run it a few times in succession with the same url. After a crash or 2 it seems to get worse after relaunching SC.

i am not sure if the repeat is a silly idea or not?

If iy would help I can send a crash log
SC Version 4.6.3 OS Version: Mac OS X 10.5.6 (9G55)

cheers

john
User avatar
johnjohnston1
 
Posts: 196
Joined: Sun Jul 06, 2008 10:42 am
Location: Glasgow, UK

Re: Web View

Postby sctell » Tue Mar 31, 2009 2:40 am

Hi John,

Please excuse but responding at work from a PC.

Not sure exactly how your script is called but…..

You should only call put SCWebView("createWindowGroup","wd id 100") once. You only create a window group when first initialising.

If you call this function repeatedly, I am not sure of the outcome.
You are only meant to call it once for each SC window requiring web views.

You should only call put SCWebView("createWebView","wd id 100",0,0,1000,800) once for each web view you require attached to the SC window. If you do not give them different locations they will be stacked on top of each other.
If you require more than one then you need a global for each, say gWebView_A , gWebView_B etc. and any calls will then have to use the correct global for the web view to which you are referring.
You also need to release each web view when you have finished with them.

If you want to post your example, I will take a look.
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby Dave_Higgins » Tue Mar 31, 2009 4:53 am

johnjohnston wrote:.... but I am trying to make thumbnails of webpages. The idea would be to build a illustrated links page from a list of urls.

If you don't really need live updates, you might want to take a look at webkit2png... It's a basic python script file that you run from the command line that generates up to 3 versions of the page as a .png file. Since you're using Leopard (have to for SCWebView) it's a hassle free install. Just make the script executable and call it with shell() like any other command. Once you have a group of images from the URLs you could then use Terry's SCImageBrowser for display and picking.
Code: Select all
Usage: webkit2png [options] [http://example.net/ ...]

examples:
webkit2png http://google.com/            # screengrab google
webkit2png -W 1000 -H 1000 http://google.com/ # bigger screengrab of google
webkit2png -T http://google.com/         # just the thumbnail screengrab
webkit2png -TF http://google.com/        # just thumbnail and fullsize grab
webkit2png -o foo http://google.com/     # save images as "foo-thumb.png" etc
webkit2png -                             # screengrab urls from stdin
webkit2png -h | less                     # full documentation

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -W WIDTH, --width=WIDTH
                        initial (and minimum) width of browser (default: 800)
  -H HEIGHT, --height=HEIGHT
                        initial (and minimum) height of browser (default: 600)
  --clipwidth=WIDTH     width of clipped thumbnail (default: 200)
  --clipheight=HEIGHT   height of clipped thumbnail (default: 150)
  -s SCALE, --scale=SCALE
                        scale factor for thumbnails (default: 0.25)
  -m, --md5             use md5 hash for filename (like del.icio.us)
  -o NAME, --filename=NAME
                        save images as NAME-full.png,NAME-thumb.png etc
  -F, --fullsize        only create fullsize screenshot
  -T, --thumb           only create thumbnail sreenshot
  -C, --clipped         only create clipped thumbnail screenshot
  -d, --datestamp       include date in filename
  -D DIR, --dir=DIR     directory to place images into
  --delay=DELAY         delay between page load finishing and screenshot
  --noimages            don't load images

There are other similar scripts out there if you google around, but this one seemed to fit what I needed.

Hmm. Now that I check it out a little more, I might need to find a better one. This one doesn't seem to honor WebKit (Safari) cookies, so auto log-in doesn't work in many sites.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: Web View

Postby johnjohnston1 » Tue Mar 31, 2009 11:57 am

Hi Terry,
Thanks for the explanation, I'll try it asap

Thanks to Dave too, I'll have a play with that too.

just want to pass a list of urls to SC and create a webpage of thumbnail links, looks like there a few options. I think I had one working with Tomas' webkit external at some point.

cheers

john
User avatar
johnjohnston1
 
Posts: 196
Joined: Sun Jul 06, 2008 10:42 am
Location: Glasgow, UK

Re: Web View

Postby kaj » Wed Apr 15, 2009 4:21 pm

I'm new to SCWebView but not SuperCard. I was looking around for an external and found SCWebView. Which is exactly what I need. I will play with it tonight when I get sometime.

I need to create a project that will use google maps and display data (longitude and latitude locations, parsed kml files) stored in a SuperCard field, then finally display the map along with the data in SuperCard. You know just like any can browser can do. I just don't want to use a browser for entering the data. Everything has to be done inside SuperCard. Does it look like SCWebView is the XFcn to use?

Thanks for your time

Keven
iMac 27" 3.06 GHz Intel Core 2 Duo, 8 GB RAM, Mac OS X 10.6.8, SC 4.7.3
MacPro 3.0 GHZ Intel Quad-Core, 12 GB Ram, Mac OS X 10.6.8
User avatar
kaj
 
Posts: 18
Joined: Wed Apr 15, 2009 3:52 pm
Location: Phoenix

Re: Web View

Postby sctell » Thu Apr 16, 2009 12:26 am

Hi Keven,

All SCWebView is, is a Cocoa overlay window containing a browser. This window does not have any border and is grouped/linked to the SC window.

It is built upon a WebView/WebKit.

Here is a small part of Apple’s description for a WebView.

A WebView object is intended to support most features you would expect in a web browser except that it doesn’t implement the specific user interface for those features.


Within SCWebView you provide the user interface in SC.

You will have to experiment to see if it can fulfill your requirements.
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby Dave_Higgins » Fri Apr 17, 2009 5:45 pm

kaj wrote:I need to create a project that will use google maps and display data (longitude and latitude locations, parsed kml files) stored in a SuperCard field, then finally display the map along with the data in SuperCard. You know just like any can browser can do. I just don't want to use a browser for entering the data. Everything has to be done inside SuperCard. Does it look like SCWebView is the XFcn to use?

You can probably do this by utilizing the JavaScript capabilities in the X. And if it can be done with a specific URL, then JS might not be needed. I would suggest using a browser first to get just what you want then copying out the "Share" url. Using that as a basis you can probably merge some different data into the URL then have the X load that URL into the WebView. Might be a good place to start.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

PreviousNext

Return to XCmds, XFcns, and XRtns

Who is online

Users browsing this forum: No registered users and 1 guest