Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
How to create DHTML pages using C language? Please give me some web site where I can find the step by step procedure to create DHTML pages using C.
Regards,
NM
Assuming your application will be executed as a CGI of apache or another HTTP server, you only need to print the HTTP headers and the content of the page to stdout.
The minimal headers expected are:
Content-type: text/html\r\n\r\n
(do not forget the double \r\n)
then write your page.
C? Not so suitable language for that.
But, someone did CMS with that, called Tokyopromenade, Opensource
http://1978th.net/tokyopromenade/
Just for your information
For using C to generate (D|X)HTML, you will have to write CGI programs. CGI programs should output the Content-type: text/html or equivalent before HTML is output.
After that, you can upload the program to the cgi-bin/ or equivalent directory. Remember to set the execution bit on the file.
Have your C program write Content-type: text/html\n\n to stdout before anything else, and you can then generate whatever HTML you wish. The empty line is critical!
"DHTML" is mostly used to describe client-side functionality, and you use Javascript for that.
But if you mean dynamic web pages (server-side functionality), and you must use C, you can use CGI (Common Gateway Interface, RFC3875):
http://hoohoo.ncsa.illinois.edu/cgi/primer.html
However, using C for web pages is not a good choice. It would be better to use a scripting language like Python or Ruby, and either study the CGI support in that language or go for a framework like Ruby on Rails.
To create dynamic webpages using C, there are a couple of ways you can go about this (this is not an exhaustive list):
You use CGI, an old standard for creating dynamic webpages. The way this works is that for each request to your site, your webserver creates a new process, invokes your program (passing information about the request to your program using environmental variables and stdin), and feeds the output from your program to the web browser. As other replies have noted, CGI requires your program to specify the HTTP response headers to the browser.
If you're interesting in using C for performance reasons when developing webpages (this is sort of diving into insanity), CGI clearly isn't an option. If you're this much of a masochist, you should probably look into linking with FastCGI or creating an Apache module. In fact, since you like pain this much, you might as well just start with thttpd and insert your code where needed.
Good luck. You might also consider seeing a shrink.
Search "C library for web applications" here on stackoverflow, it has some good answers.
I haven't tried it, maybe someone would find it usefull: klone.
It is a framework for building standalone web serververs and html templating with
embedded C.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
My blog currently runs Jekyll and the Minimal Mistakes theme, and uses the theme's built in functionality to add the Disqus comments system.
This JavaScript-based commenting system, to me sort of defeats the purpose of having a static blog in Jekyll, considering:
Its JavaScript creates a decisively non-static page.
Comments are not stored with the website.
Comments are stored in some database instead of flat-text files.
My question is, therefore: What is a suitable system for comments that stays as close to the Jekyll philosophy as possible (an ideally runs on gh-pages)?
I found several possible candidates:
Isso is a comments system which is looks similar to Disqus, it works with a SQLite database
Jekyll::StaticComments seems pretty suitable, but it means you have to manually add the comments from emails.
Are there any other options? If so, what would work with gh-pages, and what would work on a self-hosted Jekyll blog?
Here's another solution which is dynamic and uses JavaScript, but doesn't store the comments at a 3rd party provider:
This guy made a static website with Jekyll, but uses GitHub's issue tracker to create his comments.
He uses GitHub Pages to host his blog, and for each new post, he creates a new issue in his blog's repository.
Then, he uses JavaScript to get the issue's comments from the GitHub API and show it on the page.
Here's a blog post which explains how to set this up:
GitHub hosted comments for GitHub hosted blogs
Whether a javascript loaded, externally hosted comment system "defeats the purpose" of a static site is a matter of opinion.
For me, the point is to be able to host the site as entirely static resources, to take advantage of caching, CDN, distributed hosting, etc. I have seen huge advantages to that, and externally hosting my comments doesn't conflict at all.
That being said, it's an interesting question.
Isso (like Disqus) uses JS on the client side and requires server side software (Python based) that you have to manage, so it doesn't seem like this is any closer to your ideal.
Jekyll::StaticComments is in the right direction, but it's not supported on gh-pages if you have GitHub processing your Jekyll site (you can of course generate the static site yourself and then host it on GitHub Pages).
You also need a way for users to submit comments, and then to get those comments into a file that can be used by the generation process (not necessarily via email as you thought though).
So you need to take comments from somewhere, possibly email, possibly yet another third party hosted app (SimpleForm maybe).
And then you need to manually put them into the YAML site, regenerate, then publish, or, you can set up an automated build process for your site, which can pull the user submitted content when available and build and publish automatically.
Other than manually accepting comments through an off-site medium, you're going to deal with something dynamic somewhere.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I would like to customize the login screen in a Linux OS. Not just the bacground image, but everything from buttons to textboxes, even the login method (so not a username + password, but something of my own).
The flavor of Linux doesn't really matter, it only needs to have a graphical interface. I have some experience with Ubuntu though.
However, this would be my first time developing something for Linux -- I have developed applications for Windows before, mostly in C# -- but I am up to the challange to learn something new. So please try to be a bit easier on me, me being something of a noob at the moment.
So, how can I do this?
The "login screen" shown on GNU/Linux systems to login to a graphical session is part of the desktop environment you are using. Various alternatives exist for the zoo of alternative environments out there. Examples are kdm as offered by the KDE desktop environment, gdm as offered by Gnome, xdm, wdm, many others exist. Start by reading the wikipedia article about kdm to get an impression.
You'd have to implement a replacement for that part which serves the same purpose, if the existing options to configure it are not enough. So best probably is to start reading about those. That should give you an impression about the requirements.
Roughly explained you have to create an executable that can be executed by the system and configure that as "desktop manager" in the systems configuration. The exact location of that configuration again depends on the distribution, but the general approach always is the same.
The logic of such a program has to somehow answer the question of whether a user is allowed to login to the system by whatever means chosen. Typically this is done by using PAM in background ("Pluggable authentication modules"). Maybe start by reading an introduction to PAM to gain insight into how things work, which may be a bit confusing at first glance due to its endless flexibility. That framework is used on modern unixoid systems to separate the requirements for that logic from the actual implementation. So you really want to learn about how PAM works too. It is an unbelievable flexible framework where already endless strategies exist, so countless adapters for all sorts of existing authorities like databases, LDAP servers, simple file based authorities, IMAP servers, you name it: everything you can imagine. So chances are that you do not have to implement anything, but just can pick something implemented by someone else and configure / tailor it to your needs.
The logic itself does not have to be complex, it just has to answer that simple question in an clear way: is the user who requests access granted or not. For that it will (or will not) have to consult some existing authority. How exactly that works obviously is completely up to you. The real difficult thing probably is to access and control the graphics hardware without having a running graphical desktop environment to build on (since that is only started afterwards). So you probably have to deal with some hardware abstraction layer. Which again means that you probably want to be using some language like C or C++ for that job, scripting languages are less well suited for such job, also because they introduce all sorts of additional requirements of what has to be installed on a system which becomes unusable if some element inside that chain of utilities break due to the lack of a login screen :-)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
i have an Educational website and i create always pdf files from my learning and ad them for download
but there is many learchers that download my files and reupload them somewhere else
i used google dmca but is there any way to Prevent from re-uploading my files?
One way is to use your .htaccess to prevent hotlinking, but even if you do that, you'll again have the problem that when someone views the document via an in-browser extension (e.g. Adobe Reader, Foxit PDF Reader), they can save it and you've lost control over what they can do with it. Or, depending on how you've set up your site, they can simply directly download it, leaving you again back at square one.
Hence, the solution is to bypass direct access to the document. And, there are a number of ways to do that, which varies based on technique and web software (platform) used.
However, since you didn't mention a particular platform or technology: you can use web controllers (MVC type controllers) to broker the dynamic viewing and displaying of the documents in tandem with a client-side tool / plugin to do the displaying for you (much like Scribd).
However, Scribd uses a proprietary Flash PDF viewer called iPaper, and while it isn't available for use, you can find many other alternatives on the web. One that comes highly recommended (there's even a tag on SO for it) is FlexPaper, an open source plugin that implements a client-side web-based PDF viewer - which I think will suit your needs perfectly (from here):
This project provides a light weight document viewer component
enabling PDF files to be viewed without having any PDF reader software
installed. This project provides both Flex library and stand-alone web
version.
Here are some demos of it in action:
http://flexpaper.devaldi.com/demo/
Sorry, by mistake posted partial comment. Anyway...
Why do you afraid of reuploading of your files ? Put links to original site into the PDF and get profit of this. More copies, more downloads, more popularity for your resource. If you indeed would like to make PDFs available from your site only, you have to hide files from users and provide some functionality to read them from your web site only (you can use existing sites of this type). That makes duplicating of your resources to be harder task, but be ready that many users reject to read it this way.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Before I start: I know this is a very broad question, but it is the best way I could phrase it, I have searched around a lot and can only seem to find generic explanations. I searched SO and didn't find much. I have also skimmed through some pages in the wordpress codex, and didn't find anything really useful.
I would like to create a simple database driven blog-style website, it will really only consist of stories (their title, date, content, etc), I just began teaching myself web development and my idea of how database driven websites work has proven to be completely wrong. I figured you would always need a file connecting to the database for each article, but the more I read I learn about mark up being generated on request, and so on, so the actual /year/month/day/article doesn't actually have to exist on the server, or that may be wrong, that is why I am here.
As I said I cannot find much on this topic that isn't a generic graphic of a server interacting with a web page. How does one go about creating a database driven website of this style? Are the files/directories not actually on the server but only created on a case by case basis as someone requests it? If so, then why can you type out a complete url and it be there with out throwing a 404? I have a lot of questions, really all I need is a strong explanation of how these sites work, code examples, and so on. Could someone explain how they work or point me to information (recommended articles, examples or books)?
EDIT: Please don't recommend a framework, I want to understand how these sites work and build one myself.
It's actually quite simple. Wordpress's index page calls wp-blog-header.php. That file calls for other files, and those files call for other files. It goes on for some time until all the contents of the page are actually loaded.
The databases come in when you start thinking about having users. Obviously the user information is stored in the database. Beyond that, Wordpress keeps post titles, dates, and other information in the database for easy loading later on.
Comments are also stored in the database. Each comment is associated with a number, and in the database, just like the posts, the dates/times as well as the usernames associated with the comments are kept.
Further exploration in the actual Wordpress files will reveal a lot of interesting features.
You might want to check out Django. It is an open source Python web framework that provides a lot of the functionality you are talking about. It also has a lot of very good high-level documentation with even a free e-book. It is centered a bit more on newspaper type sites than blogging, but most of the same principles apply. If you are new to python and like to use IDEs I would recommend checking out PyCharm. It has tight Django integration and makes for simple project setup and debugging.
Generally speaking, you'll use a framework that will take input parameters (year/month/day/article), run some code to fetch data from the database, and dynamically create the webpage. There isn't an actual .html file sitting on the webserver. One of the most popular frameworks to do websites like you're describing is Ruby on Rails, which makes it incredibly simple to do.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am a C programmer and new to web development. Which web-C-technology (open source) suits me to learn quickly for web-development?
Update: my question is based on both client and server technologies.
I know this is going to sound arrogant, but instead of saying that you are ‘a C programmer’ you should say that you are ‘a programmer’ and learn some language better suited to web programming. It will be fun, you will become a better programmer and the applications are very likely to be better, too.
I know that in theory you can write a good web application in any language, but in practice there are lots of aspects that make writing in a more popular (in the ‘webapp sense’) language easier. Lots of examples, if nothing else.
You could try KORE
Kore is an easy to use web application framework for writing scalable web APIs in C.
Kore exposes an easy to use API to build your applications. Below is an example of how simple it is to get going with writing web applications in C. The code will respond to all requests with an "Hello world" response
#include <kore/kore.h>
#include <kore/http.h>
int page(struct http_request *);
int
page(struct http_request *req)
{
http_response(req, 200, "Hello world", 11);
return (KORE_RESULT_OK);
}
Kore makes it easy to get started without having to fiddle with build frameworks such as make.
Using the builtin commands you can create, compile and run Kore applications.
However if you prefer building Makefiles and linking the libraries together yourself, go for it
$ kore create myapp
$ cd myapp
$ kore run
compiling myapp.c
myapp built succesfully!
[parent]: running on https://127.0.0.1:8888
[parent]: kore is starting up
[wrk 0]: worker 0 started (cpu#0)
Source
I'm not aware of any present-day heavy use of C (not C++) for web development, much less one that could be "learned quickly". It's not the right language for the task at large, though some specific modules in a web application could certainly be written in C for performance - and even then C++ would be most likely.
On the client side, you have little choice. You need to know your way around HTML/CSS/Javascript.
On the server-side, you have a ton of options.
I was a C programmer before I got into web development, and when PHP came along, I was attracted to it because it has syntactical similarities with C, and (even better), a lot standard C library functions are there too ( sprintf, fread, etc).
PHP is also a decent place to start as it performs just fine as procedural language, and if you've never done anything remotely OO, you might find that it provides a nice way to get your feet wet.
This is not to say that PHP is the most wonderful language on the planet. There are plenty of issues. But as a "first web-oriented language" for someone coming from a heavy C background, I'm hard-pressed to think of anything significantly better.
I'm not aware of any present-day heavy use of C (not C++) for web development
While not open-source, the G-WAN Web server is the only example I know of Web development in C.
It lets you write C scripts that are run on-the-fly:
http://g-wan.com
Given your experience in C, that may help.
On the client side, you can do nothing in C. On the server side one could argue that it's still possible to create a set of cgi's in C and these cgi's together with some cleverly crafted client code (html+css+javascript) could result in a state of the art web application.
This is, however, based on my experience, a very hard road, and one that's virtually impossible to follow without having a good insight in the very special environment that a web application is. Plus, the end-result will be a Frankenstein-like beast at best. Trust me, been there done that.
My suggestion to you would be to start studying web development as such. That is, client side html+css+javascript and a server side scripting solution. You'll probably benefit from choosing a scripting solution like php, because of its syntactical proximity to C, but IMHO that's the easy part of the job. Understanding how the client side (html+css+javascript) works together to create beautiful, reliable and user friendly web applications is where you need to focus on. Because of your background in C programming, the scripting side will be easier to get started in.
Good luck!
A lot of "web programming" nowadays happens client-side. Unless you investigate (or invent) a cross-compiler from C to Javascript, you're not going to be running a lot of C code in people's browsers.
Server-side, of course, you're free to write stuff in C if you feel like it, and some people do.
Before someone comes to suggest that you use language substitute-fashionable-one, I'd like to tell you that what you need to do the web development with c is to know how to do development in c and understand the nature of protocols, markup, etc. Library needs are minimal here. And no one will tell you which one suits your needs and your perception of beauty.