Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed Dec 16, 2022
2 parents 15d7e7d + cdb8233 commit 7fdcea0
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 75 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: @MODULE_NAME@ CI
name: ipify CI

# Only on Development we build snapshots
on:
Expand All @@ -8,7 +8,7 @@ on:
- master

env:
MODULE_ID: @MODULE_SLUG@
MODULE_ID: ipify

jobs:
#############################################
Expand Down
13 changes: 6 additions & 7 deletions ModuleConfig.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
component {

// Module Properties
this.title = "@MODULE_NAME@";
this.title = "ipify";
this.author = "Ortus Solutions";
this.webURL = "https://www.ortussolutions.com";
this.description = "@MODULE_DESCRIPTION@";
this.description = " A Simple Public IP Address API Module based on www.ipify.org";
this.version = "@build.version@[email protected]@";

// Model Namespace
this.modelNamespace = "@MODULE_SLUG@";

this.modelNamespace = "ipify";
// CF Mapping
this.cfmapping = "@MODULE_SLUG@";

this.cfmapping = "ipify";
// Dependencies
this.dependencies = [];
// Helpers
this.applicationHelper = [ "helpers/mixins.cfm" ];

/**
* Configure Module
Expand Down
14 changes: 7 additions & 7 deletions box.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name" : "@MODULE_NAME@",
"name" : "ipify",
"version" : "1.0.0",
"location" : "https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/@MODULE_SLUG@/@build.version@/@MODULE_SLUG@[email protected]@.zip",
"location" : "https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/ipify/@build.version@/ipify[email protected]@.zip",
"author" : "Ortus Solutions <[email protected]>",
"homepage" : "https://github.com/coldbox-modules/@MODULE_SLUG@",
"documentation" : "https://github.com/coldbox-modules/@MODULE_SLUG@",
"repository" : { "type" : "git", "url" : "https://github.com/coldbox-modules/@MODULE_SLUG@" },
"bugs" : "https://github.com/coldbox-modules/@MODULE_SLUG@",
"homepage" : "https://github.com/coldbox-modules/ipify",
"documentation" : "https://github.com/coldbox-modules/ipify",
"repository" : { "type" : "git", "url" : "https://github.com/coldbox-modules/ipify" },
"bugs" : "https://github.com/coldbox-modules/ipify",
"shortDescription" : "Description goes here",
"slug" : "@MODULE_SLUG@",
"slug" : "ipify",
"type" : "modules",
"keywords":"",
"license" : [
Expand Down
2 changes: 1 addition & 1 deletion build/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ notifications:
env:
# Fill out these global variables for build process
global:
- MODULE_ID=@MODULE_NAME@
- MODULE_ID=ipify
matrix:
- ENGINE=lucee@5
- ENGINE=adobe@2018
Expand Down
6 changes: 3 additions & 3 deletions build/SetupTemplate.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ component {
command( "tokenReplace" )
.params(
path = "/#variables.cwd#/**",
token = "@MODULE_NAME@",
token = "ipify",
replacement = moduleName
)
.run();

command( "tokenReplace" )
.params(
path = "/#variables.cwd#/**",
token = "@MODULE_SLUG@",
token = "ipify",
replacement = moduleSlug
)
.run();

command( "tokenReplace" )
.params(
path = "/#variables.cwd#/**",
token = "@MODULE_DESCRIPTION@",
token = " A Simple Public IP Address API Module based on www.ipify.org",
replacement = moduleDescription
)
.run();
Expand Down
7 changes: 7 additions & 0 deletions helpers/mixins.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<cfscript>
function myIp(){
return getInstance( "@ipify" ).get();
}
</cfscript>
25 changes: 25 additions & 0 deletions models/Ipify.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Tap into the ipify API for public address retrieval
*/
component {

variables.API_URL = "https://api.ipify.org/?format=json";

function init(){
return this;
}

/**
* Get the public IP Url of the caller
*/
string function get(){
cfhttp(
method = "GET",
charset = "utf-8",
url = variables.API_URL,
result = "local.results"
);
return deserializeJSON( results.fileContent ).ip;
}

}
88 changes: 52 additions & 36 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,68 @@
# Ortus ColdBox Module Template
# IPIFY API Module

This template can be used to create Ortus based ColdBox Modules. To use, just click the `Use this Template` button in the github repository: https://github.com/coldbox-modules/module-template and run the setup task from where you cloned it.
This module allows you to tap into the ipify API: https://www.ipify.org/ : A Simple Public IP Address API, to get the IP address of where you made the call from; your public IP Address.

```bash
box task run taskFile=build/setupTemplate
```
## LICENSE

Apache License, Version 2.0.

## IMPORTANT LINKS

* Source: https://github.com/coldbox-modules/ipify
* ForgeBox: http://forgebox.io/view/ipify
* [Changelog](changelog.md)

## SYSTEM REQUIREMENTS

The `setupTemplate` task will ask you for your module name, id and description and configure the template for you! Enjoy!
* Lucee 5+
* ColdFusion 2018+

## Directory Structure
## Why ipify?

The root of the module is the root of the repository. Add all the necessary files your module will need.
* Ever needed to get your public IP address programmatically?
* Maybe you're provisioning new cloud servers and need to know your IP -- maybe you're behind a corporate firewall and need to tunnel information -- whatever the reason: sometimes having a public IP address API is useful!
* ipify is completely open source (check out the GitHub repository): https://github.com/rdegges/ipify-api

* `.github/workflows` - These are the github actions to test and build the module via CI
* `build` - This is the CommandBox task that builds the project. Only modify if needed. Most modules will never modify it. (Modify if needed)
* `test-harness` - This is a ColdBox testing application, where you will add your testing files, specs etc.
* `.cfformat.json` - A CFFormat using the Ortus Standards
* `.cflintrc` - A CFLint configuration file according to Ortus Standards
* `.editorconfig` - Smooth consistency between editors
* `.gitattributes` - Git attributes
* `.gitignore` - Basic ignores. Modify as needed.
* `.markdownlint.json` - A linting file for markdown docs
* `box.json` - The box.json for YOUR module. Modify as needed.
* `changelog.md` - A nice changelog tracking file
* `ModuleConfig.cfc` - Your module's configuration. Modify as needed.
* `readme.md` - Your module's readme. Modify as needed.
* `[email protected]` - A set of json files to configure the major engines your modules supports.
## Installation

## Test Harness
Just do `box install ipify` and you are ready to roll!

The test harness is created to bootstrap your working module into the application `afterAspectsLoad`. This is done in the `config/ColdBox.cfc`. It includes some key features:
## Usage

* `config` - Modify as needed
* `tests` - All your testing specs should go here. Please notice the commented out ORM fixtures. Enable them if your module requires ORM
* `.cfconfig.json` - A prepared cfconfig json file so your engine data is consistent. Modify as needed.
* `.env.sample` - An environment property file sample. Copy and create a `.env` if your app requires it.
You can get access to our model, or helper to get your public IP address

```js
// Via getInstance: handlers/layouts/views/interceptors
getInstance( "ipify" ).get()

// Via injection: anywhere
property name="ipify" inject="@ipify";
var ip = ipify.get();

// As a delegate: anywhere
component delegates="ip<@ipify"
// Then use with the ip suffix: getIp()

// As a helper: handlers/layouts/views/interceptors
getMyIp()
```

## API Docs
********************************************************************************
Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
www.ortussolutions.com
********************************************************************************

The build task will take care of building API Docs using DocBox for you but **ONLY** for the `models` folder in your module. If you want to document more then make sure you modify the `build/Build.cfc` task.
## HONOR GOES TO GOD ABOVE ALL

## Github Actions Automation
Because of His grace, this project exists. If you don't like this, then don't read it, its not for you.

The github actions will clone, test, package, deploy your module to ForgeBox and the Ortus S3 accounts for API Docs and Artifacts. So please make sure the following environment variables are set in your repository. ** Please note that most of them are already defined at the org level **
>"Therefore being justified by faith, we have peace with God through our Lord Jesus Christ:
By whom also we have access by faith into this grace wherein we stand, and rejoice in hope of the glory of God.
And not only so, but we glory in tribulations also: knowing that tribulation worketh patience;
And patience, experience; and experience, hope:
And hope maketh not ashamed; because the love of God is shed abroad in our hearts by the
Holy Ghost which is given unto us. ." Romans 5:5

* `FORGEBOX_TOKEN` - The Ortus ForgeBox API Token
* `AWS_ACCESS_KEY` - The travis user S3 account
* `AWS_ACCESS_SECRET` - The travis secret S3
### THE DAILY BREAD

> Please contact the admins in the `#infrastructure` channel for these credentials if needed
> "I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12
4 changes: 2 additions & 2 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name":"@MODULE_NAME@-adobe@2018",
"name":"ipify-adobe@2018",
"app":{
"serverHomeDirectory":".engine/adobe2018",
"cfengine":"adobe@2018"
Expand All @@ -13,7 +13,7 @@
},
"webroot": "test-harness",
"aliases":{
"/moduleroot/@MODULE_NAME@":"../"
"/moduleroot/ipify":"../"
}
},
"openBrowser":"false",
Expand Down
4 changes: 2 additions & 2 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name":"@MODULE_NAME@-adobe@2021",
"name":"ipify-adobe@2021",
"app":{
"serverHomeDirectory":".engine/adobe2021",
"cfengine":"adobe@2021"
Expand All @@ -13,7 +13,7 @@
},
"webroot": "test-harness",
"aliases":{
"/moduleroot/@MODULE_NAME@":"../"
"/moduleroot/ipify":"../"
}
},
"jvm":{
Expand Down
14 changes: 7 additions & 7 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name":"@MODULE_NAME@-lucee@5",
"name":"ipify-lucee@5",
"app":{
"serverHomeDirectory":".engine/lucee5",
"cfengine":"lucee@5"
Expand All @@ -11,13 +11,13 @@
"rewrites":{
"enable":"true"
},
"webroot": "test-harness",
"aliases":{
"/moduleroot/@MODULE_NAME@":"../"
"webroot":"test-harness",
"aliases":{
"/moduleroot/ipify":"../"
}
},
"openBrowser":"false",
"cfconfig": {
"file" : ".cfconfig.json"
}
"cfconfig":{
"file":".cfconfig.json"
}
}
2 changes: 1 addition & 1 deletion test-harness/Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ www.ortussolutions.com
component{

// UPDATE THE NAME OF THE MODULE IN TESTING BELOW
request.MODULE_NAME = "@MODULE_NAME@";
request.MODULE_NAME = "ipify";

// Application properties
this.name = hash( getCurrentTemplatePath() );
Expand Down
4 changes: 2 additions & 2 deletions test-harness/box.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"testbox":"*"
},
"installPaths":{
"coldbox":"coldbox",
"testbox":"testbox"
"coldbox":"coldbox/",
"testbox":"testbox/"
},
"testbox":{
"runner":"http://localhost:60299/tests/runner.cfm"
Expand Down
4 changes: 2 additions & 2 deletions test-harness/tests/Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
component{

// The name of the module used in cfmappings ,etc
request.MODULE_NAME = "@MODULE_NAME@";
request.MODULE_NAME = "ipify";
// The directory name of the module on disk. Usually, it's the same as the module name
request.MODULE_PATH = "@MODULE_NAME@";
request.MODULE_PATH = "ipify";

// APPLICATION CFC PROPERTIES
this.name = "#request.MODULE_NAME# Testing Suite";
Expand Down
7 changes: 6 additions & 1 deletion test-harness/tests/specs/ModuleSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="root" {
/*********************************** BDD SUITES ***********************************/

function run(){
describe( "MockData CFC", function(){
describe( "Ipify", function(){
beforeEach( function( currentSpec ){
setup();
} );

it( "can get a public ip", function(){
expect( getInstance( "ipify@ipify" ).get() ).notToBeEmpty();
});

} );
}

Expand Down
9 changes: 7 additions & 2 deletions test-harness/views/main/index.cfm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<cfoutput>
Module Tester
</cfoutput>
<h2>
My IP is: #getInstance( "@ipify" ).get()#
</h2>
<h2>
My helper IP is: #myIp()#
</h2>
</cfoutput>

0 comments on commit 7fdcea0

Please sign in to comment.