How to make logo interchangeable, Ruby on Rails - ruby-on-rails

I have created a custom CMS Rails app for a local company, and had the request to allow the logo to be interchangeable for the holidays. For example, they talked about having choices of different logos for each holiday.
I am imaging a radio button looking something like this
Normal
Christmas
Christmas1
Easter
Easter1
Thanksgiving
4th of July
etc
So, does anyone have any idea how I would implement this, or have any experience with it?
I have an admin panel for them and I am thinking of adding a section that has the radio buttons mentioned above, and depending on what one is set a variable changes values and displays a different logo from the images folder, but not sure if that's the route to go.
Thanks for any help.
Edit: Sounds like I have the right idea, can I get some advice from you experts on how you would go about implementing this? I'm thinking of having a logo model where they can upload the image to, but how would I implement that into the view to allow them to pick?

Don't confuse two different things you will store in the database: the list of logos, and the setting of the current logo. The former will consist of a model and a table. The latter could be a simple foreign key pointing to the correct entry in that table.
You should also have a new controller since you plan to let them manage the list of logos. For image uploading check out Carrierwave which has comprehensive examples.

Related

Ember search engine

I am creating an Ember app that has a search engine built into it say for houses. My results change a lot as houses are found / added or removed / sold. Therefore my search results change all the time.
I also have pages for each house which has a similar houses section on it that shows always changing similar houses to this one.
I am trying to find the best way to make this app crawlable to search engines.
I could like discourse use noscript tages for each page but as all my houses pages can hold different information and structure depending on the agent/ seller this would be a lot more work basically duplicating what the client is doing!
I could go down the phantomjs route and cache all my pages and serve via the escapedfragment_ method but i am thinking this would be a resource intensive approach with content changing so much. Also with my house pages having similar houses on them that can change depending on the user / location etc, i am not sure how to cache these sections.
Another method i am toying with is to convert my page / section templates into a serverside template so i can render it on the server. For example when a customer creates a house page via my ember app in the format they require they click publish and i convert the rendered html into serverside template with placeholders etc for data.
Anyone help with this ? Any ideas / suggestions / advice would be great!
I think you've kind of answered your own question. This is all about trade offs and finding the solution that is best for your particular case. There is no silver bullet. Personally I go with something close to the noscript route, but instead of putting things inside noscript tags, I put them in regular divs with a class of no-ember, which are visible by default. Then when the document is ready I test to see if the client supports push state. If so, I initialize my Ember app and hide the no-ember divs. If not, then all of the no-ember divs are visible so that the client can see/use the content like normal.

Filtering Database results in Ruby on Rails

I have created a rails application where users can create and apply for jobs.
As you can imagine many of these jobs come from various countries/cities and have different salaries and industries etc. I would like to create a system that will allow my users to filter through all the options to find what they're most interested in.
I would like to use a combination of radio buttons and a salary slider bar (probably Jquery) in my view to select the results that show. I would then like the page to reload (without refreshing - like AJAX) when the user hits a button called filter results.
A good example of the kind of filtering system I would like to achieve can be seen at WIWT.com if you just click on their top filters button they have an excellent filtering system.
It would be great to know where to get started on this and whether there are any easy to use Gems already out there? Also if anyone could point me in the direction of a thorough tutorial that would be great as much of what I have found has been fairly incomplete and based around has_scope.
Thanks!

Building a site with Orchard CMS

