Allow customizing Carbon Ads format
Carbon Ads now supports a new Cover format, which can be forced using an extra query parameter.
This commit is contained in:
		
							parent
							
								
									fcd734079b
								
							
						
					
					
						commit
						9c6c880b1d
					
				|  | @ -5,18 +5,23 @@ import AdComponent from "./ad-component"; | |||
| export default class CarbonadsAd extends AdComponent { | ||||
|   serve_id = null; | ||||
|   placement = null; | ||||
|   format = null; | ||||
| 
 | ||||
|   init() { | ||||
|     this.set("serve_id", this.siteSettings.carbonads_serve_id); | ||||
|     this.set("placement", this.siteSettings.carbonads_placement); | ||||
|     this.set("format", this.siteSettings.carbonads_format); | ||||
|     super.init(); | ||||
|   } | ||||
| 
 | ||||
|   @discourseComputed("serve_id", "placement") | ||||
|   url(serveId, placement) { | ||||
|     return htmlSafe( | ||||
|       `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}` | ||||
|     ); | ||||
|   @discourseComputed("serve_id", "placement", "format") | ||||
|   url(serveId, placement, format) { | ||||
|     let baseUrl = `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`; | ||||
|     if (format) { | ||||
|       baseUrl += `&format=${format}`; | ||||
|     } | ||||
| 
 | ||||
|     return htmlSafe(baseUrl); | ||||
|   } | ||||
| 
 | ||||
|   @discourseComputed | ||||
|  |  | |||
|  | @ -97,6 +97,7 @@ en: | |||
| 
 | ||||
|     carbonads_serve_id: "Your Carbon Ads Serve ID" | ||||
|     carbonads_placement: "Your Carbon Ads Placement" | ||||
|     carbonads_format: "Your Carbon Ads Format" | ||||
|     carbonads_through_trust_level: "Show your ads to users based on trust levels. Users with trust level higher than this value will not see ads." | ||||
|     carbonads_exclude_groups: "Ads will not be shown to members of these groups" | ||||
|     carbonads_topic_list_top_enabled: "Show an ad above the topic list" | ||||
|  |  | |||
|  | @ -438,6 +438,12 @@ carbonads_plugin: | |||
|   carbonads_placement: | ||||
|     client: true | ||||
|     default: "" | ||||
|   carbonads_format: | ||||
|     client: true | ||||
|     default: "responsive" | ||||
|     choices: | ||||
|       - responsive | ||||
|       - cover | ||||
|   carbonads_through_trust_level: | ||||
|     client: true | ||||
|     default: 2 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue