CodeFund Ads is an ethical and discreet ad platform that funds open-source. It helps your favorite projects thrive by paying maintainers the majority of all generated revenue.
After being approved on the CodeFund platform,
publishers can add CodeFund to their site by including the CodeFund script and adding the CodeFund div
.
<div id="codefund"></div>
<script src="https://codefund.io/properties/PROPERTY_ID/funder.js" async="async" type="text/javascript"></script>
Setting
async
on the script tag will ensure that CodeFund doens't block anything on the publisher's site.
The URLs/routes responsible for ad rendering are:
-
GET
/properties/1/funder.js
→advertisements#show
- embed scriptThis is the embed JavaScript that publishers place on their site. It includes the ad HTML and some logic to inject the HTML to the page and setup the links and impression pixel.
-
GET
/scripts/76bfe997-898a-418c-8f0b-6298b7dd320a/embed.js
→advertisements#show
- embed scriptThis endpoint is to support our legacy system (CodeFund v1) embed URLs. It points to the same endpoint as
/properties/1/funder.js
. -
GET
/display/1.gif
→impressions#show
- creates an impressionThis is the impression pixel image. The impression is created after this image is requested and served successfully. This means that a matching campaign was found and the embed JavaScript did its job correctly.
-
GET
/impressions/76bfe997-898a-418c-8f0b-6298b7dd320a/click?campaign_id=1
→advertisement_clicks#show
- creates a clickThis is the proxy/redirect URL that allows us to track the click. We immediately redirect to the advertiser's campaign URL and background the work to mark the associated impression as clicked.
All enum values are managed as constants defined in config/enums.yml
This file is converted to Ruby constants at runtime.
Introspect what enums are defined via the cli.
ENUMS.constants
ENUMS::USER_ROLES.constants
# etc...
Always use enums instead of "magic" values.
git clone https://github.com/gitcoinco/code_fund_ads.git
cd /path/to/project
cp .env-sample .env
# setup environment variables
bundle install
yarn install
bundle exec rails db:setup
It is recommended to develop with Rails cache enabled. This application relies heavily on cacheing and may not work properly without the cache enabled.
bundle exec rails dev:cache
# => Development mode is now being cached.
The impressions
table will seed with approximately 100k records spread over 12 months by default.
You can increase this by setting the IMPRESSIONS
environment variable and seeding again.
IMPRESSIONS=10_000_000 rails db:seed
You may want to create a teamocil/tmux config for your machine.
SEE: https://github.com/gitcoinco/code_fund_ads/blob/master/.teamocil-example.yml
cd /path/to/project
./bin/teamocil
Alternatively, you may want to create a mert config for your machine to be used with iTerm.
SEE: https://github.com/gitcoinco/code_fund_ads/blob/master/.mert-example.yml
cd /path/to/project
./bin/mert
We avoid bike shedding by enforcing coding standards through tooling.
Ensure the code has been standardized by running the following before you commit.
./bin/standardize
- The
impressions
table is dynamically partitioned by advertiser (i.e.user
) and date - The database user requires permissions to execute DDL and create schema to support dynamic partition tables
- Searchable ActiveStorage metadata
- Eventable