How to generate static pages in yii - yii

In one project we need to generate static pages with and not store content on database. We are using Yii framework. Does somebody know the approach that can be implemented in this task? How does one generate static pages in Yii framework? There will thousands of static pages that should be created by users, so how I can edit them?

You can do a few things.
Make HTML/PHP files in another folder that is not under the "protected" directory. Then you can access them: http://mysite.com/files/pagename.html
If you want the same template as the main page, but just different content, put them in the protected/views/site/pages folder. you can then access them by index.php?r=site/page&view=pagename
You can manually create a route for each page in the controller that loads a view, but this sounds out of the question since users will be creating the content.
And probably the best way. Upload the webpage content to the database, store it. Then you can use Yii/Gii Crud tools to get some basic pages laid out to edit those new pages. You would just have to create a way to render those pages as you would like, stripping out bad tags and such.

Related

Hubspot: stage entire website including primary CSS file during website redesign

I am helping a client redesign their website through Hubspot. Their existing site is within Hubspot and their new website will also be within Hubspot. I am attempting to run the development through Hubspot's Content Staging as per this link: https://knowledge.hubspot.com/website-user-guide/how-to-redesign-and-relaunch-your-site-with-content-staging
The problem is that this appears to be on a per page basis rather than a per site basis. A problem with this is that I am unable to stage files such as the primary CSS file, or other CSS/JS files that I need to make changes to, but that the existing website will need to keep untouched throughout development.
Does anyone have any experience redesigning a Hubspot website who may have some advise for me? What am I missing?
Thanks!
When I'm redeveloping a HubSpot site within a client's portal, i'll do it on a template by template basis.
So for example, if you're making a new home page, just attach any stylesheets and scripts you need in the template file itself - found in the Edit > Edit Head menu. Here you can disable the Primary CSS file, and you can also disable domain specific stylesheets (the ones you add in Content > Content Settings) so that your template is only using the assets you want it to use.
Using this technique, you can work on individual templates, and then stage any pages that are using said templates independently of the rest of the website. Finally when you're ready to make your changes site wide, merely move your assets from the Edit head area within your template to the Content Settings area.

redirect google users from indexed html snapshot to my site main page

i have business listing site (www.brate.com) where people can search for local businesses and rate them.
the entire site is build using GWT (i.e. Ajax) and the all content is generated dynamically. Now i am in a phase where i want the site to be SEO friendly, below is my approach and please advise me if its the best way to implement it.
1- create static HTML snapshot of each business and its related data (site, address, phone number, user reviews...etc) and put all the generated HTML files under a single directory
2- create a sitemap xml file that contains all the above HTML links
3- configure webmaster to crawl and index all generated HTML snapshots
now my logic is that when google search query list one of the above generated html files in its search results i want to redirect the user to the site main page (www.brate.com) not the html snapshot.
can i use a redirect like "" in the generated snapshots?
if not what is the best way to achieve the above mentioned logic?
Thanks
Sameeh, one suggested approach for GWT
Ensure that you have correctly handled history tokens for all your pages in GWT. Let the tokens start with exclamation (!).
Associate GWT history tokens with generated pages using #! notation
Let tokens be keyword rich as we do for any URL optimization in SEO
Read through https://developers.google.com/webmasters/ajax-crawling/ for understanding #! notation.
Details on support by Bing: http://searchengineland.com/bing-now-supports-googles-crawlable-ajax-standard-84149

is this a good place to DRY out code?

