Advertisement:

Author Topic: Aeva Media & PrettyURLs  (Read 1753 times)

Offline gamesmad

  • SMF Hero
  • ******
  • Posts: 1,666
  • Gender: Male
Aeva Media & PrettyURLs
« on: April 13, 2012, 10:54:49 AM »
Could anybody advise me on how to get PrettyURLs to work with Aeva Media?

There seems to be basic support (http://domain.com/media), but further than that the URLs are not "pretty" (http://domain.com/media/?sa=item;in=1).

Are there some additional filters I could setup?

Edit - I have found this http://www.simplemachines.org/community/index.php?topic=146969.msg2487779#msg2487779 but not sure if it is the right thing?
« Last Edit: April 13, 2012, 02:25:45 PM by gamesmad »
1 on 1 SMF Help - Want 1 on 1 SMF Help? Post in Help Wanted or drop me a message!

Go Charter! - Please consider becoming a charter member to support SMF development.

Please do not PM me with general questions, posting in the appropriate board will ensure everyone benefits from the advice given.

Offline gamesmad

  • SMF Hero
  • ******
  • Posts: 1,666
  • Gender: Male
Re: Aeva Media & PrettyURLs
« Reply #1 on: April 17, 2012, 08:20:02 AM »
Bump.
1 on 1 SMF Help - Want 1 on 1 SMF Help? Post in Help Wanted or drop me a message!

Go Charter! - Please consider becoming a charter member to support SMF development.

Please do not PM me with general questions, posting in the appropriate board will ensure everyone benefits from the advice given.

Offline Suki

  • Developer
  • SMF Super Hero
  • *
  • Posts: 12,954
  • Kaizoku Jotei
    • Free SMF mods
Re: Aeva Media & PrettyURLs
« Reply #2 on: April 17, 2012, 09:06:33 AM »
I don't know Pretty urls or aeva that well, but by looking at the code posted, the main problem to sort out is the regex and if nothing had changed, the code posted there should work, did you tried it?
Hand in glove
We can go wherever we please
And everything depends upon
How near you stand to me

And if the people stare
Then the people stare
Oh, I really don't know and I really don't care

Offline gamesmad

  • SMF Hero
  • ******
  • Posts: 1,666
  • Gender: Male
Re: Aeva Media & PrettyURLs
« Reply #3 on: April 20, 2012, 08:59:18 AM »
Thanks for your reply.  I haven't tried the code as I'm unsure where to put it?

I've had a look in the PrettyURLs files in Sources and couldn't find anything that looked in a similar format.  I assume I am looking for a file with other similar code in?
1 on 1 SMF Help - Want 1 on 1 SMF Help? Post in Help Wanted or drop me a message!

Go Charter! - Please consider becoming a charter member to support SMF development.

Please do not PM me with general questions, posting in the appropriate board will ensure everyone benefits from the advice given.

Offline Suki

  • Developer
  • SMF Super Hero
  • *
  • Posts: 12,954
  • Kaizoku Jotei
    • Free SMF mods
Re: Aeva Media & PrettyURLs
« Reply #4 on: April 20, 2012, 09:14:30 AM »
Taking a quick look, it should go on prettyurls PrettyUrls-Filters.php, I'm not so sure how the filters system works as I never used pretty urls.
Hand in glove
We can go wherever we please
And everything depends upon
How near you stand to me

And if the people stare
Then the people stare
Oh, I really don't know and I really don't care

Offline nend

  • Sr. Member
  • ****
  • Posts: 849
  • 2 deep n2 the code
Re: Aeva Media & PrettyURLs
« Reply #5 on: May 01, 2012, 11:42:09 PM »
Easy,

In PrettyUrls-Filters.php Add this function
Code: [Select]
// Filter Aeva Media URLs
function pretty_aeva_filter($urls)
{
global $boardurl;

$pattern = array(
'~.*[?;&]action=media;sa=media;in=([0-9]+);(thumba?|preview)(.*)~S',
'~.*[?;&]action=media;sa=(album|item|media);in=([0-9]+)(.*)~S',
'~.*[?;&]action=media(.*)~S',
);
$replacement = array(
$boardurl . '/media/$2/$1/?$3',
$boardurl . '/media/$1/$2/?$3',
$boardurl . '/media/?$1',
);
foreach ($urls as $url_id => $url)
if (!isset($url['replacement']) && strpos($url['url'], 'action=media') !== false)
$urls[$url_id]['replacement'] = preg_replace($pattern, $replacement, $url['url']);
return $urls;
}

In PrettyUrls-Tests.php add this function.
Code: [Select]
// Dummy Aeva Test
function pretty_aeva_test()
{
global $scripturl, $txt;

// Just return a few
return array(
'<a href="' . $scripturl . '?action=media;sa=album;in=1">' . $txt['help'] . '</a>',
'<a href="' . $scripturl . '?action=media;sa=item;in=123">' . $txt['search'] . '</a>',
'<a href="' . $scripturl . '?action=media;sa=media;in=38">' . $txt['members_title'] . '</a>',
);
}

Now on to the db, navigate to...
Code: [Select]
http://yoursite.com/path-to-forum/index.php?action=admin;area=pretty;sa=filters
This is a hidden menu, not selectable, but it is there to edit the json structure in the db.

Replace content with this.
Code: [Select]
{
    "aeva": {
        "description": "Aeva Media filter",
        "enabled": 1,
        "filter": {
            "priority": 38,
            "callback": "pretty_aeva_filter"
        },
        "rewrite": {
            "priority": 38,
            "rule": [
                "RewriteRule ^media/(thumba?|preview)/([0-9]+)/?(.*)$ index.php?action=media;sa=media;in=$2;$1;$3 [L,QSA]",
                "RewriteRule ^media/(?:(album|item|media)/([0-9]+)/?)?(.*)$ index.php?action=media;sa=$1;in=$2;$3 [L,QSA]"
            ]
        },
        "test_callback": "pretty_aeva_test",
        "title": "Aeva Media"
    },
    "boards": {
        "description": "Rewrite Board URLs",
        "enabled": 1,
        "filter": {
            "priority": 45,
            "callback": "pretty_urls_board_filter"
        },
        "rewrite": {
            "priority": 50,
            "rule": [
                "RewriteRule ^ROOTURL([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]",
                "RewriteRule ^ROOTURL([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1.$2 [L,QSA]"
            ]
        },
        "test_callback": "pretty_boards_test",
        "title": "Boards"
    },
    "topics": {
        "description": "Rewrite Topic URLs",
        "enabled": 1,
        "filter": {
            "priority": 40,
            "callback": "pretty_urls_topic_filter"
        },
        "rewrite": {
            "priority": 55,
            "rule": [
                "RewriteRule ^ROOTURL([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1;topic=$2.0 [L,QSA]",
                "RewriteRule ^ROOTURL([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]"
            ]
        },
        "test_callback": "pretty_topics_test",
        "title": "Topics"
    },
    "actions": {
        "description": "Rewrite Action URLs (ie, index.php?action=something)",
        "enabled": 1,
        "filter": {
            "priority": 55,
            "callback": "pretty_urls_actions_filter"
        },
        "rewrite": {
            "priority": 45,
            "rule": "#ACTIONS"
        },
        "test_callback": "pretty_actions_test",
        "title": "Actions"
    },
    "profiles": {
        "description": "Rewrite Profile URLs. As this uses the Username of an account rather than it's Display Name, it may not be desirable to your users.",
        "enabled": 0,
        "filter": {
            "priority": 50,
            "callback": "pretty_profiles_filter"
        },
        "rewrite": {
            "priority": 40,
            "rule": "RewriteRule ^profile/([^/]+)/?$ ./index.php?pretty;action=profile;user=$1 [L,QSA]"
        },
        "test_callback": "pretty_profiles_test",
        "title": "Profiles"
    }
}

Piece of cake, lol,  ;)

*edit

The link in my sig has a Aeva Gallery with it done this way. I just copied and pasted my work from there.