Jump to content

u-nikos

Members
  • Posts

    38
  • Joined

  • Last visited

Posts posted by u-nikos

  1. Hey all,

    I'm developing a multilingual website with the following tree structure:

    - root

        - en

            - about-us

        - nl

            - over-ons

    But, because "nl" is the main language, I want to set the "nl" page as the website root (essentially stripping out the "/nl/" part within URLs).

    For example:

    http://www.website.nl/over-ons/ = page found

    http://www.website.nl/nl/over-ons/ = page not found

    http://www.website.nl/en/about-us/ = page found

    http://www.website.nl/about-us/ = page not found

    Is this possible with ProcessWire or do I need to modify Apeisa's Multisite module to enable this functionality?

    Greetings,

    Niek

  2. Hey all,

    I've converted the ProcessWire 2.3 rules to Nginx. Hope this will help some people :)

    Greetings,

    Niek

    server {
    	listen 80;
    	listen 443 ssl;
    
    	root /var/www/example.com/public_html;
    	server_name example.com www.example.com;
    	ssl_certificate /etc/pki/tls/certs/example.com.crt;
    	ssl_certificate_key /etc/pki/tls/private/example.com.key;
    
    	client_max_body_size 50m;
    	access_log /var/www/example.com/_logs/access.log;
    	error_log /var/www/example.com/_logs/error.log;
    
    	# -----------------------------------------------------------------------------------------------
    	# Set default directory index files
    	# -----------------------------------------------------------------------------------------------
    
    	index index.php index.html index.htm;
    
    	# -----------------------------------------------------------------------------------------------
    	# Optional: Redirect users to the 'www.' version of the site (uncomment to enable).
    	# For example: http://processwire.com/ would be redirected to http://www.processwire.com/
    	# -----------------------------------------------------------------------------------------------
    
    	if ($host !~* ^www\.) {
    		rewrite ^(.*)$ $scheme://www.$host$1 permanent;
    	}
    
    	# -----------------------------------------------------------------------------------------------
    	# Access Restrictions: Protect ProcessWire system files
    	# -----------------------------------------------------------------------------------------------
    
    	# Block access to ProcessWire system files
    	location ~ \.(inc|info|module|sh|sql)$ {
    		deny all;
    	}
    
    	# Block access to any file or directory that begins with a period
    	location ~ /\. {
    		deny all;
    	}
    
    	# Block access to protected assets directories
    	location ~ ^/(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$) {
    		deny all;
    	}
    
    	# Block acceess to the /site/install/ directory
    	location ~ ^/(site|site-[^/]+)/install($|/.*$) {
    		deny all;
    	}
    
    	# Block dirs in /site/assets/ dirs that start with a hyphen
    	location ~ ^/(site|site-[^/]+)/assets.*/-.+/.* {
    		deny all;
    	}
    
    	# Block access to /wire/config.php, /site/config.php, /site/config-dev.php, and /wire/index.config.php
    	location ~ ^/(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$ {
    		deny all;
    	}
    
    	# Block access to any PHP-based files in /templates-admin/
    	location ~ ^/(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$ {
    		deny all;
    	}
    
    	# Block access to any PHP or markup files in /site/templates/
    	location ~ ^/(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ {
    		deny all;
    	}
    
    	# Block access to any PHP files in /site/assets/
    	location ~ ^/(site|site-[^/]+)/assets($|/|/.*\.php)$ {
    		deny all;
    	}
    
    	# Block access to any PHP files in core or core module directories
    	location ~ ^/wire/(core|modules)/.*\.(php|inc|tpl|module)$ {
    		deny all;
    	}
    
    	# Block access to any PHP files in /site/modules/
    	location ~ ^/(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module)$ {
    		deny all;
    	}
    
    	# Block access to any software identifying txt files
    	location ~ ^/(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md)$ {
    		deny all;
    	}
    
    	# Block all http access to the default/uninstalled site-default directory
    	location ~ ^/site-default/ {
    		deny all;
    	}
    
    	# -----------------------------------------------------------------------------------------------
    	# If the request is for a static file, then set expires header and disable logging.
    	# Give control to ProcessWire if the requested file or directory is non-existing.
    	# -----------------------------------------------------------------------------------------------
    
    	location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|eot|woff|ttf)$ {
    		expires 24h;
    		log_not_found off;
    		access_log off;
    		try_files $uri $uri/ /index.php?it=$uri&$args;
    	}
    
    	# -----------------------------------------------------------------------------------------------
    	# This location processes all other requests. If the request is for a file or directory that
    	# physically exists on the server, then load the file. Else give control to ProcessWire.
    	# -----------------------------------------------------------------------------------------------
    
    	location / {
    		try_files $uri $uri/ /index.php?it=$uri&$args;
    	}
    
    	# -----------------------------------------------------------------------------------------------
    	# Pass .php requests to fastcgi socket
    	# -----------------------------------------------------------------------------------------------
    
    	location ~ \.php$ {
    
    		# Check if the requested PHP file actually exists for security
    		try_files $uri =404;
    
    		# Fix for server variables that behave differently under nginx/php-fpm than typically expected
    		fastcgi_split_path_info ^(.+\.php)(/.+)$;
    
    		# Set environment variables
    		include fastcgi_params;
    		fastcgi_param PATH_INFO $fastcgi_path_info;
    		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    
    		# Pass request to php-fpm fastcgi socket
    		fastcgi_pass unix:/var/run/example.com_fpm.sock;
    	}
    }
    
    • Like 14
    • Thanks 1
  3. Disabling CSRF protection like in the link Pete provided is one way to do it. But if you want to maintain CSRF protection, a better way to go might be to just setup an email filter so that those messages go to your trash automatically. But I will go ahead and add a CSRF specific Exception class to 2.3 so that you can use catch to modify the behavior.

    Thanks Ryan, that sounds like a good solution!

  4. Hey Doolak! Yes this is intended behaviour. I'll explain what the module does:

    1. When a page is saved with the news_article template, the module will find the first parent page that isn't a year/month/day template (in this case: News).

    2. Then it'll create the year/month/day templates under that parent page, and move the news_article into it (in this case: it'll create the 2013 year archive under News, and move the Lorem Ipsum news_article into it).

    3. After the news_article is moved, the module will cleanup empty year/month/day archives (in this case: it'll delete the Recent News and Archive pages because you've told the module that they are year archives, and they are cleaned up because they're empty).

    If you want to retain the Recent News and Archive pages, you should create an different template for the year archives, like "news_year_archive" and tell the module to use this template for the year archives.

    Little example:

    - News (template=news)

        - 2013 (template=news_year_archive)

            - Lorem Ipsum (template=news_article)

            - Dolor Sit (template=news_article)

        - Recent News (template=news_overview)

        - Archive (template=news_overview)

    Although I'm not sure if you really need the Recent News and Archive pages (because News could already show the recent news, and the 2013 page is already an archive), but I hope this helps u :)

  5. Hey Marty,

    No need to do that manually, you can put a little snippet in one of your templates to save the pages automatically (be sure to remove the snippet when you're done).

    Here is a little example:

    <?php foreach ($pages->find('template=news-item') as $item) {
        $item->save();
    } ?>
  6. @OP: Wouldn't be better if these settings were somewhere in config possibly, rather than in administration? This is obviously just my preference, have code related settings in code, but I thought I'll throw it out; You could have something like this:

    Well, all cache related settings are done through the admin UI at the moment, but maybe Ryan has a better opinion on this. I'm fine with both options.

    I've also updated the MarkupCache module to support the CacheName "PageSelector" format.

    MarkupCache.module

    • Like 1
  7. Who uses php 5.4. :P Seriously I wouldn't be able to use this module and many others too. Thanks for removing it.

    Yeah I didn't really think about version compatibility, will try to do so in the future :)

    thanks u-nikos for downgrading to php 5.3  :) it works fine now but when i submit a new rule i become a site-not-found error because the module directs to a wrong url. in my local environment it calls localhost/processwire/setup/date-archiver/. the right url would be localhost/pw/processwire/setup/date-archiver/.

    I've changed the $session->redirect argument from $page->path to $page->url, so it should be fixed now.

  8. I think this seems like a nice format too. I guess what I was trying to get at with the format I recommended was the familiar "if => then" statement. "If the saved page matches this, then clear this cache." I start to have a little trouble when the logic gets to: "If the cache is this and if the saved page matches this selector, clear it." 

    Maybe u could say it like:

    Clear this cache "if a page is saved that matches this selector"

    But the main reason is that I think it would be easier to find a specific rule if all cache names are aligned at the left side :)

  9. I'm fine with those limitations/requirements and would be more than happy if u could integrate this functionality into the MarkupCache module :)

    Edit:

    Maybe it's an idea to switch the name and the selector? Think it would be easier to identify a rule if the name comes first. Especially if you have a bunch of them.

    Something like:

    TopNavigation "template=basic-page"

    HomeNewsSlider "template=news-item"

    Or:

    TopNavigation => template=basic-page

    HomeNewsSlider => template=news-item

    Some extra rows for the textarea field would also be nice. 5 rows seems to be a bit tiny.

  10. That's exactly what the regex functionality is for. The regex /^nav.two.(.*)/ would remove all related parts.

    This can be useful (for example) when caching the top navigation per page. Because the markup of the the top navigation is different for each page (because of the current/parent classnames) you could cache it per page with $cache->get("TopNavigation_" . $page->id). Then you could expire all all TopNavigation caches with the /^TopNavigation_(.*)/ regex when needed. It would also allow us to cache things for specific users $cache->get("TopNavigation_" . $user->id) or even $cache->get("TopNavigation_" . $user->id . "_" . $page->id).

    • Like 2
  11. I'm glad u like it! The begin/end concept is something I remembered from working with the Yii Framework (very nice framework btw, with lots of cool concepts) so I thought: let's integrate that ;)

    For the second part:

    I tried to put the rules on one line but I wasn't sure if I could get the parsing (what is the selector part, what is the name part and is the name a regex pattern?) right. It would be possible to check if the name begins with a non-alphanumeric, non-backslash, non-whitespace character (aka delimiter) to determine if it's a regex or not (and I'm oké with that), but if someone decides to begin a cache name with a "!" character (or similar) the rule would break. I also don't know if selectors can contain question marks, but if that's not the case and you're okay with the delimiter thing, then one rule per line would definitely be better.

  12. Yeah the configuration is a bit vague at the moment, but it works like this:

    The first line (uniqueName:) specifies the markup cache that should be expired when a page is saved that matches the selector on the second line (pageSelector:).

    Rule 1 (cache name or cache name regex)

    Rule 1 (page selector)

    Rule 2 (cache name or cache name regex)

    Rule 2 (page selector)

    ...

    If someone has a better idea then I would love to hear it. This is just one way to do it :)

  13. Hey all,

    I think it would be nice if the MarkupCache module could automatically expire specific caches when specific templates or pages are saved. This would allow us to cache heavy parts of a page for a very long time (or forever), and it'll only need to re-create the heavy part if its content has changed. It would also make sure no out-of-date content is shown.

    Advantages over the normal page cache are:

    - The normal page cache needs to re-render the whole page, this only needs to re-render the part that has changed (performance).
    - The normal page cache does not work with CSRF forms.

    I've coded a little proof-of-concept and I would like to hear if you guys have any suggestions or improvements. It works as following:

    Say you want to cache a news slider on the homepage:
     

    
    <?php if ( ! $data = $cache->get("HomeNewsSlider", 604800)) {
    
    // ... generate markup which uses the news-item template in $data ...
    
    $cache->save($data);
    
    }
    
    echo $data; ?>
    
    


    Then u would somehow configure the MarkupCache to expire the "HomeNewsSlider" cache when a page has been saved with the "news-item" template:

    fn7dp4.jpg

    This is how I have implemented it at the moment, but maybe someone has a better idea?

    I've also added a more convenient method (the begin() and end() methods) for caching markup:

    
    <?php if ($cache->begin("HomeNewsSlider", 604800)): ?>
    
    <h1><?=$page->title?></h1>
    
    // ... some other markup ...
    
    <?php $cache->end(); endif; ?>
    
    


    The module will start buffering the output when calling begin() and it'll save the buffer to the cache when calling end(). If the cache is available the begin() method will output the cached data. This way you wouldn't need to render all output to a $data variable.

    Hope u guys have some feedback or other/better ideas :)

    MarkupCache.module

    • Like 3
  14. Thnx for the comments and tips guys! I've pushed some new changes:

    - Moved Site button from navigation to user actions.

    - Moving search bar to the left on mobile devices.

    - Changed PageList font-size to 12px for better readability.

    - Fixed translation issues.

    - Made PageListStatusHidden class a bit darker for better readability.

    - Removed automatic Javascript resize of title.

    • Like 1
  15. ProcessDateArchiver

    ProcessWire Date Archiver Process

    Automatically archives pages based on a Datetime field (e.g. /news/2013/01/03/some-news-item/).

    Behavior

    - When you add a page with a specified template, the module will automatically create year/month/day archives for it.
    - When you change the date in a specified Datetime field, the page is automatically moved to the correct year/month/day archive.
    - When moving or trashing a page, the module will automatically clean up empty year, month and day archives.

    How to create an archiving rule

    1. Go to the Setup -> Date Archiver screen in the ProcessWire admin.
    2. Click on Add New Archiving Rule.
    3. Specify the template that should be archived (typically the news-item template).
    4. Specify the Datetime field that should be used to determine the date to archive by.
    5. Specify the template that should be used for creating year archives.
    6. Optionally specify the template that should be used for creating month archives.
    7. Optionally specify the template that should be used for creating day archives.
    8. Click Add Rule.

    Tips and tricks

    - Configure the archive templates that will contain other archives to sort its children by name.
    - Configure the archive template that will contain the news items to sort its children by the specified Datetime field.
    - You will improve usability if you dont allow the user to create date archives manually.

    How to Install

    1. Install the module by placing ProcessDateArchiver.module in /site/modules/.
    2. Check for new modules on the Modules screen in the ProcessWire admin.
    3. Click Install for the Date Archiver Process.

    Module download:
    https://github.com/u...hive/master.zip

    Module project:
    https://github.com/u...ssDateArchiver/

    n63lg4.jpg

    • Like 13
  16. Nice! I've updated TinyMCE in the InputfieldTinyMCE module to version 3.5.8 and everything seems to work at first sight. Did some limited testing on Chrome OS-X with inserting images, links and basic styling.

    • Like 2
  17. Are there any plans to upgrade the TinyMCE editor again in ProcessWire 2.3?

    The current solution works fine overall, but what I'm really missing are the webkit image resize handles (integrated since TinyMCE 3.5.5).

    • Like 2
×
×
  • Create New...