Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 30 Sep 2014, 07:49
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
thread_saver
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [26 Posts]   Goto page: Previous 1, 2
Author Message
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Tue 20 Dec 2011, 11:36    Post subject:  

I was trying to use an array instead and figured out how to get it
by replacing the --separator "\n" \ with a new line Very Happy

I cleaned up the code here a bit too
in the actual code I dont use echo but its here only for a working snippet

thanks for all the suggestions
all working code is good code I just wanted to use arrays
*because later it will be easier to translate this to BaCon code


*args $1,$,2,$3 are sometimes arguments from the command line
so I dont like to force 'set' those



Code:
SEL=`Xdialog \
        --title "thread_saver" \
        --separator "\n" \
        --stdout \
        --3inputsbox  "thread_saver" 0 0 \
            "URL (dowload this link)" "$1" \
            "end page number" "$2" \
            "name the html file" "$3"`

# lets get the three values in 3 separate  arrays
SEL_ARRARY=($SEL)

THREAD=${SEL_ARRARY[0]}
NPAGE=${SEL_ARRARY[1]}
NAME=${SEL_ARRARY[2]}

echo $THREAD
echo $NPAGE
echo $NAME

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Tue 20 Dec 2011, 12:12    Post subject:  

looks good!

BTW/ that will work with --separator " " as well.
Back to top
View user's profile Send private message 
puppyluvr


Joined: 06 Jan 2008
Posts: 3203
Location: Chickasha Oklahoma

PostPosted: Tue 20 Dec 2011, 18:21    Post subject:  

Very Happy Hello,
Wow, talk about clean..
IDK how (but I will) that works, but it does..