I'm in the early stages of trying to learn Orchard, and I'm still seem to be struggling with the basics on how to build a page containing a multitude of various content that can be easily managed by non-technical users.
Ideally, what I'm trying to do is the following, I just can't figure out how to fit it into the Orchard architecture using Content Types, Parts, Fields, Widgets, Zones, etc. Also, since I'm still learning, I'm also trying to avoid any custom modules, or hard-coding content into the site (though I'm open to the idea, if that's the best way to get it done!).
Goal: Create a "home page" layout containing a Menu, Image slideshow, and several feature descriptions. For each image in the slideshow, I need a title, sub-title, description, and an image. To make this easy for non-technical users to manage, I would like to define the HTML template (custom Content Type, Part, or whatever), and allow authors to specify just those well-defined properties. I tried using Content Parts for this, but unfortunately, I can only have one Content Part of a particular type on a piece of Content. I also saw recommendations to create multiple Content Parts with the same set of properties, but I don't know how many images will be displayed (and I don't want to assign an arbitrary number).
I need to do something similar for feature descriptions, allowing authors to specify an image, title, description, and a page to link to. I'm running into the same problem as above, I'm not sure how to allow authors to specify a finite list of content, but have each content item be well-defined.
So far, the best option appears to be creating some sort of custom widget to "host" the content, but for some reason, my gut tells me that creating a custom layer for a single page just to specify which content to display is abusing the purpose of layers, which is begin able to customize a particular layout based on some criteria (whether or not the user is authenticated, for example).
I hope that made sense, and I apologize that it took so many words to explain my issue, I've just really reached my peak of frustration, and although I think that the Orchard guys definitely have it figured out in terms of architecture, I just can't get past these seemingly simple problems to build a simple website.
I greatly appreciate any tips, suggestions, advice this community has to offer!
TIA, -Jeremy
What you defined in Orchard terms is a Content Type named Feature.
Go to Contents -> Content Type, and click Create.
Select those parts by default:
Title, because you want your authors to provide a nice title/name for the features
Autoroute, which will create a SEO friendly url based on the Title (can be customized)
Click Save
Add specific Fields
SubTitle, of type TextField. Configure it to Default, Required.
Description, of type TextField. Configure it to TextArea, Required.
Image, of type Media Picker. Configure it to Required.
You can add some Hints to each fields, which will be displayed in the Feature editor to describe what to enter in each field. Very useful for authors.
Now you can create Features by clicking on the link in the top left part of the Dashboard.
Next step is to put those features on the homepage. What I suggest is to create a Projection which will be set as the homepage. A Projection is just a Page with an Url, which will display the result of a query as its content. The Query in your case will be "Give me all Features ordered by Creation Date".
In the dashboard, click on Queries
Click on "Create a new Query"
Enter "All Features"
Click on "Add a new Filter"
Select Content Type, then select Feature, Save
Click on "Add a sort Criterium"
Select "Creation Date", then Descending, Save
At this point, you can already preview the result of the query by clicking on Preview. But what we want is a front-end page.
Create a new Projection by clicking on Projection in the "New" section of the dashboard (top left again)
- Give it a title, and don't forget to check "Set as Home page" to make it the home page
- Select the only available query, named "All Featrues"
- Save
On the home page you should see all the features, ordered by date. But what you want is a slider. At that point you need two more steps:
- Integrate a slider jQuery plugin
- Render the HTML compatible with your jQuery plugin
By default, when you render a Projection it will use the standard "Summary" layout. But using projections you can decide exactly what layout you want to apply, and exactly what html tags and classes.
Edit the query named "All Features"
Add a new Layout
Select Html List
Select "Properties" and Save
Click Add Properties
Select Display Text, Save
Do the same for
Feature:SubTitle
Feature:Description
Feature:Image
Save your query
Edit the home page projection and select this specific Layout instead of the default one.
You will see that each property is rendered in an html container.
By editing each property you can decide which class to apply, and which html tag to use. By changing them you can render exactly what you want, and customize your CSS/HTML to render the slider nicely. This is purely your HTML know have to apply here, or find some articles about that.
For your editors, they just have to go to the dashboard and add/update some feature content items, it will be reflected on the website.
Optionally there is a Slider module on the Orchard Gallery. You can try this one too. But if you want to handle exactly what happens the technique I described is better.
I've just gone through this exact scenario myself. I think that what you want can be accomplished using Orchard Lists. The UX is not exactly intuitive for the end user, but it seems like it's the most straightforward way to accomplish this goal without installing/developing a custom module.
First, make sure you're using Orchard 1.4 because you'll need the built-in support for generating alternates for Container Widgets for each zone. Enable the Shape tracing, Url alternates and Widget alternates modules.
Now, create a list of items as described in the documentation (see http://docs.orchardproject.net/Documentation/Creating-lists). Translate "book review" into "slide" and "book reviews" into "slides" and you get the idea. You can add custom fields to represent your subtitle, description, etc. I'd just keep the image as part of the content itself instead of creating a custom field for it.
If you've followed the steps in the documentation, you should now be seeing a list of your slides rendered as ul/li's. Now you'll want to customize how things are rendered so you can show your custom fields and generally customize the tags. Use the shape tracer and create alternates for the list as you see fit. Now you're free to control all the rendering. See http://weblogs.asp.net/bleroy/archive/2011/03/27/taking-over-list-rendering-in-orchard.aspx and http://weblogs.asp.net/bleroy/archive/2011/05/23/orchard-list-customization-first-item-template.aspx for ideas.
Managing this list from your end-user's perspective is actually quite easy, but I don't really feel that it's very intuitive.
It took me three days of digging through blogs and docs to figure this out for myself.
I'd also recommend this wonderful module called Featured Item Slider. It has all the basic functionalities of a slideshow, including all mentioned in the question, plus some fantastic additional capabilities, such as different animations. You can also fine tune the layout and styling by providing additional css. Get the source here. And here is the slideshow in action. If a module already exists providing the functionality you're looking for, then it's best to use that rather than reinvent the wheel, unless you do it for learning purposes.

Moderated model editing in Rails2

I want to allow users to edit a model, adding a picture, url and/or phone number to it. However I don't want these changes to show up until they are confirmed by a moderator. I do however want to allow the users to create new entries without moderation, but they cannot include the picture, url, and/or phone number (they can include basic details like the name and surname). Or better, they can include the picture etc. but at the start only the basic information will show up until the picture etc. are accepted by a moderator.
I'm using Rails 2.3.5.
If you want to keep things simple, you can just have a moderated? on your model. Then have your moderated have complete edit access to un-moderated models.
And when rendered your model, don't show the picture, url, or phone number.
I like Andrew's suggestion above for state-machine and versions, but if you want to keep it simple, a nice flag will do exactly that
It sounds like you need to record the revision history of your model. You can use a plugin like Vestal Versions to do this.
When you update your model, you need to set a moderated flag on it. This could be done with a simple checkbox, or a more advanced state machine plugin.

Keeping track of refinements made to page using ASPX (Breadcrumb trail)?

I have done stuff like this before, but I want to figure out the most efficient way of doing this. There is my scenario:
A user can search our site. Depending on that search they have a number of refinements they can make to the data. There are categories for different refinements. Each refinement is represented by a checkbox. The refinements might look like this:
Appliances:
Washer,
Dryer,
Dishwasher,
Microwave
Rooms:
Family,
Dining,
Bedroom,
Game
Each refinement has its own ID. The checkboxes are not ASPX controls. The HTML for the boxes is being built server side. I may want to change that, but not sure if it is going to matter.
When the page is posted back to, I am building the breadcrumbs for it and preselecting (checking) the refinements that were checked. The breadcrumbs are not clickable. However, I need to keep track of what may have been previously checked. So the breadcrumbs should look like this:
Washer, Dryer > Bedroom > Microwave
Each ">" represents a new refinement search. The user can unselect a refinement a remove the item from the breadcrumb list. So let's say they uncheck Dryer and Bedroom:
Washer > Microwave
I need some suggestions on how I should keep track of the refinements and building / rebuilding of the crumbs. TIA!
I don't think breadcrumbs are the right metaphor for this application. Breadcrumbs are a navigational aid, to show the path someone took to get where they are, such as:
Home -> My Account -> Profile -> Edit Preferences -> Change Address
Meaning that the user entered the site via the home page, clicked the My Account link, etc. etc. etc.
This user should be able to get back to the Profile page by clicking "Profile" in the breadcrumb trail.
I think what you really want for this application is a Shopping Basket metaphor, where all refinements are added to a list, and then the list can be displayed at the top of the page in a "My Refinements" area. Bonus points for making the items in the list selectable via CheckBoxes for an add/remove functionality.
Generally, once there's an established metaphor, you shouldn't use it for something else, as users get used to a standard way of doing things. ( I recall coming across sliders being used for a list selector and it was very confusing. Dev. should have stuck with the tried and true Dropdownlist)
I'm making this Community Wiki as I haven't actually answered the question.
Well, i ended up using some hidden input controls to keep track of checkbox states.

Resources