The owner of a site that I am working on has asked me to make the About Us page editable (by her, through a web interface). In fact, there are 5 pages in total that she wants to make editable - About Us, Terms of Service, and so on.
In the old implementation, when these pages were static view files, I had all the URLs coded into routes.rb
scope :controller => :home do
get :about
get :terms
# etc ...
end
Now that these different actions are fetching data from the DB (or wherever) it seems like the standard RESTful approach might be to make a Pages resource and consolidate all the views into a show action.
That doesn't feel quite right. Individual resources aren't usually hardwired into the site the way an About Us page is - the contents of the page might change, but the page itself isn't going anywhere, and there are links to it in the footer, in some of our emails, etc.
Specifically, factoring out the individual routes from the PagesController would raise the following problems:
I couldn't used named route helpers like about_path
The routes for permanent pages on the site would be stored in the database, which means that...
maintenance would probably be a headache, since that is not the normal place to keep routes.
So currently I think that the best approach is to leave these URLs coded into routes.rb, and have separate controller actions, each of which would fetch its own page from the DB.
Can anyone share some insight? How do you deal with data that's not totally static but still needs to be hard-wired into the site?
If you are going to allow markdown, I like the idea of a Pages controller and model. If your layout feels like all 5 pages should have a similar feel, then I'd go with one template that populates with the user generated content and appropriate navigation.
My choice would be to set the routes, make the views (including routing), and populate the views with the user generated markdown.
Without knowing more about your site, it's hard to say, but my preference is not to allow users to generate pages that reflect the site identity (About, terms, etc.) unless that's what they are paying for.

How do I manage assets in Rails 3.1?

OK, so I'm starting a new project using Rails 3.1 and I'm new to CoffeeScript.
Anyway, I like the idea of having asset files representing controllers but what if I only want the JS to render when the controller is called?
For example, I have a controller called Game. In my games.js.coffee file, I put some code in there and it's called for every page request. Even pages that have nothing to do with Games.
In Rails 3.0.7, what I would do is put a yield(:js) in the application erb file and then call content_for(:js) in my Games#action view. That way, only the js that was needed for that controller was loaded.
Or, am I going about this the wrong way? Is it better to have ALL js code loaded and cached for every page request to improve performance?
Thanks for any suggestions.
Is it better to have ALL js code loaded and cached for every page request to improve performance?
Basically, the Rails team decided that the answer is usually "yes." Most sites work best with just a single (minified) JS file, which you get by default in Rails 3.1. That way, once the user has accessed a single page of your site, all other pages will load quickly, since all the JS has been cached.
If your site has a huge amount of JS (think Facebook), then I'd suggest architecting your site to load rarely-used JS code asynchronously, using a library like RequireJS. Otherwise, I wouldn't bother loading different code under different controllers; it's a lot of extra work for a marginal benefit.
Take a look at this plugin, I think it solves your problem: https://github.com/snitko/specific_assets

When is a website considered "static" or "dynamic"

I have created a site, which parses XML files and display its content on the appropriate page. Is my site a dynamic web page or static web page?
How do dynamic and static web pages differ?
I feel it's dynamic, because I parse the content from xml files; initially i don't have any content in my main page..
What do you think about this, please explain it..
I would describe your pages as dynamic. "Static" usually means that the file sitting on the web server is delivered as-is to the user; since you're assembling the pages from data files, I'd call them dynamic even if you're not building in any dynamically-changing data.
I don't think this is a hard and fast definition though. If someone feels the page is static because it's assembled from static pages, that's another way to look at it.
This is actually an interesting question..
I would have said it's a dynamic website, as the content is generated programmatically.. but if the XML files do not change, it's no less "static" than straight HTML files served though Apache.
Say you have a site that is regular HTML files - it would be considered a static web-page; but if you take those HTML files, store them in a database, and have a simple page that allows /view.php?page=index - does that make it a dynamic site?
I would say no, it's just a static site served through a database, or XML files (instead of a file-system).
Basically: if the content changes without you manually editing those XML files, I would say it's a dynamic site. If it does change, then I would say it's a static site.
Static web pages would be plain HTML content that are delivered. If you are processing any type of XML files at the server side and generating content accordingly, this is a dynamic page. Static pages change content when the page is actually edited & modified.
First result on Google if you had searched for it explains it. http://websiteowner.info/articles/pages/pagetypes.asp
Also, stating that static websites are not updated regularly is not correct. The web and HTML was around even before we started writing stuff in Perl & PHP. There are/were sites that had heavy traffic and were being modified manually.
a simple way to distinguish between static and dynamic:
Static: straight HTML files
Dynamic: HTML is generated through server-side code and a data store(XML, database, etc.)
KISS - Dynamic pages change without changing the page itself.
Your pages are dynamic, because once deployed the content can be changed without changing the page's HTML.
Any content that is fixed and always renders the same is considered Static.