Switch to full style
Non-Gimp related posts here
Post a reply

Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 5:20 am

Just an idea:

it could be interesting to have (it not yet available, IDK) an option to ask for getting the list of all topics in order of views received.

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 9:41 am

I don't think there is a way right now on gc. it's like ancient phpbb I think.
So with the help of chatGPT I thought I would share a snapshot taken minutes ago here:
Active Topics listed by Decending Views Snapshot Jan 12, 2024

If you're interested in running the snapshot again at a later time. here's the python code (It takes about 7 minutes to run with 744 pages of pages which you can change number of pages and stuff in the loop)
I named it "gc.py"
Code:
import requests
from bs4 import BeautifulSoup

def get_page_source(url):
    response = requests.get(url)
    if response.status_code == 200:
        return response.text
    else:
        print(f"Failed to retrieve page. Status code: {response.status_code}")
        return None

def parse_table_rows(html_content):
    soup = BeautifulSoup(html_content, 'html.parser')
    table = soup.find_all('table', {'class': 'tablebg'})

    if len(table) > 1:  # Check if there is a second table with the class 'tablebg'
        second_table = table[1]
        rows = second_table.find_all('tr')

        data_array = []
        for row in rows[1:25]:  # Skip the first row as headers
            #print (str(row))
            columns = row.find_all(['td', 'th'])
            row_data = [column.get_text(strip=True) for column in columns]

            # Check if the third column is a link
            if len(columns)>=3:
                link_td = columns[2]
                link = link_td.find('a')
                if link:
                    href_value = link.get('href')
                    row_data.append(href_value)
                data_array.append(row_data)   
           
        return data_array

    else:
        print("Second table not found.")
        return None
    #print (html_content)
    # table = soup.find('table', {'class': 'tablebg'})
   
    # if table:
    #     rows = table.find_all('tr')
    #     for row in rows:
    #         columns = row.find_all(['td', 'th'])
    #         for column in columns:
    #             print(column.get_text(strip=True), end='\t')
    #         print()

if __name__ == "__main__":
    arrs = []
    for p in range(0,745):
        url = "http://gimpchat.com/search.php?st=0&sk=t&sd=d&sr=topics&search_id=active_topics&start=" + str(p*25)
        page_source = get_page_source(url)
        if page_source:
            arr = parse_table_rows(page_source)
            arrs = arrs + arr
            # for i in range(0,len(arr)):
            #     print ("<a href='" + str(arr[7])+ "'>" + str(arr[2]))

    sorted_array = sorted(arrs, key=lambda x: - int(x[5]))
    arr = sorted_array
    print ("<table><tr><td>No.</td><td>Topic</td><td>Author</td><td>Views</td></tr>")
    for i in range(0,len(arr)):
        row = arr[i]
        try:
            print ("<tr><td>"+str(i+1)+"</td><td><a href='http://gimpchat.com/" + str(row[7])+ "'>" + str(row[2]) + "</a></td><td>"+str(row[3])+"</td><td>"+str(row[5])+"</td></tr>")
        except UnicodeEncodeError as e:
            continue     


And I run it with the below command to output it to test1.html which can then be opened with browser
Code:
python gc.py > test1.html

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 9:58 am

Wow.
Is it possible to extend the .py capability in order to do the list by topic groups?
like:
- Gimp Art
- Gimp Scripts and Plug-ins
- etc
to get a shorter list?

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 10:04 am

I'll see what I can do. :D

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 10:07 am

If I remember right Tim did some really interesting stuff in a similar way back over on GimpLearn for viewing custom fonts - but of course that was with recent web technology. But very useful.

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 10:09 am

If I download it as .pdf I get it but truncated horizontally; what can I set while saving to reduce maybe the characters dimension?

well, it can be saved as html, but if it could be produced with a bit smaller character size I think that also in pdf would be readable completely.

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 11:18 am

what are you trying to do as pdf? my snapshot?

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 11:28 am

Yes

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 11:37 am

Once downloaded as .pdf, you can see pages large as this one (only a small amount of the right part is lost)
OnePage of pdf.PNG
OnePage of pdf.PNG (139.2 KiB) Viewed 608 times

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 11:39 am

it fits fine if you choose "Print" then as PDF instead of saving as PDF
I can't attach it because it's bigger than 6MiB

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 11:40 am

here's snapshot broken down into their groups.
It's too large to be clickable link but it's there so you can text search by GROUPNAME:followed by groupname with no prepended space.
https://tinmantaken.blogspot.com/2024/0 ... roups.html

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 11:45 am

trandoductin wrote:it fits fine if you choose "Print" then as PDF instead of saving as PDF
I can't attach it because it's bigger than 6MiB

it's what I did, just repeated and it fits as shown (losing part of the right side

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 11:51 am

The same happens with the new snapshop, maybe you created it with a width larger than 132?

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 11:57 am

Also, the search seems not to work, it indicates the search entered on top but the detail is not

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 12:01 pm

I don't know why Print as PDF not working for you. it fits on mine breaking the long lines into multiple lines maybe because it works better if you open the HTML as webpage then Print as PDF from the source rather than my page on the blog.

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 12:16 pm

So, I can only browse the .html to read.
OK.
Thanks a lot in any case.

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 1:27 pm

How can I upload a file larger than 6Mib to share? like pdf

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 1:33 pm

It already there?

PerViews.png
PerViews.png (17.48 KiB) Viewed 590 times

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 1:40 pm

What? It's already there? stupid me.

Re: Proposal: a "View Topics in order of views"

Fri Jan 12, 2024 1:41 pm

How are you seeing that selection I don't see it for active topics.
Post a reply