I have following visualforce page available on Lead layout for adding as inline visualforce page.
<apex:page showHeader="false" sidebar="false" standardController="Lead" extensions="CloudFilesController">
<!-- code here-->
<script>
var objectName = 'Lead';
// code here
</script>
<!-- code here-->
</apex:page>
Except the standard controller and a javascript variable 'ojectName' all the code is same for all objects. I want to automate the creation of these pages for other objects and present user with a setup screen where I list all objects and user can create these by a button click for each objects and then add to Page layout. One way of doing it will be metadata api. I want to do it all in apex so I will probably have to use https://github.com/financialforcedev/apex-mdapi apex wrapper for metadata api.
Are there other ways to do it, any pure apex way?