SEL=`Xdialog \

allows you to chain the commands so cleanly..
Why wasnt I informed of this... Wink

Why are the arrays # from 0 but as variables, saved from 1.??

_________________
Close the Windows, and open your eyes, to a whole new world
http://puppylinuxstuff.meownplanet.net/puppyluvr/
Puppy Linux Users Group on Facebook

Puppy since 2.15CE...
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Tue 20 Dec 2011, 18:31    Post subject:  

Dear Joe,

Thanks from me and many of us here.

With kind regards,
vovchik
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Tue 20 Dec 2011, 19:45    Post subject:  

Even more.....

Code:
SEL=`Xdialog \
        --title "thread_saver" \
        --separator "\n" \ #or " "
        --stdout \
        --3inputsbox  "thread_saver" 0 0 \
            "URL (dowload this link)" "$THREAD" \
            "end page number" "$NPAGE" \
            "name the html file" "$NAME"`


That won't set the vars, but will avoid the $1, $2,$3 ( actually, you could use anything $A,$B,$C....etc..)

Another way is to set a default text for each item which is helpful to know the exact syntax to enter (a sort of tooltip) and it also highlights each item.
Code:

SEL=`Xdialog \
        --title "thread_saver" \
        --separator " " \
        --stdout \
        --3inputsbox  "thread_saver" 0 0 \
            "URL (dowload this link)" "http://murga-linux.com/puppy/viewtopic.php?t=74404" \
            "end page number" "5" \
            "name the html file" "Xdialog-tips"`


I guess we've worked this one over pretty well Smile



Cheers,
s
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Tue 20 Dec 2011, 23:44    Post subject:  

Quote:
I guess we've worked this one over pretty well Smile


yeah, but all for the better .I like the part you did about removing the $1 $2 $3
and using the names nice

I said in another post what I want to do and seaside why I wanted to rewrite
your app so I can use this as a front end to some other tools I wrote
in BaCon to convert bbcode to bbpress

in other terms the murga post format to puppylinux.info format
I can already do this in raw bbcode but after a post is made the server embeds html
and converts bbcode to html

it will take me awhile to see the pattern and strip out all the embedded html
then convert the cleaned up html to bbpress

if that sounds a bit confusing its because it is Smile
but we have good company here to get it done
Joe

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Wed 21 Dec 2011, 20:53    Post subject:  

this is quite a challenge Exclamation

I am trying to strip the mugra html
so that later I can reformat it to bbpress format for puppylinux.info

this is as far as I got so far
if anyone would like
to take a turn getting dizzy staring at code here it is Laughing

this is a dragNdrop script I wrote
you'll get the idea what it does after you run it on a downloaded post

it strips the code done to a very basic format

P.S and I don't like sed ... but its fast for conversions
Code:


#!/bin/bash

# Joe arose filter html
cat "$@" >"$@"".clean"
sed -i '2,261d' "$@"".clean"

#sed -i '/viewtopic.php/d' "$@"".clean"
sed -i '/mode=quote/d' "$@"".clean"
sed -i '/icon_quote.gif/d' "$@"".clean"

sed -i '/nowrap/d' "$@"".clean"
sed -i '/tbody/d' "$@"".clean"
sed -i '/#top/d' "$@"".clean"
sed -i "/\<option/d" "$@"".clean"
sed -i '/viewprofile&amp/d' "$@"".clean"
sed -i '/newtopic&amp/d' "$@"".clean"
sed -i '/subSilver/d' "$@"".clean"
sed -i '/AdBrite/d' "$@"".clean"
sed -i "/\<table/d" "$@"".clean"
sed -i '/gensmall/d' "$@"".clean"
sed -i '/r1soft/d' "$@"".clean"
sed -i "/images\/avatars/d" "$@"".clean"
sed -i "/images\/smiles/d" "$@"".clean"
sed -i "/adbrite/d" "$@"".clean"
sed -i "/R1miniHCP/d" "$@"".clean"
sed -i "/\<div/d" "$@"".clean"
sed -i "/\<script/d" "$@"".clean"
sed -i "/icq_status/d" "$@"".clean"
sed -i "/_icq.prototype/d" "$@"".clean"
sed -i "/www.phpbb.com/d" "$@"".clean"
sed -i "/postdetails/d" "$@"".clean"
sed -i "/userAgent/d" "$@"".clean"
sed -i "/_icq\(\)/d" "$@"".clean"
sed -i "/getElementById/d" "$@"".clean"
sed -i "/this.ids/d" "$@"".clean"
sed -i "/\<link/d" "$@"".clean"
sed -i "/\<meta/d" "$@"".clean"
sed -i "/\<style/d" "$@"".clean"
sed -i "/Joined\:/d" "$@"".clean"

#add a line before and add for new lines
sed -i "/\<a name\=/i\
\<\/br\>\<\/br\>\<\/br\>\<\/br\>__" "$@"".clean"

# add a long line after the name
sed -i "/\<a name\=/a\
________________________________________________________________<\/br\>" "$@"".clean"

#delete the last 50 lines
sed -i -n -e :a -e '1,50!{P;N;D;};N;ba' "$@"".clean"

# fold the text at 70 characters and rename to html
fold -sw 70 "$@"".clean" > "$@"".cleaned"

#remove tmp file
rm -f "$@"".clean"




updated 12-23-2011

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Fri 23 Dec 2011, 20:25    Post subject:  

I have completely re written the code to reduce it down to the bare basics
and to be used for puppylinux.info only

Presenting puppylinux.info saver !

Easy
Just the link and the page number everything else is automatic
Even the correct name is saved for you Cool


Joe

Code:

#!/bin/sh

# puppylinux_info. saver big_bass re written completely
# 12-23-2011

#------------------------------------------------
SEL=`Xdialog \
--title "info saver" \
--separator "\n" --stdout \
--2inputsbox "puppylinux.info saver" 0 0 \
"URL (dowload this link)" "$1" \
"end page number" "$2" `

# lets get the two values in 2 separate arrays
SEL_ARRARY=($SEL)

THREAD=${SEL_ARRARY[0]}
NPAGE=${SEL_ARRARY[1]}

#------------------------------------------------
add_date=`date "+%m"-"%d"-"%y"`
URL_NAME=`basename $THREAD`
mkdir -p /root/Forum_Threads_info/$URL_NAME"-folder-"${add_date}
cd /root/Forum_Threads_info/$URL_NAME"-folder-"${add_date}

for i in $(seq 1 1 $NPAGE); do

wget "$THREAD/page/$i"
mv "$i" "$URL_NAME""_""$i"
done

Xdialog --title "done" \
--msgbox "Thread downloaded to /root/Forum_Threads_info " 0 0 3000

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Sat 24 Dec 2011, 11:07    Post subject:  

this one is for the murga forum

thread_saver completely rewritten to the basics
12-23-2011

Code:

#!/bin/sh

# thread_saver big_bass completely rewritten to the basics and using Xdialog 
# 12-23-2011
# added date to folder rewritten the download part and the naming
# of the files and numbering 

# original idea was based on
# ThreadGet Seaside 11-24-2010 (Based on Mu's Fetchforum basic program)
# For use on  phpBB forums
# update 3-29-2011 --add startpage, append to existing files


#------------------------------------------------
SEL=`Xdialog \
        --title "thread_saver" \
        --separator "\n" --stdout \
        --3inputsbox  "thread_saver" 0 0 \
            "URL (dowload this link)" "$1" \
            "end page number" "$2" \
            "name the html file" "$3"`

# lets get the three values in 3 separate  arrays
SEL_ARRARY=($SEL)

THREAD=${SEL_ARRARY[0]}
NPAGE=${SEL_ARRARY[1]}
NAME=${SEL_ARRARY[2]}

#------------------------------------------------

add_date=`date "+%m"-"%d"-"%y"`
URL_NAME=`basename $THREAD`
mkdir -p /root/Forum_Threads/$NAME"-folder-"${add_date}
cd /root/Forum_Threads/$NAME"-folder-"${add_date}


# zero start count fix
NPAGE=($NPAGE-1)
let ALL_POSTS=15*$NPAGE

# simplified the renaming renumbering code a lot  big_bass
for i in $(seq 0 15 $ALL_POSTS); do
 
   let N_ADJ=($i/15)
 
   wget "$THREAD&start=$i"
   mv "$URL_NAME&start=$i" "$NAME""_""$N_ADJ"
   echo "$URL_NAME&start=$i" "$NAME""_""$N_ADJ"
done



Xdialog --title "done" \
       --msgbox "Thread downloaded to /root/Forum_Threads " 0 0 3000

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Sat 24 Dec 2011, 11:42    Post subject:  

Dear Joe,

Thanks for this little and very useful app. Just relax now, it is xmas, and we, your friends, will be there to wish you a very merry xmas every day....

With kind regards,
vovchik
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Thu 29 Dec 2011, 11:49    Post subject:  

updated first post for the murga thread saver

12-29-2011
added long names and a filter to clean poorly formatted topic names
this way you can save thread names that had spaces up to twenty words long
they are auto corrected

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 2 [26 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1179s ][ Queries: 13 (0.0356s) ][ GZIP on ]